| ... | @@ -1773,25 +1773,41 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step { | ... | @@ -1773,25 +1773,41 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step { |
| 1773 | .use_llvm = true, | 1773 | .use_llvm = true, |
| 1774 | }, .{ | 1774 | }, .{ |
| 1775 | .name = "a", | 1775 | .name = "a", |
| 1776 | .c_source_bytes = "int foo = 42;", | 1776 | .c_source_bytes = |
| | 1777 | \\#include <stdio.h> |
| | 1778 | \\int foo = 42; |
| | 1779 | \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); } |
| | 1780 | , |
| 1777 | }); | 1781 | }); |
| | 1782 | dso.linkLibC(); |
| 1778 | | 1783 | |
| 1779 | const main = addExecutable(b, opts, .{ | 1784 | const main = addExecutable(b, opts, .{ |
| 1780 | .name = "main", | 1785 | .name = "main", |
| 1781 | .zig_source_bytes = | 1786 | .zig_source_bytes = |
| | 1787 | \\const std = @import("std"); |
| 1782 | \\extern var foo: i32; | 1788 | \\extern var foo: i32; |
| | 1789 | \\extern fn printFoo() void; |
| 1783 | \\pub fn main() void { | 1790 | \\pub fn main() void { |
| 1784 | \\ @import("std").debug.print("{d}\n", .{foo}); | 1791 | \\ std.debug.print("exe foo={d}\n", .{foo}); |
| | 1792 | \\ printFoo(); |
| | 1793 | \\ foo += 1; |
| | 1794 | \\ std.debug.print("exe foo={d}\n", .{foo}); |
| | 1795 | \\ printFoo(); |
| 1785 | \\} | 1796 | \\} |
| 1786 | , | 1797 | , |
| 1787 | .strip = true, // TODO temp hack | 1798 | .strip = true, // TODO temp hack |
| 1788 | }); | 1799 | }); |
| 1789 | main.pie = true; | 1800 | main.pie = true; |
| 1790 | main.linkLibrary(dso); | 1801 | main.linkLibrary(dso); |
| 1791 | main.linkLibC(); | | |
| 1792 | | 1802 | |
| 1793 | const run = addRunArtifact(main); | 1803 | const run = addRunArtifact(main); |
| 1794 | run.expectStdErrEqual("42\n"); | 1804 | run.expectStdErrEqual( |
| | 1805 | \\exe foo=42 |
| | 1806 | \\lib foo=42 |
| | 1807 | \\exe foo=43 |
| | 1808 | \\lib foo=43 |
| | 1809 | \\ |
| | 1810 | ); |
| 1795 | test_step.dependOn(&run.step); | 1811 | test_step.dependOn(&run.step); |
| 1796 | | 1812 | |
| 1797 | return test_step; | 1813 | return test_step; |