| author | |
| committer | |
| log | cdf0a2af58ccd4ca4250435f258b35735e953aaf |
| tree | 1b4a40e586d5b744a9d72e07d7876123a31a535c |
| parent | f558c835a41052b7609f0f0b27c5bbc4fe6b024d |
15 files changed, 310 insertions(+), 237 deletions(-)
test/link.zig+172-190| ... | @@ -20,197 +20,179 @@ pub const cases = [_]Case{ | ... | @@ -20,197 +20,179 @@ pub const cases = [_]Case{ |
| 20 | .build_root = "test/link/interdependent_static_c_libs", | 20 | .build_root = "test/link/interdependent_static_c_libs", |
| 21 | .import = @import("link/interdependent_static_c_libs/build.zig"), | 21 | .import = @import("link/interdependent_static_c_libs/build.zig"), |
| 22 | }, | 22 | }, |
| 23 | }; | ||
| 24 | 23 | ||
| 25 | //pub fn addCases(cases: *Standalone) void { | 24 | // WASM Cases |
| 26 | // addWasmCases(cases); | 25 | .{ |
| 27 | // addMachOCases(cases); | 26 | .build_root = "test/link/wasm/archive", |
| 28 | //} | 27 | .import = @import("link/wasm/archive/build.zig"), |
| 29 | // | 28 | }, |
| 30 | //fn addWasmCases(cases: *Standalone) void { | 29 | .{ |
| 31 | // cases.addBuildFile("test/link/wasm/archive/build.zig", .{ | 30 | .build_root = "test/link/wasm/basic-features", |
| 32 | // .build_modes = true, | 31 | .import = @import("link/wasm/basic-features/build.zig"), |
| 33 | // .requires_stage2 = true, | 32 | }, |
| 34 | // }); | 33 | .{ |
| 35 | // | 34 | .build_root = "test/link/wasm/bss", |
| 36 | // cases.addBuildFile("test/link/wasm/basic-features/build.zig", .{ | 35 | .import = @import("link/wasm/bss/build.zig"), |
| 37 | // .requires_stage2 = true, | 36 | }, |
| 38 | // }); | 37 | .{ |
| 39 | // | 38 | .build_root = "test/link/wasm/export", |
| 40 | // cases.addBuildFile("test/link/wasm/bss/build.zig", .{ | 39 | .import = @import("link/wasm/export/build.zig"), |
| 41 | // .build_modes = false, | 40 | }, |
| 42 | // .requires_stage2 = true, | 41 | .{ |
| 43 | // }); | 42 | .build_root = "test/link/wasm/export-data", |
| 44 | // | 43 | .import = @import("link/wasm/export-data/build.zig"), |
| 45 | // cases.addBuildFile("test/link/wasm/export/build.zig", .{ | 44 | }, |
| 46 | // .build_modes = true, | 45 | .{ |
| 47 | // .requires_stage2 = true, | 46 | .build_root = "test/link/wasm/extern", |
| 48 | // }); | 47 | .import = @import("link/wasm/extern/build.zig"), |
| 49 | // | 48 | }, |
| 50 | // // TODO: Fix open handle in wasm-linker refraining rename from working on Windows. | 49 | .{ |
| 51 | // if (builtin.os.tag != .windows) { | 50 | .build_root = "test/link/wasm/extern-mangle", |
| 52 | // cases.addBuildFile("test/link/wasm/export-data/build.zig", .{}); | 51 | .import = @import("link/wasm/extern-mangle/build.zig"), |
| 53 | // } | 52 | }, |
| 54 | // | 53 | .{ |
| 55 | // cases.addBuildFile("test/link/wasm/extern/build.zig", .{ | 54 | .build_root = "test/link/wasm/function-table", |
| 56 | // .build_modes = true, | 55 | .import = @import("link/wasm/function-table/build.zig"), |
| 57 | // .requires_stage2 = true, | 56 | }, |
| 58 | // .use_emulation = true, | 57 | .{ |
| 59 | // }); | 58 | .build_root = "test/link/wasm/infer-features", |
| 60 | // | 59 | .import = @import("link/wasm/infer-features/build.zig"), |
| 61 | // cases.addBuildFile("test/link/wasm/extern-mangle/build.zig", .{ | 60 | }, |
| 62 | // .build_modes = true, | 61 | .{ |
| 63 | // .requires_stage2 = true, | 62 | .build_root = "test/link/wasm/producers", |
| 64 | // }); | 63 | .import = @import("link/wasm/producers/build.zig"), |
| 65 | // | 64 | }, |
| 66 | // cases.addBuildFile("test/link/wasm/function-table/build.zig", .{ | 65 | .{ |
| 67 | // .build_modes = true, | 66 | .build_root = "test/link/wasm/segments", |
| 68 | // .requires_stage2 = true, | 67 | .import = @import("link/wasm/segments/build.zig"), |
| 69 | // }); | 68 | }, |
| 70 | // | 69 | .{ |
| 71 | // cases.addBuildFile("test/link/wasm/infer-features/build.zig", .{ | 70 | .build_root = "test/link/wasm/stack_pointer", |
| 72 | // .requires_stage2 = true, | 71 | .import = @import("link/wasm/stack_pointer/build.zig"), |
| 73 | // }); | 72 | }, |
| 74 | // | 73 | .{ |
| 75 | // cases.addBuildFile("test/link/wasm/producers/build.zig", .{ | 74 | .build_root = "test/link/wasm/type", |
| 76 | // .build_modes = true, | 75 | .import = @import("link/wasm/type/build.zig"), |
| 77 | // .requires_stage2 = true, | 76 | }, |
| 78 | // }); | 77 | |
| 79 | // | 78 | // Mach-O Cases |
| 80 | // cases.addBuildFile("test/link/wasm/segments/build.zig", .{ | 79 | // cases.addBuildFile("test/link/macho/bugs/13056/build.zig", .{ |
| 81 | // .build_modes = true, | 80 | // .build_modes = true, |
| 82 | // .requires_stage2 = true, | 81 | // .requires_macos_sdk = true, |
| 83 | // }); | 82 | // .requires_symlinks = true, |
| 84 | // | 83 | // }); |
| 85 | // cases.addBuildFile("test/link/wasm/stack_pointer/build.zig", .{ | 84 | // |
| 86 | // .build_modes = true, | 85 | // cases.addBuildFile("test/link/macho/bugs/13457/build.zig", .{ |
| 87 | // .requires_stage2 = true, | 86 | // .build_modes = true, |
| 88 | // }); | 87 | // .requires_symlinks = true, |
| 89 | // | 88 | // }); |
| 90 | // cases.addBuildFile("test/link/wasm/type/build.zig", .{ | 89 | // |
| 91 | // .build_modes = true, | 90 | // cases.addBuildFile("test/link/macho/dead_strip/build.zig", .{ |
| 92 | // .requires_stage2 = true, | 91 | // .build_modes = false, |
| 93 | // }); | 92 | // .requires_symlinks = true, |
| 94 | //} | 93 | // }); |
| 95 | // | 94 | // |
| 96 | //fn addMachOCases(cases: *tests.StandaloneContext) void { | 95 | // cases.addBuildFile("test/link/macho/dead_strip_dylibs/build.zig", .{ |
| 97 | // cases.addBuildFile("test/link/macho/bugs/13056/build.zig", .{ | 96 | // .build_modes = true, |
| 98 | // .build_modes = true, | 97 | // .requires_macos_sdk = true, |
| 99 | // .requires_macos_sdk = true, | 98 | // .requires_symlinks = true, |
| 100 | // .requires_symlinks = true, | 99 | // }); |
| 101 | // }); | 100 | // |
| 102 | // | 101 | // cases.addBuildFile("test/link/macho/dylib/build.zig", .{ |
| 103 | // cases.addBuildFile("test/link/macho/bugs/13457/build.zig", .{ | 102 | // .build_modes = true, |
| 104 | // .build_modes = true, | 103 | // .requires_symlinks = true, |
| 105 | // .requires_symlinks = true, | 104 | // }); |
| 106 | // }); | 105 | // |
| 107 | // | 106 | // cases.addBuildFile("test/link/macho/empty/build.zig", .{ |
| 108 | // cases.addBuildFile("test/link/macho/dead_strip/build.zig", .{ | 107 | // .build_modes = true, |
| 109 | // .build_modes = false, | 108 | // .requires_symlinks = true, |
| 110 | // .requires_symlinks = true, | 109 | // }); |
| 111 | // }); | 110 | // |
| 112 | // | 111 | // cases.addBuildFile("test/link/macho/entry/build.zig", .{ |
| 113 | // cases.addBuildFile("test/link/macho/dead_strip_dylibs/build.zig", .{ | 112 | // .build_modes = true, |
| 114 | // .build_modes = true, | 113 | // .requires_symlinks = true, |
| 115 | // .requires_macos_sdk = true, | 114 | // }); |
| 116 | // .requires_symlinks = true, | 115 | // |
| 117 | // }); | 116 | // cases.addBuildFile("test/link/macho/headerpad/build.zig", .{ |
| 118 | // | 117 | // .build_modes = true, |
| 119 | // cases.addBuildFile("test/link/macho/dylib/build.zig", .{ | 118 | // .requires_macos_sdk = true, |
| 120 | // .build_modes = true, | 119 | // .requires_symlinks = true, |
| 121 | // .requires_symlinks = true, | 120 | // }); |
| 122 | // }); | 121 | // |
| 123 | // | 122 | // cases.addBuildFile("test/link/macho/linksection/build.zig", .{ |
| 124 | // cases.addBuildFile("test/link/macho/empty/build.zig", .{ | 123 | // .build_modes = true, |
| 125 | // .build_modes = true, | 124 | // .requires_symlinks = true, |
| 126 | // .requires_symlinks = true, | 125 | // }); |
| 127 | // }); | 126 | // |
| 128 | // | 127 | // cases.addBuildFile("test/link/macho/needed_framework/build.zig", .{ |
| 129 | // cases.addBuildFile("test/link/macho/entry/build.zig", .{ | 128 | // .build_modes = true, |
| 130 | // .build_modes = true, | 129 | // .requires_macos_sdk = true, |
| 131 | // .requires_symlinks = true, | 130 | // .requires_symlinks = true, |
| 132 | // }); | 131 | // }); |
| 133 | // | 132 | // |
| 134 | // cases.addBuildFile("test/link/macho/headerpad/build.zig", .{ | 133 | // cases.addBuildFile("test/link/macho/needed_library/build.zig", .{ |
| 135 | // .build_modes = true, | 134 | // .build_modes = true, |
| 136 | // .requires_macos_sdk = true, | 135 | // .requires_symlinks = true, |
| 137 | // .requires_symlinks = true, | 136 | // }); |
| 138 | // }); | 137 | // |
| 139 | // | 138 | // cases.addBuildFile("test/link/macho/objc/build.zig", .{ |
| 140 | // cases.addBuildFile("test/link/macho/linksection/build.zig", .{ | 139 | // .build_modes = true, |
| 141 | // .build_modes = true, | 140 | // .requires_macos_sdk = true, |
| 142 | // .requires_symlinks = true, | 141 | // .requires_symlinks = true, |
| 143 | // }); | 142 | // }); |
| 144 | // | 143 | // |
| 145 | // cases.addBuildFile("test/link/macho/needed_framework/build.zig", .{ | 144 | // cases.addBuildFile("test/link/macho/objcpp/build.zig", .{ |
| 146 | // .build_modes = true, | 145 | // .build_modes = true, |
| 147 | // .requires_macos_sdk = true, | 146 | // .requires_macos_sdk = true, |
| 148 | // .requires_symlinks = true, | 147 | // .requires_symlinks = true, |
| 149 | // }); | 148 | // }); |
| 150 | // | 149 | // |
| 151 | // cases.addBuildFile("test/link/macho/needed_library/build.zig", .{ | 150 | // cases.addBuildFile("test/link/macho/pagezero/build.zig", .{ |
| 152 | // .build_modes = true, | 151 | // .build_modes = false, |
| 153 | // .requires_symlinks = true, | 152 | // .requires_symlinks = true, |
| 154 | // }); | 153 | // }); |
| 155 | // | 154 | // |
| 156 | // cases.addBuildFile("test/link/macho/objc/build.zig", .{ | 155 | // cases.addBuildFile("test/link/macho/search_strategy/build.zig", .{ |
| 157 | // .build_modes = true, | 156 | // .build_modes = true, |
| 158 | // .requires_macos_sdk = true, | 157 | // .requires_symlinks = true, |
| 159 | // .requires_symlinks = true, | 158 | // }); |
| 160 | // }); | 159 | // |
| 161 | // | 160 | // cases.addBuildFile("test/link/macho/stack_size/build.zig", .{ |
| 162 | // cases.addBuildFile("test/link/macho/objcpp/build.zig", .{ | 161 | // .build_modes = true, |
| 163 | // .build_modes = true, | 162 | // .requires_symlinks = true, |
| 164 | // .requires_macos_sdk = true, | 163 | // }); |
| 165 | // .requires_symlinks = true, | 164 | // |
| 166 | // }); | 165 | // cases.addBuildFile("test/link/macho/strict_validation/build.zig", .{ |
| 167 | // | 166 | // .build_modes = true, |
| 168 | // cases.addBuildFile("test/link/macho/pagezero/build.zig", .{ | 167 | // .requires_symlinks = true, |
| 169 | // .build_modes = false, | 168 | // }); |
| 170 | // .requires_symlinks = true, | 169 | // |
| 171 | // }); | 170 | // cases.addBuildFile("test/link/macho/tls/build.zig", .{ |
| 172 | // | 171 | // .build_modes = true, |
| 173 | // cases.addBuildFile("test/link/macho/search_strategy/build.zig", .{ | 172 | // .requires_symlinks = true, |
| 174 | // .build_modes = true, | 173 | // }); |
| 175 | // .requires_symlinks = true, | 174 | // |
| 176 | // }); | 175 | // cases.addBuildFile("test/link/macho/unwind_info/build.zig", .{ |
| 177 | // | 176 | // .build_modes = true, |
| 178 | // cases.addBuildFile("test/link/macho/stack_size/build.zig", .{ | 177 | // .requires_symlinks = true, |
| 179 | // .build_modes = true, | 178 | // }); |
| 180 | // .requires_symlinks = true, | 179 | // |
| 181 | // }); | 180 | // cases.addBuildFile("test/link/macho/uuid/build.zig", .{ |
| 182 | // | 181 | // .build_modes = false, |
| 183 | // cases.addBuildFile("test/link/macho/strict_validation/build.zig", .{ | 182 | // .requires_symlinks = true, |
| 184 | // .build_modes = true, | 183 | // }); |
| 185 | // .requires_symlinks = true, | 184 | // |
| 186 | // }); | 185 | // cases.addBuildFile("test/link/macho/weak_library/build.zig", .{ |
| 187 | // | 186 | // .build_modes = true, |
| 188 | // cases.addBuildFile("test/link/macho/tls/build.zig", .{ | 187 | // .requires_symlinks = true, |
| 189 | // .build_modes = true, | 188 | // }); |
| 190 | // .requires_symlinks = true, | 189 | // |
| 191 | // }); | 190 | // cases.addBuildFile("test/link/macho/weak_framework/build.zig", .{ |
| 192 | // | 191 | // .build_modes = true, |
| 193 | // cases.addBuildFile("test/link/macho/unwind_info/build.zig", .{ | 192 | // .requires_macos_sdk = true, |
| 194 | // .build_modes = true, | 193 | // .requires_symlinks = true, |
| 195 | // .requires_symlinks = true, | 194 | // }); |
| 196 | // }); | 195 | }; |
| 197 | // | ||
| 198 | // cases.addBuildFile("test/link/macho/uuid/build.zig", .{ | ||
| 199 | // .build_modes = false, | ||
| 200 | // .requires_symlinks = true, | ||
| 201 | // }); | ||
| 202 | // | ||
| 203 | // cases.addBuildFile("test/link/macho/weak_library/build.zig", .{ | ||
| 204 | // .build_modes = true, | ||
| 205 | // .requires_symlinks = true, | ||
| 206 | // }); | ||
| 207 | // | ||
| 208 | // cases.addBuildFile("test/link/macho/weak_framework/build.zig", .{ | ||
| 209 | // .build_modes = true, | ||
| 210 | // .requires_macos_sdk = true, | ||
| 211 | // .requires_symlinks = true, | ||
| 212 | // }); | ||
| 213 | //} | ||
| 214 | 196 | ||
| 215 | const std = @import("std"); | 197 | const std = @import("std"); |
| 216 | const builtin = @import("builtin"); | 198 | const builtin = @import("builtin"); |
test/link/wasm/archive/build.zig+12-3| ... | @@ -1,15 +1,24 @@ | ... | @@ -1,15 +1,24 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 7 | b.default_step = test_step; |
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 6 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 7 | // The code in question will pull-in compiler-rt, | 16 | // The code in question will pull-in compiler-rt, |
| 8 | // and therefore link with its archive file. | 17 | // and therefore link with its archive file. |
| 9 | const lib = b.addSharedLibrary(.{ | 18 | const lib = b.addSharedLibrary(.{ |
| 10 | .name = "main", | 19 | .name = "main", |
| 11 | .root_source_file = .{ .path = "main.zig" }, | 20 | .root_source_file = .{ .path = "main.zig" }, |
| 12 | .optimize = b.standardOptimizeOption(.{}), | 21 | .optimize = optimize, |
| 13 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 22 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 14 | }); | 23 | }); |
| 15 | lib.use_llvm = false; | 24 | lib.use_llvm = false; |
test/link/wasm/basic-features/build.zig+4-1| ... | @@ -1,11 +1,13 @@ | ... | @@ -1,11 +1,13 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | // Library with explicitly set cpu features | 6 | // Library with explicitly set cpu features |
| 5 | const lib = b.addSharedLibrary(.{ | 7 | const lib = b.addSharedLibrary(.{ |
| 6 | .name = "lib", | 8 | .name = "lib", |
| 7 | .root_source_file = .{ .path = "main.zig" }, | 9 | .root_source_file = .{ .path = "main.zig" }, |
| 8 | .optimize = b.standardOptimizeOption(.{}), | 10 | .optimize = .Debug, |
| 9 | .target = .{ | 11 | .target = .{ |
| 10 | .cpu_arch = .wasm32, | 12 | .cpu_arch = .wasm32, |
| 11 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, | 13 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, |
| ... | @@ -24,4 +26,5 @@ pub fn build(b: *std.Build) void { | ... | @@ -24,4 +26,5 @@ pub fn build(b: *std.Build) void { |
| 24 | 26 | ||
| 25 | const test_step = b.step("test", "Run linker test"); | 27 | const test_step = b.step("test", "Run linker test"); |
| 26 | test_step.dependOn(&check.step); | 28 | test_step.dependOn(&check.step); |
| 29 | b.default_step = test_step; | ||
| 27 | } | 30 | } |
test/link/wasm/bss/build.zig+5-2| ... | @@ -1,14 +1,16 @@ | ... | @@ -1,14 +1,16 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 6 | const test_step = b.step("test", "Test"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const lib = b.addSharedLibrary(.{ | 9 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 10 | .name = "lib", |
| 9 | .root_source_file = .{ .path = "lib.zig" }, | 11 | .root_source_file = .{ .path = "lib.zig" }, |
| 10 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 12 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 11 | .optimize = b.standardOptimizeOption(.{}), | 13 | .optimize = .Debug, |
| 12 | }); | 14 | }); |
| 13 | lib.use_llvm = false; | 15 | lib.use_llvm = false; |
| 14 | lib.use_lld = false; | 16 | lib.use_lld = false; |
| ... | @@ -36,5 +38,6 @@ pub fn build(b: *std.Build) void { | ... | @@ -36,5 +38,6 @@ pub fn build(b: *std.Build) void { |
| 36 | check_lib.checkNext("name .rodata"); | 38 | check_lib.checkNext("name .rodata"); |
| 37 | check_lib.checkNext("index 1"); // bss section always last | 39 | check_lib.checkNext("index 1"); // bss section always last |
| 38 | check_lib.checkNext("name .bss"); | 40 | check_lib.checkNext("name .bss"); |
| 41 | |||
| 39 | test_step.dependOn(&check_lib.step); | 42 | test_step.dependOn(&check_lib.step); |
| 40 | } | 43 | } |
test/link/wasm/export-data/build.zig+6-1| ... | @@ -2,7 +2,12 @@ const std = @import("std"); | ... | @@ -2,7 +2,12 @@ const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn build(b: *std.Build) void { | 3 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 4 | const test_step = b.step("test", "Test"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 5 | b.default_step = test_step; |
| 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 | } | ||
| 6 | 11 | ||
| 7 | const lib = b.addSharedLibrary(.{ | 12 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 13 | .name = "lib", |
test/link/wasm/export/build.zig+11-2| ... | @@ -1,8 +1,18 @@ | ... | @@ -1,8 +1,18 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 7 | b.default_step = test_step; | ||
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 5 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 6 | const no_export = b.addSharedLibrary(.{ | 16 | const no_export = b.addSharedLibrary(.{ |
| 7 | .name = "no-export", | 17 | .name = "no-export", |
| 8 | .root_source_file = .{ .path = "main.zig" }, | 18 | .root_source_file = .{ .path = "main.zig" }, |
| ... | @@ -50,7 +60,6 @@ pub fn build(b: *std.Build) void { | ... | @@ -50,7 +60,6 @@ pub fn build(b: *std.Build) void { |
| 50 | check_force_export.checkNext("name foo"); | 60 | check_force_export.checkNext("name foo"); |
| 51 | check_force_export.checkNext("kind function"); | 61 | check_force_export.checkNext("kind function"); |
| 52 | 62 | ||
| 53 | const test_step = b.step("test", "Run linker test"); | ||
| 54 | test_step.dependOn(&check_no_export.step); | 63 | test_step.dependOn(&check_no_export.step); |
| 55 | test_step.dependOn(&check_dynamic_export.step); | 64 | test_step.dependOn(&check_dynamic_export.step); |
| 56 | test_step.dependOn(&check_force_export.step); | 65 | test_step.dependOn(&check_force_export.step); |
test/link/wasm/extern-mangle/build.zig+10-4| ... | @@ -1,18 +1,24 @@ | ... | @@ -1,18 +1,24 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn build(b: *std.Build) void { | 3 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 4 | const test_step = b.step("test", "Test it"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 5 | b.default_step = test_step; |
| 6 | 6 | ||
| 7 | add(b, test_step, .Debug); | ||
| 8 | add(b, test_step, .ReleaseFast); | ||
| 9 | add(b, test_step, .ReleaseSmall); | ||
| 10 | add(b, test_step, .ReleaseSafe); | ||
| 11 | } | ||
| 12 | |||
| 13 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 7 | const lib = b.addSharedLibrary(.{ | 14 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 15 | .name = "lib", |
| 9 | .root_source_file = .{ .path = "lib.zig" }, | 16 | .root_source_file = .{ .path = "lib.zig" }, |
| 10 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 17 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 11 | .optimize = b.standardOptimizeOption(.{}), | 18 | .optimize = optimize, |
| 12 | }); | 19 | }); |
| 13 | lib.import_symbols = true; // import `a` and `b` | 20 | lib.import_symbols = true; // import `a` and `b` |
| 14 | lib.rdynamic = true; // export `foo` | 21 | lib.rdynamic = true; // export `foo` |
| 15 | lib.install(); | ||
| 16 | 22 | ||
| 17 | const check_lib = lib.checkObject(.wasm); | 23 | const check_lib = lib.checkObject(.wasm); |
| 18 | check_lib.checkStart("Section import"); | 24 | check_lib.checkStart("Section import"); |
test/link/wasm/extern/build.zig+13-2| ... | @@ -1,10 +1,22 @@ | ... | @@ -1,10 +1,22 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 6 | const test_step = b.step("test", "Test it"); | ||
| 7 | b.default_step = test_step; | ||
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 4 | const exe = b.addExecutable(.{ | 16 | const exe = b.addExecutable(.{ |
| 5 | .name = "extern", | 17 | .name = "extern", |
| 6 | .root_source_file = .{ .path = "main.zig" }, | 18 | .root_source_file = .{ .path = "main.zig" }, |
| 7 | .optimize = b.standardOptimizeOption(.{}), | 19 | .optimize = optimize, |
| 8 | .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, | 20 | .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, |
| 9 | }); | 21 | }); |
| 10 | exe.addCSourceFile("foo.c", &.{}); | 22 | exe.addCSourceFile("foo.c", &.{}); |
| ... | @@ -15,6 +27,5 @@ pub fn build(b: *std.Build) void { | ... | @@ -15,6 +27,5 @@ pub fn build(b: *std.Build) void { |
| 15 | run.skip_foreign_checks = true; | 27 | run.skip_foreign_checks = true; |
| 16 | run.expectStdOutEqual("Result: 30"); | 28 | run.expectStdOutEqual("Result: 30"); |
| 17 | 29 | ||
| 18 | const test_step = b.step("test", "Run linker test"); | ||
| 19 | test_step.dependOn(&run.step); | 30 | test_step.dependOn(&run.step); |
| 20 | } | 31 | } |
test/link/wasm/function-table/build.zig+13-6| ... | @@ -1,13 +1,20 @@ | ... | @@ -1,13 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 7 | b.default_step = test_step; | ||
| 5 | 8 | ||
| 6 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 7 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 8 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 9 | const import_table = b.addSharedLibrary(.{ | 16 | const import_table = b.addSharedLibrary(.{ |
| 10 | .name = "lib", | 17 | .name = "import_table", |
| 11 | .root_source_file = .{ .path = "lib.zig" }, | 18 | .root_source_file = .{ .path = "lib.zig" }, |
| 12 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 19 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 13 | .optimize = optimize, | 20 | .optimize = optimize, |
| ... | @@ -17,7 +24,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -17,7 +24,7 @@ pub fn build(b: *std.Build) void { |
| 17 | import_table.import_table = true; | 24 | import_table.import_table = true; |
| 18 | 25 | ||
| 19 | const export_table = b.addSharedLibrary(.{ | 26 | const export_table = b.addSharedLibrary(.{ |
| 20 | .name = "lib", | 27 | .name = "export_table", |
| 21 | .root_source_file = .{ .path = "lib.zig" }, | 28 | .root_source_file = .{ .path = "lib.zig" }, |
| 22 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 29 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 23 | .optimize = optimize, | 30 | .optimize = optimize, |
| ... | @@ -27,7 +34,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -27,7 +34,7 @@ pub fn build(b: *std.Build) void { |
| 27 | export_table.export_table = true; | 34 | export_table.export_table = true; |
| 28 | 35 | ||
| 29 | const regular_table = b.addSharedLibrary(.{ | 36 | const regular_table = b.addSharedLibrary(.{ |
| 30 | .name = "lib", | 37 | .name = "regular_table", |
| 31 | .root_source_file = .{ .path = "lib.zig" }, | 38 | .root_source_file = .{ .path = "lib.zig" }, |
| 32 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 39 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 33 | .optimize = optimize, | 40 | .optimize = optimize, |
test/link/wasm/infer-features/build.zig+5-4| ... | @@ -1,12 +1,12 @@ | ... | @@ -1,12 +1,12 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn build(b: *std.Build) void { | 3 | pub const requires_stage2 = true; |
| 4 | const optimize = b.standardOptimizeOption(.{}); | ||
| 5 | 4 | ||
| 5 | pub fn build(b: *std.Build) void { | ||
| 6 | // Wasm Object file which we will use to infer the features from | 6 | // Wasm Object file which we will use to infer the features from |
| 7 | const c_obj = b.addObject(.{ | 7 | const c_obj = b.addObject(.{ |
| 8 | .name = "c_obj", | 8 | .name = "c_obj", |
| 9 | .optimize = optimize, | 9 | .optimize = .Debug, |
| 10 | .target = .{ | 10 | .target = .{ |
| 11 | .cpu_arch = .wasm32, | 11 | .cpu_arch = .wasm32, |
| 12 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.bleeding_edge }, | 12 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.bleeding_edge }, |
| ... | @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { |
| 20 | const lib = b.addSharedLibrary(.{ | 20 | const lib = b.addSharedLibrary(.{ |
| 21 | .name = "lib", | 21 | .name = "lib", |
| 22 | .root_source_file = .{ .path = "main.zig" }, | 22 | .root_source_file = .{ .path = "main.zig" }, |
| 23 | .optimize = optimize, | 23 | .optimize = .Debug, |
| 24 | .target = .{ | 24 | .target = .{ |
| 25 | .cpu_arch = .wasm32, | 25 | .cpu_arch = .wasm32, |
| 26 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, | 26 | .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, |
| ... | @@ -45,4 +45,5 @@ pub fn build(b: *std.Build) void { | ... | @@ -45,4 +45,5 @@ pub fn build(b: *std.Build) void { |
| 45 | 45 | ||
| 46 | const test_step = b.step("test", "Run linker test"); | 46 | const test_step = b.step("test", "Run linker test"); |
| 47 | test_step.dependOn(&check.step); | 47 | test_step.dependOn(&check.step); |
| 48 | b.default_step = test_step; | ||
| 48 | } | 49 | } |
test/link/wasm/producers/build.zig+13-6| ... | @@ -1,24 +1,31 @@ | ... | @@ -1,24 +1,31 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub const requires_stage2 = true; | ||
| 5 | |||
| 4 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 5 | const test_step = b.step("test", "Test"); | 7 | const test_step = b.step("test", "Test it"); |
| 6 | test_step.dependOn(b.getInstallStep()); | 8 | b.default_step = test_step; |
| 9 | |||
| 10 | add(b, test_step, .Debug); | ||
| 11 | add(b, test_step, .ReleaseFast); | ||
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 7 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 8 | const lib = b.addSharedLibrary(.{ | 17 | const lib = b.addSharedLibrary(.{ |
| 9 | .name = "lib", | 18 | .name = "lib", |
| 10 | .root_source_file = .{ .path = "lib.zig" }, | 19 | .root_source_file = .{ .path = "lib.zig" }, |
| 11 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 20 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 12 | .optimize = b.standardOptimizeOption(.{}), | 21 | .optimize = optimize, |
| 13 | }); | 22 | }); |
| 14 | lib.use_llvm = false; | 23 | lib.use_llvm = false; |
| 15 | lib.use_lld = false; | 24 | lib.use_lld = false; |
| 16 | lib.strip = false; | 25 | lib.strip = false; |
| 17 | lib.install(); | 26 | lib.install(); |
| 18 | 27 | ||
| 19 | const zig_version = builtin.zig_version; | 28 | const version_fmt = "version " ++ builtin.zig_version_string; |
| 20 | var version_buf: [100]u8 = undefined; | ||
| 21 | const version_fmt = std.fmt.bufPrint(&version_buf, "version {}", .{zig_version}) catch unreachable; | ||
| 22 | 29 | ||
| 23 | const check_lib = lib.checkObject(.wasm); | 30 | const check_lib = lib.checkObject(.wasm); |
| 24 | check_lib.checkStart("name producers"); | 31 | check_lib.checkStart("name producers"); |
test/link/wasm/segments/build.zig+12-3| ... | @@ -1,14 +1,23 @@ | ... | @@ -1,14 +1,23 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 7 | b.default_step = test_step; |
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 6 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 7 | const lib = b.addSharedLibrary(.{ | 16 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 17 | .name = "lib", |
| 9 | .root_source_file = .{ .path = "lib.zig" }, | 18 | .root_source_file = .{ .path = "lib.zig" }, |
| 10 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 19 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 11 | .optimize = b.standardOptimizeOption(.{}), | 20 | .optimize = optimize, |
| 12 | }); | 21 | }); |
| 13 | lib.use_llvm = false; | 22 | lib.use_llvm = false; |
| 14 | lib.use_lld = false; | 23 | lib.use_lld = false; |
test/link/wasm/stack_pointer/build.zig+12-3| ... | @@ -1,14 +1,23 @@ | ... | @@ -1,14 +1,23 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 7 | b.default_step = test_step; |
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 6 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 7 | const lib = b.addSharedLibrary(.{ | 16 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 17 | .name = "lib", |
| 9 | .root_source_file = .{ .path = "lib.zig" }, | 18 | .root_source_file = .{ .path = "lib.zig" }, |
| 10 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 19 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 11 | .optimize = b.standardOptimizeOption(.{}), | 20 | .optimize = optimize, |
| 12 | }); | 21 | }); |
| 13 | lib.use_llvm = false; | 22 | lib.use_llvm = false; |
| 14 | lib.use_lld = false; | 23 | lib.use_lld = false; |
test/link/wasm/type/build.zig+12-3| ... | @@ -1,14 +1,23 @@ | ... | @@ -1,14 +1,23 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_stage2 = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | test_step.dependOn(b.getInstallStep()); | 7 | b.default_step = test_step; |
| 8 | |||
| 9 | add(b, test_step, .Debug); | ||
| 10 | add(b, test_step, .ReleaseFast); | ||
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 6 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 7 | const lib = b.addSharedLibrary(.{ | 16 | const lib = b.addSharedLibrary(.{ |
| 8 | .name = "lib", | 17 | .name = "lib", |
| 9 | .root_source_file = .{ .path = "lib.zig" }, | 18 | .root_source_file = .{ .path = "lib.zig" }, |
| 10 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, | 19 | .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding }, |
| 11 | .optimize = b.standardOptimizeOption(.{}), | 20 | .optimize = optimize, |
| 12 | }); | 21 | }); |
| 13 | lib.use_llvm = false; | 22 | lib.use_llvm = false; |
| 14 | lib.use_lld = false; | 23 | lib.use_lld = false; |
test/tests.zig+10-7| ... | @@ -599,18 +599,21 @@ pub fn addLinkTests( | ... | @@ -599,18 +599,21 @@ pub fn addLinkTests( |
| 599 | _ = test_filter; | 599 | _ = test_filter; |
| 600 | _ = optimize_modes; | 600 | _ = optimize_modes; |
| 601 | _ = enable_macos_sdk; | 601 | _ = enable_macos_sdk; |
| 602 | _ = omit_stage2; | ||
| 603 | _ = enable_symlinks_windows; | 602 | _ = enable_symlinks_windows; |
| 604 | 603 | ||
| 605 | const step = b.step("test-link", "Run the linker tests"); | 604 | const step = b.step("test-link", "Run the linker tests"); |
| 606 | 605 | ||
| 607 | inline for (link.cases) |link_test| { | 606 | inline for (link.cases) |link_test| { |
| 608 | const dep = b.anonymousDependency(link_test.build_root, link_test.import, .{}); | 607 | const requires_stage2 = @hasDecl(link_test.import, "requires_stage2") and |
| 609 | const dep_step = dep.builder.default_step; | 608 | link_test.import.requires_stage2; |
| 610 | assert(mem.startsWith(u8, dep.builder.dep_prefix, "test.")); | 609 | if (!requires_stage2 or !omit_stage2) { |
| 611 | const dep_prefix_adjusted = dep.builder.dep_prefix["test.".len..]; | 610 | const dep = b.anonymousDependency(link_test.build_root, link_test.import, .{}); |
| 612 | dep_step.name = b.fmt("{s}{s}", .{ dep_prefix_adjusted, dep_step.name }); | 611 | const dep_step = dep.builder.default_step; |
| 613 | step.dependOn(dep_step); | 612 | assert(mem.startsWith(u8, dep.builder.dep_prefix, "test.")); |
| 613 | const dep_prefix_adjusted = dep.builder.dep_prefix["test.".len..]; | ||
| 614 | dep_step.name = b.fmt("{s}{s}", .{ dep_prefix_adjusted, dep_step.name }); | ||
| 615 | step.dependOn(dep_step); | ||
| 616 | } | ||
| 614 | } | 617 | } |
| 615 | 618 | ||
| 616 | return step; | 619 | return step; |