From d7c2324cdbcb32e285e03aa7938529b9412c72e6 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 14 Jan 2024 20:51:03 +0100 Subject: test/link/elf: trigger build system bug testing relocatable mode --- test/link/elf.zig | 63 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'test') diff --git a/test/link/elf.zig b/test/link/elf.zig index 92aba4f352..8c22d0ad7f 100644 --- a/test/link/elf.zig +++ b/test/link/elf.zig @@ -695,41 +695,40 @@ fn testDsoUndef(b: *Build, opts: Options) *Step { fn testEmitRelocatable(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "emit-relocatable", opts); - const obj1 = addObject(b, opts, .{ - .name = "obj1", - .zig_source_bytes = - \\const std = @import("std"); - \\extern var bar: i32; - \\export fn foo() i32 { - \\ return bar; - \\} - \\export fn printFoo() void { - \\ std.debug.print("foo={d}\n", .{foo()}); - \\} - , - .c_source_bytes = - \\#include - \\int bar = 42; - \\void printBar() { - \\ fprintf(stderr, "bar=%d\n", bar); - \\} - , + const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes = + \\const std = @import("std"); + \\extern var bar: i32; + \\export fn foo() i32 { + \\ return bar; + \\} + \\export fn printFoo() void { + \\ std.debug.print("foo={d}\n", .{foo()}); + \\} + }); + + const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes = + \\#include + \\int bar = 42; + \\void printBar() { + \\ fprintf(stderr, "bar=%d\n", bar); + \\} }); - obj1.linkLibC(); + b_o.linkLibC(); - const exe = addExecutable(b, opts, .{ - .name = "test", - .zig_source_bytes = - \\const std = @import("std"); - \\extern fn printFoo() void; - \\extern fn printBar() void; - \\pub fn main() void { - \\ printFoo(); - \\ printBar(); - \\} - , + const c_o = addObject(b, opts, .{ .name = "c" }); + c_o.addObject(a_o); + c_o.addObject(b_o); + + const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes = + \\const std = @import("std"); + \\extern fn printFoo() void; + \\extern fn printBar() void; + \\pub fn main() void { + \\ printFoo(); + \\ printBar(); + \\} }); - exe.addObject(obj1); + exe.addObject(c_o); exe.linkLibC(); const run = addRunArtifact(exe); -- cgit v1.2.3 From b1ffc2b8b353f64362c27df2ecc44436db234a29 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 15 Jan 2024 00:18:50 +0100 Subject: test/link/elf: patch up relocatable test --- test/link/elf.zig | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/link/elf.zig b/test/link/elf.zig index 8c22d0ad7f..0d76a5b64b 100644 --- a/test/link/elf.zig +++ b/test/link/elf.zig @@ -705,6 +705,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step { \\ std.debug.print("foo={d}\n", .{foo()}); \\} }); + a_o.linkLibC(); const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes = \\#include -- cgit v1.2.3