| ... | ... | @@ -695,41 +695,40 @@ fn testDsoUndef(b: *Build, opts: Options) *Step { |
| 695 | 695 | fn testEmitRelocatable(b: *Build, opts: Options) *Step { |
| 696 | 696 | const test_step = addTestStep(b, "emit-relocatable", opts); |
| 697 | 697 | |
| 698 | | const obj1 = addObject(b, opts, .{ |
| 699 | | .name = "obj1", |
| 700 | | .zig_source_bytes = |
| 701 | | \\const std = @import("std"); |
| 702 | | \\extern var bar: i32; |
| 703 | | \\export fn foo() i32 { |
| 704 | | \\ return bar; |
| 705 | | \\} |
| 706 | | \\export fn printFoo() void { |
| 707 | | \\ std.debug.print("foo={d}\n", .{foo()}); |
| 708 | | \\} |
| 709 | | , |
| 710 | | .c_source_bytes = |
| 711 | | \\#include <stdio.h> |
| 712 | | \\int bar = 42; |
| 713 | | \\void printBar() { |
| 714 | | \\ fprintf(stderr, "bar=%d\n", bar); |
| 715 | | \\} |
| 716 | | , |
| 698 | const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes = |
| 699 | \\const std = @import("std"); |
| 700 | \\extern var bar: i32; |
| 701 | \\export fn foo() i32 { |
| 702 | \\ return bar; |
| 703 | \\} |
| 704 | \\export fn printFoo() void { |
| 705 | \\ std.debug.print("foo={d}\n", .{foo()}); |
| 706 | \\} |
| 707 | }); |
| 708 | |
| 709 | const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes = |
| 710 | \\#include <stdio.h> |
| 711 | \\int bar = 42; |
| 712 | \\void printBar() { |
| 713 | \\ fprintf(stderr, "bar=%d\n", bar); |
| 714 | \\} |
| 717 | 715 | }); |
| 718 | | obj1.linkLibC(); |
| 716 | b_o.linkLibC(); |
| 719 | 717 | |
| 720 | | const exe = addExecutable(b, opts, .{ |
| 721 | | .name = "test", |
| 722 | | .zig_source_bytes = |
| 723 | | \\const std = @import("std"); |
| 724 | | \\extern fn printFoo() void; |
| 725 | | \\extern fn printBar() void; |
| 726 | | \\pub fn main() void { |
| 727 | | \\ printFoo(); |
| 728 | | \\ printBar(); |
| 729 | | \\} |
| 730 | | , |
| 718 | const c_o = addObject(b, opts, .{ .name = "c" }); |
| 719 | c_o.addObject(a_o); |
| 720 | c_o.addObject(b_o); |
| 721 | |
| 722 | const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes = |
| 723 | \\const std = @import("std"); |
| 724 | \\extern fn printFoo() void; |
| 725 | \\extern fn printBar() void; |
| 726 | \\pub fn main() void { |
| 727 | \\ printFoo(); |
| 728 | \\ printBar(); |
| 729 | \\} |
| 731 | 730 | }); |
| 732 | | exe.addObject(obj1); |
| 731 | exe.addObject(c_o); |
| 733 | 732 | exe.linkLibC(); |
| 734 | 733 | |
| 735 | 734 | const run = addRunArtifact(exe); |