| author | |
| committer | |
| log | a7417f783953c0f39e929a690926336e5c495f30 |
| tree | 12371ecb25276bad48a80eef9f36e45dc32ed777 |
| parent | 6b4d4c70fd8b8696eb1220438b89f769a3c3a908 |
| signature |
4 files changed, 78 insertions(+), 1 deletions(-)
build.zig+14-1| ... | @@ -484,7 +484,20 @@ pub fn build(b: *Builder) !void { | ... | @@ -484,7 +484,20 @@ pub fn build(b: *Builder) !void { |
| 484 | )); | 484 | )); |
| 485 | 485 | ||
| 486 | toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); | 486 | toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); |
| 487 | toolchain_step.dependOn(tests.addStandaloneTests(b, test_filter, modes, skip_non_native, enable_macos_sdk, target, omit_stage2)); | 487 | toolchain_step.dependOn(tests.addStandaloneTests( |
| 488 | b, | ||
| 489 | test_filter, | ||
| 490 | modes, | ||
| 491 | skip_non_native, | ||
| 492 | enable_macos_sdk, | ||
| 493 | target, | ||
| 494 | omit_stage2, | ||
| 495 | b.enable_darling, | ||
| 496 | b.enable_qemu, | ||
| 497 | b.enable_rosetta, | ||
| 498 | b.enable_wasmtime, | ||
| 499 | b.enable_wine, | ||
| 500 | )); | ||
| 488 | toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2)); | 501 | toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2)); |
| 489 | toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); | 502 | toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); |
| 490 | toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes)); | 503 | toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes)); |
test/stage1/c_abi/build_wasm.zig created+24| ... | @@ -0,0 +1,24 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const Builder = std.build.Builder; | ||
| 3 | |||
| 4 | pub fn build(b: *Builder) void { | ||
| 5 | const rel_opts = b.standardReleaseOptions(); | ||
| 6 | const target: std.zig.CrossTarget = .{ .cpu_arch = .wasm32, .os_tag = .wasi }; | ||
| 7 | b.use_stage1 = false; | ||
| 8 | |||
| 9 | const c_obj = b.addObject("cfuncs", null); | ||
| 10 | c_obj.addCSourceFile("cfuncs.c", &[_][]const u8{"-std=c99"}); | ||
| 11 | c_obj.setBuildMode(rel_opts); | ||
| 12 | c_obj.linkSystemLibrary("c"); | ||
| 13 | c_obj.setTarget(target); | ||
| 14 | |||
| 15 | const main = b.addTest("main.zig"); | ||
| 16 | main.setBuildMode(rel_opts); | ||
| 17 | main.addObject(c_obj); | ||
| 18 | main.setTarget(target); | ||
| 19 | |||
| 20 | const test_step = b.step("test", "Test the program"); | ||
| 21 | test_step.dependOn(&main.step); | ||
| 22 | |||
| 23 | b.default_step.dependOn(test_step); | ||
| 24 | } | ||
test/standalone.zig+6| ... | @@ -41,6 +41,12 @@ pub fn addCases(cases: *tests.StandaloneContext) void { | ... | @@ -41,6 +41,12 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 41 | if (builtin.cpu.arch == .x86_64) { | 41 | if (builtin.cpu.arch == .x86_64) { |
| 42 | cases.addBuildFile("test/stage1/c_abi/build.zig", .{}); | 42 | cases.addBuildFile("test/stage1/c_abi/build.zig", .{}); |
| 43 | } | 43 | } |
| 44 | // C ABI tests only pass for the Wasm target when using stage2 | ||
| 45 | cases.addBuildFile("test/stage1/c_abi/build_wasm.zig", .{ | ||
| 46 | .requires_stage2 = true, | ||
| 47 | .use_emulation = true, | ||
| 48 | }); | ||
| 49 | |||
| 44 | cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ | 50 | cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ |
| 45 | .build_modes = true, | 51 | .build_modes = true, |
| 46 | .cross_targets = true, | 52 | .cross_targets = true, |
test/tests.zig+34| ... | @@ -463,6 +463,11 @@ pub fn addStandaloneTests( | ... | @@ -463,6 +463,11 @@ pub fn addStandaloneTests( |
| 463 | enable_macos_sdk: bool, | 463 | enable_macos_sdk: bool, |
| 464 | target: std.zig.CrossTarget, | 464 | target: std.zig.CrossTarget, |
| 465 | omit_stage2: bool, | 465 | omit_stage2: bool, |
| 466 | enable_darling: bool, | ||
| 467 | enable_qemu: bool, | ||
| 468 | enable_rosetta: bool, | ||
| 469 | enable_wasmtime: bool, | ||
| 470 | enable_wine: bool, | ||
| 466 | ) *build.Step { | 471 | ) *build.Step { |
| 467 | const cases = b.allocator.create(StandaloneContext) catch unreachable; | 472 | const cases = b.allocator.create(StandaloneContext) catch unreachable; |
| 468 | cases.* = StandaloneContext{ | 473 | cases.* = StandaloneContext{ |
| ... | @@ -475,6 +480,11 @@ pub fn addStandaloneTests( | ... | @@ -475,6 +480,11 @@ pub fn addStandaloneTests( |
| 475 | .enable_macos_sdk = enable_macos_sdk, | 480 | .enable_macos_sdk = enable_macos_sdk, |
| 476 | .target = target, | 481 | .target = target, |
| 477 | .omit_stage2 = omit_stage2, | 482 | .omit_stage2 = omit_stage2, |
| 483 | .enable_darling = enable_darling, | ||
| 484 | .enable_qemu = enable_qemu, | ||
| 485 | .enable_rosetta = enable_rosetta, | ||
| 486 | .enable_wasmtime = enable_wasmtime, | ||
| 487 | .enable_wine = enable_wine, | ||
| 478 | }; | 488 | }; |
| 479 | 489 | ||
| 480 | standalone.addCases(cases); | 490 | standalone.addCases(cases); |
| ... | @@ -962,6 +972,11 @@ pub const StandaloneContext = struct { | ... | @@ -962,6 +972,11 @@ pub const StandaloneContext = struct { |
| 962 | enable_macos_sdk: bool, | 972 | enable_macos_sdk: bool, |
| 963 | target: std.zig.CrossTarget, | 973 | target: std.zig.CrossTarget, |
| 964 | omit_stage2: bool, | 974 | omit_stage2: bool, |
| 975 | enable_darling: bool = false, | ||
| 976 | enable_qemu: bool = false, | ||
| 977 | enable_rosetta: bool = false, | ||
| 978 | enable_wasmtime: bool = false, | ||
| 979 | enable_wine: bool = false, | ||
| 965 | 980 | ||
| 966 | pub fn addC(self: *StandaloneContext, root_src: []const u8) void { | 981 | pub fn addC(self: *StandaloneContext, root_src: []const u8) void { |
| 967 | self.addAllArgs(root_src, true); | 982 | self.addAllArgs(root_src, true); |
| ... | @@ -976,6 +991,7 @@ pub const StandaloneContext = struct { | ... | @@ -976,6 +991,7 @@ pub const StandaloneContext = struct { |
| 976 | cross_targets: bool = false, | 991 | cross_targets: bool = false, |
| 977 | requires_macos_sdk: bool = false, | 992 | requires_macos_sdk: bool = false, |
| 978 | requires_stage2: bool = false, | 993 | requires_stage2: bool = false, |
| 994 | use_emulation: bool = false, | ||
| 979 | }) void { | 995 | }) void { |
| 980 | const b = self.b; | 996 | const b = self.b; |
| 981 | 997 | ||
| ... | @@ -1007,6 +1023,24 @@ pub const StandaloneContext = struct { | ... | @@ -1007,6 +1023,24 @@ pub const StandaloneContext = struct { |
| 1007 | zig_args.append(target_arg) catch unreachable; | 1023 | zig_args.append(target_arg) catch unreachable; |
| 1008 | } | 1024 | } |
| 1009 | 1025 | ||
| 1026 | if (features.use_emulation) { | ||
| 1027 | if (self.enable_darling) { | ||
| 1028 | zig_args.append("-fdarling") catch unreachable; | ||
| 1029 | } | ||
| 1030 | if (self.enable_qemu) { | ||
| 1031 | zig_args.append("-fqemu") catch unreachable; | ||
| 1032 | } | ||
| 1033 | if (self.enable_rosetta) { | ||
| 1034 | zig_args.append("-frosetta") catch unreachable; | ||
| 1035 | } | ||
| 1036 | if (self.enable_wasmtime) { | ||
| 1037 | zig_args.append("-fwasmtime") catch unreachable; | ||
| 1038 | } | ||
| 1039 | if (self.enable_wine) { | ||
| 1040 | zig_args.append("-fwine") catch unreachable; | ||
| 1041 | } | ||
| 1042 | } | ||
| 1043 | |||
| 1010 | const modes = if (features.build_modes) self.modes else &[1]Mode{.Debug}; | 1044 | const modes = if (features.build_modes) self.modes else &[1]Mode{.Debug}; |
| 1011 | for (modes) |mode| { | 1045 | for (modes) |mode| { |
| 1012 | const arg = switch (mode) { | 1046 | const arg = switch (mode) { |