test/link/elf: trigger build system bug testing relocatable mode

This commit is contained in:
Jakub Konka 2024-01-14 20:51:03 +01:00
parent 7a96907b92
commit d7c2324cdb

View file

@ -695,9 +695,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
fn testEmitRelocatable(b: *Build, opts: Options) *Step { fn testEmitRelocatable(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "emit-relocatable", opts); const test_step = addTestStep(b, "emit-relocatable", opts);
const obj1 = addObject(b, opts, .{ const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
.name = "obj1",
.zig_source_bytes =
\\const std = @import("std"); \\const std = @import("std");
\\extern var bar: i32; \\extern var bar: i32;
\\export fn foo() i32 { \\export fn foo() i32 {
@ -706,20 +704,22 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
\\export fn printFoo() void { \\export fn printFoo() void {
\\ std.debug.print("foo={d}\n", .{foo()}); \\ std.debug.print("foo={d}\n", .{foo()});
\\} \\}
, });
.c_source_bytes =
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
\\#include <stdio.h> \\#include <stdio.h>
\\int bar = 42; \\int bar = 42;
\\void printBar() { \\void printBar() {
\\ fprintf(stderr, "bar=%d\n", bar); \\ fprintf(stderr, "bar=%d\n", bar);
\\} \\}
,
}); });
obj1.linkLibC(); b_o.linkLibC();
const exe = addExecutable(b, opts, .{ const c_o = addObject(b, opts, .{ .name = "c" });
.name = "test", c_o.addObject(a_o);
.zig_source_bytes = c_o.addObject(b_o);
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
\\const std = @import("std"); \\const std = @import("std");
\\extern fn printFoo() void; \\extern fn printFoo() void;
\\extern fn printBar() void; \\extern fn printBar() void;
@ -727,9 +727,8 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
\\ printFoo(); \\ printFoo();
\\ printBar(); \\ printBar();
\\} \\}
,
}); });
exe.addObject(obj1); exe.addObject(c_o);
exe.linkLibC(); exe.linkLibC();
const run = addRunArtifact(exe); const run = addRunArtifact(exe);