| ... | @@ -4,48 +4,24 @@ pub fn build(b: *std.Build) void { | ... | @@ -4,48 +4,24 @@ pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 4 | const test_step = b.step("test", "Test"); |
| 5 | b.default_step = test_step; | 5 | b.default_step = test_step; |
| 6 | | 6 | |
| 7 | if (@import("builtin").os.tag == .windows) { | | |
| 8 | // TODO: Fix open handle in wasm-linker refraining rename from working on Windows. | | |
| 9 | return; | | |
| 10 | } | | |
| 11 | | | |
| 12 | const lib = b.addExecutable(.{ | 7 | const lib = b.addExecutable(.{ |
| 13 | .name = "lib", | 8 | .name = "lib", |
| 14 | .root_module = b.createModule(.{ | 9 | .root_module = b.createModule(.{ |
| 15 | .root_source_file = b.path("lib.zig"), | 10 | .root_source_file = b.path("lib.zig"), |
| 16 | .optimize = .ReleaseSafe, // to make the output deterministic in address positions | 11 | .optimize = .Debug, |
| 17 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), | 12 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), |
| 18 | }), | 13 | }), |
| 19 | }); | 14 | }); |
| 20 | lib.entry = .disabled; | 15 | lib.entry = .disabled; |
| 21 | lib.use_lld = false; | 16 | lib.use_lld = false; |
| 22 | lib.root_module.export_symbol_names = &.{ "foo", "bar" }; | 17 | lib.root_module.export_symbol_names = &.{ "foo", "bar" }; |
| 23 | lib.global_base = 0; // put data section at address 0 to make data symbols easier to parse | 18 | // Object being linked has neither functions nor globals named "foo" or "bar" and |
| 24 | | 19 | // so these names correctly fail to be exported when creating an executable. |
| 25 | const check_lib = lib.checkObject(); | 20 | lib.expect_errors = .{ .exact = &.{ |
| 26 | | 21 | "error: manually specified export name 'foo' undefined", |
| 27 | check_lib.checkInHeaders(); | 22 | "error: manually specified export name 'bar' undefined", |
| 28 | check_lib.checkExact("Section global"); | 23 | } }; |
| 29 | check_lib.checkExact("entries 3"); | 24 | _ = lib.getEmittedBin(); |
| 30 | check_lib.checkExact("type i32"); // stack pointer so skip other fields | | |
| 31 | check_lib.checkExact("type i32"); | | |
| 32 | check_lib.checkExact("mutable false"); | | |
| 33 | check_lib.checkExtract("i32.const {foo_address}"); | | |
| 34 | check_lib.checkExact("type i32"); | | |
| 35 | check_lib.checkExact("mutable false"); | | |
| 36 | check_lib.checkExtract("i32.const {bar_address}"); | | |
| 37 | check_lib.checkComputeCompare("foo_address", .{ .op = .eq, .value = .{ .literal = 4 } }); | | |
| 38 | check_lib.checkComputeCompare("bar_address", .{ .op = .eq, .value = .{ .literal = 0 } }); | | |
| 39 | | | |
| 40 | check_lib.checkInHeaders(); | | |
| 41 | check_lib.checkExact("Section export"); | | |
| 42 | check_lib.checkExact("entries 3"); | | |
| 43 | check_lib.checkExact("name foo"); | | |
| 44 | check_lib.checkExact("kind global"); | | |
| 45 | check_lib.checkExact("index 1"); | | |
| 46 | check_lib.checkExact("name bar"); | | |
| 47 | check_lib.checkExact("kind global"); | | |
| 48 | check_lib.checkExact("index 2"); | | |
| 49 | | 25 | |
| 50 | test_step.dependOn(&check_lib.step); | 26 | test_step.dependOn(&lib.step); |
| 51 | } | 27 | } |