| author | |
| committer | |
| log | 97df4ae3ce34ae2f1ac8298a99faaf990e22ca75 |
| tree | bc87b057fadd0056e22bb930cd214318ddc77112 |
| parent | de489031d873193ca94de1292828c00a02e3b3ea |
| parent | c26c5a3c1b9dc55e157374cc5fab11fe28d53ecf |
| signature |
Miscellaneous LoongArch work to prepare for CI28 files changed, 339 insertions(+), 46 deletions(-)
build.zig+1| ... | @@ -576,6 +576,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -576,6 +576,7 @@ pub fn build(b: *std.Build) !void { |
| 576 | enable_macos_sdk, | 576 | enable_macos_sdk, |
| 577 | enable_ios_sdk, | 577 | enable_ios_sdk, |
| 578 | enable_symlinks_windows, | 578 | enable_symlinks_windows, |
| 579 | skip_translate_c, | ||
| 579 | )); | 580 | )); |
| 580 | test_step.dependOn(tests.addCAbiTests(b, .{ | 581 | test_step.dependOn(tests.addCAbiTests(b, .{ |
| 581 | .test_target_filters = test_target_filters, | 582 | .test_target_filters = test_target_filters, |
ci/loongarch64-linux-debug.sh created+71| ... | @@ -0,0 +1,71 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Requires cmake ninja-build | ||
| 4 | |||
| 5 | set -x | ||
| 6 | set -e | ||
| 7 | |||
| 8 | ARCH="$(uname -m)" | ||
| 9 | TARGET="$ARCH-linux-musl" | ||
| 10 | MCPU="baseline" | ||
| 11 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.157+7fdd60df1" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | # Make the `zig version` number consistent. | ||
| 16 | # This will affect the cmake command below. | ||
| 17 | git fetch --unshallow || true | ||
| 18 | git fetch --tags | ||
| 19 | |||
| 20 | # Override the cache directories because they won't actually help other CI runs | ||
| 21 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 22 | # fill up space on the hard drive for no reason. | ||
| 23 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 24 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 25 | |||
| 26 | mkdir build-debug | ||
| 27 | cd build-debug | ||
| 28 | |||
| 29 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 30 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 31 | |||
| 32 | cmake .. \ | ||
| 33 | -DCMAKE_INSTALL_PREFIX="stage3-debug" \ | ||
| 34 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 35 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 36 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 37 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 38 | -DZIG_STATIC=ON \ | ||
| 39 | -DZIG_NO_LIB=ON \ | ||
| 40 | -GNinja \ | ||
| 41 | -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ | ||
| 42 | -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE | ||
| 43 | # https://github.com/ziglang/zig/issues/22213 | ||
| 44 | |||
| 45 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 46 | # so that installation and testing do not get affected by them. | ||
| 47 | unset CC | ||
| 48 | unset CXX | ||
| 49 | |||
| 50 | ninja install | ||
| 51 | |||
| 52 | # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. | ||
| 53 | stage3-debug/bin/zig build test \ | ||
| 54 | --maxrss 60129542144 \ | ||
| 55 | -Dstatic-llvm \ | ||
| 56 | -Dskip-non-native \ | ||
| 57 | -Dtarget=native-native-musl \ | ||
| 58 | --search-prefix "$PREFIX" \ | ||
| 59 | --zig-lib-dir "$PWD/../lib" \ | ||
| 60 | -Dno-langref \ | ||
| 61 | -Dskip-translate-c | ||
| 62 | |||
| 63 | stage3-debug/bin/zig build \ | ||
| 64 | --prefix stage4-debug \ | ||
| 65 | -Denable-llvm \ | ||
| 66 | -Dno-lib \ | ||
| 67 | -Dtarget=$TARGET \ | ||
| 68 | -Duse-zig-libcxx \ | ||
| 69 | -Dversion-string="$(stage3-debug/bin/zig version)" | ||
| 70 | |||
| 71 | stage4-debug/bin/zig test ../test/behavior.zig | ||
ci/loongarch64-linux-release.sh created+77| ... | @@ -0,0 +1,77 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Requires cmake ninja-build | ||
| 4 | |||
| 5 | set -x | ||
| 6 | set -e | ||
| 7 | |||
| 8 | ARCH="$(uname -m)" | ||
| 9 | TARGET="$ARCH-linux-musl" | ||
| 10 | MCPU="baseline" | ||
| 11 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.157+7fdd60df1" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | # Make the `zig version` number consistent. | ||
| 16 | # This will affect the cmake command below. | ||
| 17 | git fetch --unshallow || true | ||
| 18 | git fetch --tags | ||
| 19 | |||
| 20 | # Override the cache directories because they won't actually help other CI runs | ||
| 21 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 22 | # fill up space on the hard drive for no reason. | ||
| 23 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 24 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 25 | |||
| 26 | mkdir build-release | ||
| 27 | cd build-release | ||
| 28 | |||
| 29 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 30 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 31 | |||
| 32 | cmake .. \ | ||
| 33 | -DCMAKE_INSTALL_PREFIX="stage3-release" \ | ||
| 34 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 35 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 36 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 37 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 38 | -DZIG_STATIC=ON \ | ||
| 39 | -DZIG_NO_LIB=ON \ | ||
| 40 | -GNinja \ | ||
| 41 | -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ | ||
| 42 | -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE | ||
| 43 | # https://github.com/ziglang/zig/issues/22213 | ||
| 44 | |||
| 45 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 46 | # so that installation and testing do not get affected by them. | ||
| 47 | unset CC | ||
| 48 | unset CXX | ||
| 49 | |||
| 50 | ninja install | ||
| 51 | |||
| 52 | # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. | ||
| 53 | stage3-release/bin/zig build test \ | ||
| 54 | --maxrss 60129542144 \ | ||
| 55 | -Dstatic-llvm \ | ||
| 56 | -Dskip-non-native \ | ||
| 57 | -Dtarget=native-native-musl \ | ||
| 58 | --search-prefix "$PREFIX" \ | ||
| 59 | --zig-lib-dir "$PWD/../lib" \ | ||
| 60 | -Dno-langref \ | ||
| 61 | -Dskip-translate-c | ||
| 62 | |||
| 63 | # Ensure that stage3 and stage4 are byte-for-byte identical. | ||
| 64 | stage3-release/bin/zig build \ | ||
| 65 | --prefix stage4-release \ | ||
| 66 | -Denable-llvm \ | ||
| 67 | -Dno-lib \ | ||
| 68 | -Doptimize=ReleaseFast \ | ||
| 69 | -Dstrip \ | ||
| 70 | -Dtarget=$TARGET \ | ||
| 71 | -Duse-zig-libcxx \ | ||
| 72 | -Dversion-string="$(stage3-release/bin/zig version)" | ||
| 73 | |||
| 74 | # diff returns an error code if the files differ. | ||
| 75 | echo "If the following command fails, it means nondeterminism has been" | ||
| 76 | echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." | ||
| 77 | diff stage3-release/bin/zig stage4-release/bin/zig | ||
doc/langref/runtime_shrExact_overflow.zig+1-1| ... | @@ -7,7 +7,7 @@ pub fn main() void { | ... | @@ -7,7 +7,7 @@ pub fn main() void { |
| 7 | const y = @shrExact(x, 2); | 7 | const y = @shrExact(x, 2); |
| 8 | std.debug.print("value: {}\n", .{y}); | 8 | std.debug.print("value: {}\n", .{y}); |
| 9 | 9 | ||
| 10 | if (builtin.cpu.arch.isRISCV() and builtin.zig_backend == .stage2_llvm) @panic("https://github.com/ziglang/zig/issues/24304"); | 10 | if ((builtin.cpu.arch.isRISCV() or builtin.cpu.arch.isLoongArch()) and builtin.zig_backend == .stage2_llvm) @panic("https://github.com/ziglang/zig/issues/24304"); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | // exe=fail | 13 | // exe=fail |
lib/std/Target.zig+1-1| ... | @@ -1903,7 +1903,7 @@ pub const Cpu = struct { | ... | @@ -1903,7 +1903,7 @@ pub const Cpu = struct { |
| 1903 | .csky => &csky.cpu.ck810, // gcc/clang do not have a generic csky model. | 1903 | .csky => &csky.cpu.ck810, // gcc/clang do not have a generic csky model. |
| 1904 | .hexagon => &hexagon.cpu.hexagonv68, // gcc/clang do not have a generic hexagon model. | 1904 | .hexagon => &hexagon.cpu.hexagonv68, // gcc/clang do not have a generic hexagon model. |
| 1905 | .lanai => &lanai.cpu.v11, // clang does not have a generic lanai model. | 1905 | .lanai => &lanai.cpu.v11, // clang does not have a generic lanai model. |
| 1906 | .loongarch64 => &loongarch.cpu.loongarch64, | 1906 | .loongarch64 => &loongarch.cpu.la64v1_0, |
| 1907 | .m68k => &m68k.cpu.M68000, | 1907 | .m68k => &m68k.cpu.M68000, |
| 1908 | .mips, .mipsel => &mips.cpu.mips32r2, | 1908 | .mips, .mipsel => &mips.cpu.mips32r2, |
| 1909 | .mips64, .mips64el => &mips.cpu.mips64r2, | 1909 | .mips64, .mips64el => &mips.cpu.mips64r2, |
lib/std/Target/loongarch.zig+24-14| ... | @@ -159,11 +159,6 @@ pub const all_features = blk: { | ... | @@ -159,11 +159,6 @@ pub const all_features = blk: { |
| 159 | }; | 159 | }; |
| 160 | 160 | ||
| 161 | pub const cpu = struct { | 161 | pub const cpu = struct { |
| 162 | pub const generic: CpuModel = .{ | ||
| 163 | .name = "generic", | ||
| 164 | .llvm_name = "generic", | ||
| 165 | .features = featureSet(&[_]Feature{}), | ||
| 166 | }; | ||
| 167 | pub const generic_la32: CpuModel = .{ | 162 | pub const generic_la32: CpuModel = .{ |
| 168 | .name = "generic_la32", | 163 | .name = "generic_la32", |
| 169 | .llvm_name = "generic-la32", | 164 | .llvm_name = "generic-la32", |
| ... | @@ -191,6 +186,30 @@ pub const cpu = struct { | ... | @@ -191,6 +186,30 @@ pub const cpu = struct { |
| 191 | .ual, | 186 | .ual, |
| 192 | }), | 187 | }), |
| 193 | }; | 188 | }; |
| 189 | pub const la64v1_0: CpuModel = .{ | ||
| 190 | .name = "la64v1_0", | ||
| 191 | .llvm_name = null, | ||
| 192 | .features = featureSet(&[_]Feature{ | ||
| 193 | .@"64bit", | ||
| 194 | .lsx, | ||
| 195 | .ual, | ||
| 196 | }), | ||
| 197 | }; | ||
| 198 | pub const la64v1_1: CpuModel = .{ | ||
| 199 | .name = "la64v1_1", | ||
| 200 | .llvm_name = null, | ||
| 201 | .features = featureSet(&[_]Feature{ | ||
| 202 | .@"64bit", | ||
| 203 | .div32, | ||
| 204 | .frecipe, | ||
| 205 | .lam_bh, | ||
| 206 | .lamcas, | ||
| 207 | .ld_seq_sa, | ||
| 208 | .lsx, | ||
| 209 | .scq, | ||
| 210 | .ual, | ||
| 211 | }), | ||
| 212 | }; | ||
| 194 | pub const la664: CpuModel = .{ | 213 | pub const la664: CpuModel = .{ |
| 195 | .name = "la664", | 214 | .name = "la664", |
| 196 | .llvm_name = "la664", | 215 | .llvm_name = "la664", |
| ... | @@ -208,13 +227,4 @@ pub const cpu = struct { | ... | @@ -208,13 +227,4 @@ pub const cpu = struct { |
| 208 | .ual, | 227 | .ual, |
| 209 | }), | 228 | }), |
| 210 | }; | 229 | }; |
| 211 | pub const loongarch64: CpuModel = .{ | ||
| 212 | .name = "loongarch64", | ||
| 213 | .llvm_name = "loongarch64", | ||
| 214 | .features = featureSet(&[_]Feature{ | ||
| 215 | .@"64bit", | ||
| 216 | .d, | ||
| 217 | .ual, | ||
| 218 | }), | ||
| 219 | }; | ||
| 220 | }; | 230 | }; |
lib/std/crypto/ml_kem.zig+6| ... | @@ -1722,14 +1722,20 @@ test "Test happy flow" { | ... | @@ -1722,14 +1722,20 @@ test "Test happy flow" { |
| 1722 | // Code to test NIST Known Answer Tests (KAT), see PQCgenKAT.c. | 1722 | // Code to test NIST Known Answer Tests (KAT), see PQCgenKAT.c. |
| 1723 | 1723 | ||
| 1724 | test "NIST KAT test d00.Kyber512" { | 1724 | test "NIST KAT test d00.Kyber512" { |
| 1725 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; | ||
| 1726 | |||
| 1725 | try testNistKat(d00.Kyber512, "e9c2bd37133fcb40772f81559f14b1f58dccd1c816701be9ba6214d43baf4547"); | 1727 | try testNistKat(d00.Kyber512, "e9c2bd37133fcb40772f81559f14b1f58dccd1c816701be9ba6214d43baf4547"); |
| 1726 | } | 1728 | } |
| 1727 | 1729 | ||
| 1728 | test "NIST KAT test d00.Kyber1024" { | 1730 | test "NIST KAT test d00.Kyber1024" { |
| 1731 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; | ||
| 1732 | |||
| 1729 | try testNistKat(d00.Kyber1024, "89248f2f33f7f4f7051729111f3049c409a933ec904aedadf035f30fa5646cd5"); | 1733 | try testNistKat(d00.Kyber1024, "89248f2f33f7f4f7051729111f3049c409a933ec904aedadf035f30fa5646cd5"); |
| 1730 | } | 1734 | } |
| 1731 | 1735 | ||
| 1732 | test "NIST KAT test d00.Kyber768" { | 1736 | test "NIST KAT test d00.Kyber768" { |
| 1737 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; | ||
| 1738 | |||
| 1733 | try testNistKat(d00.Kyber768, "a1e122cad3c24bc51622e4c242d8b8acbcd3f618fee4220400605ca8f9ea02c2"); | 1739 | try testNistKat(d00.Kyber768, "a1e122cad3c24bc51622e4c242d8b8acbcd3f618fee4220400605ca8f9ea02c2"); |
| 1734 | } | 1740 | } |
| 1735 | 1741 |
lib/std/math/modf.zig+1| ... | @@ -87,6 +87,7 @@ fn ModfTests(comptime T: type) type { | ... | @@ -87,6 +87,7 @@ fn ModfTests(comptime T: type) type { |
| 87 | test "vector" { | 87 | test "vector" { |
| 88 | if (builtin.os.tag == .macos and builtin.cpu.arch == .aarch64) return error.SkipZigTest; | 88 | if (builtin.os.tag == .macos and builtin.cpu.arch == .aarch64) return error.SkipZigTest; |
| 89 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 89 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 90 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/159529 | ||
| 90 | 91 | ||
| 91 | const widths = [_]comptime_int{ 1, 2, 3, 4, 8, 16 }; | 92 | const widths = [_]comptime_int{ 1, 2, 3, 4, 8, 16 }; |
| 92 | 93 |
lib/std/mem.zig+2-1| ... | @@ -4534,7 +4534,8 @@ pub fn doNotOptimizeAway(val: anytype) void { | ... | @@ -4534,7 +4534,8 @@ pub fn doNotOptimizeAway(val: anytype) void { |
| 4534 | } else doNotOptimizeAway(&val); | 4534 | } else doNotOptimizeAway(&val); |
| 4535 | }, | 4535 | }, |
| 4536 | .float => { | 4536 | .float => { |
| 4537 | if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c) { | 4537 | // https://github.com/llvm/llvm-project/issues/159200 |
| 4538 | if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c and !builtin.cpu.arch.isLoongArch()) { | ||
| 4538 | asm volatile ("" | 4539 | asm volatile ("" |
| 4539 | : | 4540 | : |
| 4540 | : [_] "rm" (val), | 4541 | : [_] "rm" (val), |
lib/std/zig/system.zig+2-3| ... | @@ -468,9 +468,8 @@ fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, query: T | ... | @@ -468,9 +468,8 @@ fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, query: T |
| 468 | // although it is a runtime value, is guaranteed to be one of the architectures in the set | 468 | // although it is a runtime value, is guaranteed to be one of the architectures in the set |
| 469 | // of the respective switch prong. | 469 | // of the respective switch prong. |
| 470 | switch (builtin.cpu.arch) { | 470 | switch (builtin.cpu.arch) { |
| 471 | .x86_64, .x86 => { | 471 | .loongarch32, .loongarch64 => return @import("system/loongarch.zig").detectNativeCpuAndFeatures(cpu_arch, os, query), |
| 472 | return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, query); | 472 | .x86_64, .x86 => return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, query), |
| 473 | }, | ||
| 474 | else => {}, | 473 | else => {}, |
| 475 | } | 474 | } |
| 476 | 475 |
lib/std/zig/system/loongarch.zig created+48| ... | @@ -0,0 +1,48 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | pub fn detectNativeCpuAndFeatures( | ||
| 5 | arch: std.Target.Cpu.Arch, | ||
| 6 | os: std.Target.Os, | ||
| 7 | query: std.Target.Query, | ||
| 8 | ) ?std.Target.Cpu { | ||
| 9 | _ = os; | ||
| 10 | _ = query; | ||
| 11 | |||
| 12 | // Clearly this code could do better in the future by actually querying specific CPU features | ||
| 13 | // with the cpucfg instruction like on x86. But with the small number of well-known LoongArch | ||
| 14 | // models that exist at the moment, simply checking the PRID is plenty. | ||
| 15 | var cpu: std.Target.Cpu = .{ | ||
| 16 | .arch = arch, | ||
| 17 | .model = switch (cpucfg(0) & 0xf000) { | ||
| 18 | else => return null, | ||
| 19 | 0xc000 => &std.Target.loongarch.cpu.la464, | ||
| 20 | 0xd000 => &std.Target.loongarch.cpu.la664, | ||
| 21 | }, | ||
| 22 | .features = .empty, | ||
| 23 | }; | ||
| 24 | |||
| 25 | cpu.features.addFeatureSet(cpu.model.features); | ||
| 26 | cpu.features.populateDependencies(cpu.arch.allFeaturesList()); | ||
| 27 | |||
| 28 | return cpu; | ||
| 29 | } | ||
| 30 | |||
| 31 | /// This is a workaround for the C backend until zig has the ability to put | ||
| 32 | /// C code in inline assembly. | ||
| 33 | extern fn zig_loongarch_cpucfg(word: u32, result: *u32) callconv(.c) void; | ||
| 34 | |||
| 35 | fn cpucfg(word: u32) u32 { | ||
| 36 | var result: u32 = undefined; | ||
| 37 | |||
| 38 | if (builtin.zig_backend == .stage2_c) { | ||
| 39 | zig_loongarch_cpucfg(word, &result); | ||
| 40 | } else { | ||
| 41 | asm ("cpucfg %[result], %[word]" | ||
| 42 | : [result] "=r" (result), | ||
| 43 | : [word] "r" (word), | ||
| 44 | ); | ||
| 45 | } | ||
| 46 | |||
| 47 | return result; | ||
| 48 | } | ||
lib/zig.h+13-3| ... | @@ -4195,7 +4195,17 @@ static inline void* zig_x86_64_windows_teb(void) { | ... | @@ -4195,7 +4195,17 @@ static inline void* zig_x86_64_windows_teb(void) { |
| 4195 | 4195 | ||
| 4196 | #endif | 4196 | #endif |
| 4197 | 4197 | ||
| 4198 | #if defined(zig_x86) | 4198 | #if defined(zig_loongarch) |
| 4199 | |||
| 4200 | static inline void zig_loongarch_cpucfg(uint32_t word, uint32_t* result) { | ||
| 4201 | #if defined(zig_gnuc_asm) | ||
| 4202 | __asm__("cpucfg %[result], %[word]" : [result] "=r" (result) : [word] "r" (word)); | ||
| 4203 | #else | ||
| 4204 | *result = 0; | ||
| 4205 | #endif | ||
| 4206 | } | ||
| 4207 | |||
| 4208 | #elif defined(zig_x86) | ||
| 4199 | 4209 | ||
| 4200 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { | 4210 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { |
| 4201 | #if defined(zig_msvc) | 4211 | #if defined(zig_msvc) |
| ... | @@ -4206,7 +4216,7 @@ static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax | ... | @@ -4206,7 +4216,7 @@ static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax |
| 4206 | *ecx = (uint32_t)cpu_info[2]; | 4216 | *ecx = (uint32_t)cpu_info[2]; |
| 4207 | *edx = (uint32_t)cpu_info[3]; | 4217 | *edx = (uint32_t)cpu_info[3]; |
| 4208 | #elif defined(zig_gnuc_asm) | 4218 | #elif defined(zig_gnuc_asm) |
| 4209 | __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(leaf_id), "c"(subid)); | 4219 | __asm__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (leaf_id), "c" (subid)); |
| 4210 | #else | 4220 | #else |
| 4211 | *eax = 0; | 4221 | *eax = 0; |
| 4212 | *ebx = 0; | 4222 | *ebx = 0; |
| ... | @@ -4221,7 +4231,7 @@ static inline uint32_t zig_x86_get_xcr0(void) { | ... | @@ -4221,7 +4231,7 @@ static inline uint32_t zig_x86_get_xcr0(void) { |
| 4221 | #elif defined(zig_gnuc_asm) | 4231 | #elif defined(zig_gnuc_asm) |
| 4222 | uint32_t eax; | 4232 | uint32_t eax; |
| 4223 | uint32_t edx; | 4233 | uint32_t edx; |
| 4224 | __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0)); | 4234 | __asm__("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0)); |
| 4225 | return eax; | 4235 | return eax; |
| 4226 | #else | 4236 | #else |
| 4227 | *eax = 0; | 4237 | *eax = 0; |
stage1/zig.h+13-3| ... | @@ -4195,7 +4195,17 @@ static inline void* zig_x86_64_windows_teb(void) { | ... | @@ -4195,7 +4195,17 @@ static inline void* zig_x86_64_windows_teb(void) { |
| 4195 | 4195 | ||
| 4196 | #endif | 4196 | #endif |
| 4197 | 4197 | ||
| 4198 | #if defined(zig_x86) | 4198 | #if defined(zig_loongarch) |
| 4199 | |||
| 4200 | static inline void zig_loongarch_cpucfg(uint32_t word, uint32_t* result) { | ||
| 4201 | #if defined(zig_gnuc_asm) | ||
| 4202 | __asm__("cpucfg %[result], %[word]" : [result] "=r" (result) : [word] "r" (word)); | ||
| 4203 | #else | ||
| 4204 | *result = 0; | ||
| 4205 | #endif | ||
| 4206 | } | ||
| 4207 | |||
| 4208 | #elif defined(zig_x86) | ||
| 4199 | 4209 | ||
| 4200 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { | 4210 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { |
| 4201 | #if defined(zig_msvc) | 4211 | #if defined(zig_msvc) |
| ... | @@ -4206,7 +4216,7 @@ static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax | ... | @@ -4206,7 +4216,7 @@ static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax |
| 4206 | *ecx = (uint32_t)cpu_info[2]; | 4216 | *ecx = (uint32_t)cpu_info[2]; |
| 4207 | *edx = (uint32_t)cpu_info[3]; | 4217 | *edx = (uint32_t)cpu_info[3]; |
| 4208 | #elif defined(zig_gnuc_asm) | 4218 | #elif defined(zig_gnuc_asm) |
| 4209 | __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(leaf_id), "c"(subid)); | 4219 | __asm__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (leaf_id), "c" (subid)); |
| 4210 | #else | 4220 | #else |
| 4211 | *eax = 0; | 4221 | *eax = 0; |
| 4212 | *ebx = 0; | 4222 | *ebx = 0; |
| ... | @@ -4221,7 +4231,7 @@ static inline uint32_t zig_x86_get_xcr0(void) { | ... | @@ -4221,7 +4231,7 @@ static inline uint32_t zig_x86_get_xcr0(void) { |
| 4221 | #elif defined(zig_gnuc_asm) | 4231 | #elif defined(zig_gnuc_asm) |
| 4222 | uint32_t eax; | 4232 | uint32_t eax; |
| 4223 | uint32_t edx; | 4233 | uint32_t edx; |
| 4224 | __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0)); | 4234 | __asm__("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0)); |
| 4225 | return eax; | 4235 | return eax; |
| 4226 | #else | 4236 | #else |
| 4227 | *eax = 0; | 4237 | *eax = 0; |
stage1/zig1.wasm| Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ | |||
test/behavior/asm.zig+1| ... | @@ -67,6 +67,7 @@ test "alternative constraints" { | ... | @@ -67,6 +67,7 @@ test "alternative constraints" { |
| 67 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 67 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 68 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | 68 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 69 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | 69 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 70 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/159200 | ||
| 70 | 71 | ||
| 71 | if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly | 72 | if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly |
| 72 | 73 |
test/behavior/math.zig+4| ... | @@ -111,6 +111,8 @@ test "@clz vectors" { | ... | @@ -111,6 +111,8 @@ test "@clz vectors" { |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | fn testClzVectors() !void { | 113 | fn testClzVectors() !void { |
| 114 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/159529 | ||
| 115 | |||
| 114 | const Vu4 = @Vector(64, u4); | 116 | const Vu4 = @Vector(64, u4); |
| 115 | const Vu8 = @Vector(64, u8); | 117 | const Vu8 = @Vector(64, u8); |
| 116 | const Vu128 = @Vector(64, u128); | 118 | const Vu128 = @Vector(64, u128); |
| ... | @@ -197,6 +199,8 @@ test "@ctz vectors" { | ... | @@ -197,6 +199,8 @@ test "@ctz vectors" { |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | fn testCtzVectors() !void { | 201 | fn testCtzVectors() !void { |
| 202 | if (comptime builtin.cpu.has(.loongarch, .lsx)) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/159529 | ||
| 203 | |||
| 200 | const Vu4 = @Vector(64, u4); | 204 | const Vu4 = @Vector(64, u4); |
| 201 | const Vu8 = @Vector(64, u8); | 205 | const Vu8 = @Vector(64, u8); |
| 202 | @setEvalBranchQuota(10_000); | 206 | @setEvalBranchQuota(10_000); |
test/c_abi/main.zig+2| ... | @@ -1135,6 +1135,7 @@ extern fn c_ret_medium_vec() MediumVec; | ... | @@ -1135,6 +1135,7 @@ extern fn c_ret_medium_vec() MediumVec; |
| 1135 | test "medium simd vector" { | 1135 | test "medium simd vector" { |
| 1136 | if (builtin.zig_backend == .stage2_x86_64 and !comptime builtin.cpu.has(.x86, .avx)) return error.SkipZigTest; | 1136 | if (builtin.zig_backend == .stage2_x86_64 and !comptime builtin.cpu.has(.x86, .avx)) return error.SkipZigTest; |
| 1137 | if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest; | 1137 | if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest; |
| 1138 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; | ||
| 1138 | 1139 | ||
| 1139 | c_medium_vec(.{ 1, 2, 3, 4 }); | 1140 | c_medium_vec(.{ 1, 2, 3, 4 }); |
| 1140 | 1141 | ||
| ... | @@ -1155,6 +1156,7 @@ test "big simd vector" { | ... | @@ -1155,6 +1156,7 @@ test "big simd vector" { |
| 1155 | 1156 | ||
| 1156 | if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest; | 1157 | if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest; |
| 1157 | if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest; | 1158 | if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest; |
| 1159 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; | ||
| 1158 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest; | 1160 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest; |
| 1159 | 1161 | ||
| 1160 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); | 1162 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); |
test/src/StackTrace.zig+2| ... | @@ -15,6 +15,7 @@ const Config = struct { | ... | @@ -15,6 +15,7 @@ const Config = struct { |
| 15 | 15 | ||
| 16 | const PerMode = struct { | 16 | const PerMode = struct { |
| 17 | expect: []const u8, | 17 | expect: []const u8, |
| 18 | exclude_arch: []const std.Target.Cpu.Arch = &.{}, | ||
| 18 | exclude_os: []const std.Target.Os.Tag = &.{}, | 19 | exclude_os: []const std.Target.Os.Tag = &.{}, |
| 19 | error_tracing: ?bool = null, | 20 | error_tracing: ?bool = null, |
| 20 | }; | 21 | }; |
| ... | @@ -59,6 +60,7 @@ fn addExpect( | ... | @@ -59,6 +60,7 @@ fn addExpect( |
| 59 | use_llvm: bool, | 60 | use_llvm: bool, |
| 60 | mode_config: Config.PerMode, | 61 | mode_config: Config.PerMode, |
| 61 | ) void { | 62 | ) void { |
| 63 | for (mode_config.exclude_arch) |tag| if (tag == builtin.cpu.arch) return; | ||
| 62 | for (mode_config.exclude_os) |tag| if (tag == builtin.os.tag) return; | 64 | for (mode_config.exclude_os) |tag| if (tag == builtin.os.tag) return; |
| 63 | 65 | ||
| 64 | const b = self.b; | 66 | const b = self.b; |
test/stack_traces.zig+10| ... | @@ -792,6 +792,16 @@ pub fn addCases(cases: *tests.StackTracesContext) void { | ... | @@ -792,6 +792,16 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 792 | \\} | 792 | \\} |
| 793 | , | 793 | , |
| 794 | .Debug = .{ | 794 | .Debug = .{ |
| 795 | // std.debug.sys_can_stack_trace | ||
| 796 | .exclude_arch = &.{ | ||
| 797 | .loongarch32, | ||
| 798 | .loongarch64, | ||
| 799 | .mips, | ||
| 800 | .mipsel, | ||
| 801 | .mips64, | ||
| 802 | .mips64el, | ||
| 803 | .s390x, | ||
| 804 | }, | ||
| 795 | .exclude_os = &.{ | 805 | .exclude_os = &.{ |
| 796 | .openbsd, // integer overflow | 806 | .openbsd, // integer overflow |
| 797 | .windows, // TODO intermittent failures | 807 | .windows, // TODO intermittent failures |
test/standalone/build.zig+6-1| ... | @@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void { |
| 9 | const enable_macos_sdk = b.option(bool, "enable_macos_sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse enable_ios_sdk; | 9 | const enable_macos_sdk = b.option(bool, "enable_macos_sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse enable_ios_sdk; |
| 10 | const enable_symlinks_windows = b.option(bool, "enable_symlinks_windows", "Run tests requiring presence of symlinks on Windows") orelse false; | 10 | const enable_symlinks_windows = b.option(bool, "enable_symlinks_windows", "Run tests requiring presence of symlinks on Windows") orelse false; |
| 11 | const omit_symlinks = builtin.os.tag == .windows and !enable_symlinks_windows; | 11 | const omit_symlinks = builtin.os.tag == .windows and !enable_symlinks_windows; |
| 12 | const skip_translate_c = b.option(bool, "skip_translate_c", "Test suite skips translate-c tests") orelse false; | ||
| 12 | 13 | ||
| 13 | const simple_skip_debug = b.option(bool, "simple_skip_debug", "Simple tests skip debug builds") orelse false; | 14 | const simple_skip_debug = b.option(bool, "simple_skip_debug", "Simple tests skip debug builds") orelse false; |
| 14 | const simple_skip_release_safe = b.option(bool, "simple_skip_release_safe", "Simple tests skip release-safe builds") orelse false; | 15 | const simple_skip_release_safe = b.option(bool, "simple_skip_release_safe", "Simple tests skip release-safe builds") orelse false; |
| ... | @@ -20,6 +21,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -20,6 +21,7 @@ pub fn build(b: *std.Build) void { |
| 20 | .skip_release_safe = simple_skip_release_safe, | 21 | .skip_release_safe = simple_skip_release_safe, |
| 21 | .skip_release_fast = simple_skip_release_fast, | 22 | .skip_release_fast = simple_skip_release_fast, |
| 22 | .skip_release_small = simple_skip_release_small, | 23 | .skip_release_small = simple_skip_release_small, |
| 24 | .skip_translate_c = skip_translate_c, | ||
| 23 | }); | 25 | }); |
| 24 | const simple_dep_step = simple_dep.builder.default_step; | 26 | const simple_dep_step = simple_dep.builder.default_step; |
| 25 | simple_dep_step.name = "standalone_test_cases.simple"; | 27 | simple_dep_step.name = "standalone_test_cases.simple"; |
| ... | @@ -97,9 +99,12 @@ pub fn build(b: *std.Build) void { | ... | @@ -97,9 +99,12 @@ pub fn build(b: *std.Build) void { |
| 97 | pkg.build_zig.requires_macos_sdk; | 99 | pkg.build_zig.requires_macos_sdk; |
| 98 | const requires_symlinks = @hasDecl(pkg.build_zig, "requires_symlinks") and | 100 | const requires_symlinks = @hasDecl(pkg.build_zig, "requires_symlinks") and |
| 99 | pkg.build_zig.requires_symlinks; | 101 | pkg.build_zig.requires_symlinks; |
| 102 | const requires_translate_c = @hasDecl(pkg.build_zig, "requires_translate_c") and | ||
| 103 | pkg.build_zig.requires_translate_c; | ||
| 100 | if ((requires_symlinks and omit_symlinks) or | 104 | if ((requires_symlinks and omit_symlinks) or |
| 101 | (requires_macos_sdk and !enable_macos_sdk) or | 105 | (requires_macos_sdk and !enable_macos_sdk) or |
| 102 | (requires_ios_sdk and !enable_ios_sdk)) | 106 | (requires_ios_sdk and !enable_ios_sdk) or |
| 107 | (requires_translate_c and skip_translate_c)) | ||
| 103 | { | 108 | { |
| 104 | continue :add_dep_steps; | 109 | continue :add_dep_steps; |
| 105 | } | 110 | } |
test/standalone/dep_lazypath/build.zig+2| ... | @@ -1,5 +1,7 @@ | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_translate_c = 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 it"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | b.default_step = test_step; | 7 | b.default_step = test_step; |
test/standalone/glibc_compat/build.zig+2| ... | @@ -1,6 +1,8 @@ | ... | @@ -1,6 +1,8 @@ |
| 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_translate_c = true; | ||
| 5 | |||
| 4 | // To run executables linked against a specific glibc version, the | 6 | // To run executables linked against a specific glibc version, the |
| 5 | // run-time glibc version needs to be new enough. Check the host's glibc | 7 | // run-time glibc version needs to be new enough. Check the host's glibc |
| 6 | // version. Note that this does not allow for translation/vm/emulation | 8 | // version. Note that this does not allow for translation/vm/emulation |
test/standalone/issue_794/build.zig+2| ... | @@ -1,5 +1,7 @@ | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_translate_c = 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 it"); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | b.default_step = test_step; | 7 | b.default_step = test_step; |
test/standalone/simple/build.zig+8-1| ... | @@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void { |
| 9 | const skip_release_safe = b.option(bool, "skip_release_safe", "Skip release-safe builds") orelse false; | 9 | const skip_release_safe = b.option(bool, "skip_release_safe", "Skip release-safe builds") orelse false; |
| 10 | const skip_release_fast = b.option(bool, "skip_release_fast", "Skip release-fast builds") orelse false; | 10 | const skip_release_fast = b.option(bool, "skip_release_fast", "Skip release-fast builds") orelse false; |
| 11 | const skip_release_small = b.option(bool, "skip_release_small", "Skip release-small builds") orelse false; | 11 | const skip_release_small = b.option(bool, "skip_release_small", "Skip release-small builds") orelse false; |
| 12 | const skip_translate_c = b.option(bool, "skip_translate_c", "Test suite skips translate-c tests") orelse false; | ||
| 12 | 13 | ||
| 13 | var optimize_modes_buf: [4]std.builtin.OptimizeMode = undefined; | 14 | var optimize_modes_buf: [4]std.builtin.OptimizeMode = undefined; |
| 14 | var optimize_modes_len: usize = 0; | 15 | var optimize_modes_len: usize = 0; |
| ... | @@ -36,6 +37,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -36,6 +37,7 @@ pub fn build(b: *std.Build) void { |
| 36 | if (case.os_filter) |os_tag| { | 37 | if (case.os_filter) |os_tag| { |
| 37 | if (os_tag != builtin.os.tag) continue; | 38 | if (os_tag != builtin.os.tag) continue; |
| 38 | } | 39 | } |
| 40 | if (case.uses_translate_c and skip_translate_c) continue; | ||
| 39 | 41 | ||
| 40 | const resolved_target = b.resolveTargetQuery(case.target); | 42 | const resolved_target = b.resolveTargetQuery(case.target); |
| 41 | 43 | ||
| ... | @@ -82,6 +84,7 @@ const Case = struct { | ... | @@ -82,6 +84,7 @@ const Case = struct { |
| 82 | is_exe: bool = true, | 84 | is_exe: bool = true, |
| 83 | /// Run only on this OS. | 85 | /// Run only on this OS. |
| 84 | os_filter: ?std.Target.Os.Tag = null, | 86 | os_filter: ?std.Target.Os.Tag = null, |
| 87 | uses_translate_c: bool = false, | ||
| 85 | }; | 88 | }; |
| 86 | 89 | ||
| 87 | const cases = [_]Case{ | 90 | const cases = [_]Case{ |
| ... | @@ -93,6 +96,7 @@ const cases = [_]Case{ | ... | @@ -93,6 +96,7 @@ const cases = [_]Case{ |
| 93 | .src_path = "hello_world/hello_libc.zig", | 96 | .src_path = "hello_world/hello_libc.zig", |
| 94 | .link_libc = true, | 97 | .link_libc = true, |
| 95 | .all_modes = true, | 98 | .all_modes = true, |
| 99 | .uses_translate_c = true, | ||
| 96 | }, | 100 | }, |
| 97 | .{ | 101 | .{ |
| 98 | .src_path = "cat/main.zig", | 102 | .src_path = "cat/main.zig", |
| ... | @@ -108,7 +112,10 @@ const cases = [_]Case{ | ... | @@ -108,7 +112,10 @@ const cases = [_]Case{ |
| 108 | .os_tag = .freestanding, | 112 | .os_tag = .freestanding, |
| 109 | }, | 113 | }, |
| 110 | }, | 114 | }, |
| 111 | .{ .src_path = "issue_12471/main.zig" }, | 115 | .{ |
| 116 | .src_path = "issue_12471/main.zig", | ||
| 117 | .uses_translate_c = true, | ||
| 118 | }, | ||
| 112 | .{ .src_path = "guess_number/main.zig" }, | 119 | .{ .src_path = "guess_number/main.zig" }, |
| 113 | .{ .src_path = "main_return_error/error_u8.zig" }, | 120 | .{ .src_path = "main_return_error/error_u8.zig" }, |
| 114 | .{ .src_path = "main_return_error/error_u8_non_zero.zig" }, | 121 | .{ .src_path = "main_return_error/error_u8_non_zero.zig" }, |
test/standalone/simple/hello_world/hello_libc.zig+3-7| ... | @@ -1,15 +1,11 @@ | ... | @@ -1,15 +1,11 @@ |
| 1 | const c = @cImport({ | 1 | extern fn printf(format: [*:0]const u8, ...) c_int; |
| 2 | // See https://github.com/ziglang/zig/issues/515 | 2 | extern fn strlen(str: [*:0]const u8) usize; |
| 3 | @cDefine("_NO_CRT_STDIO_INLINE", "1"); | ||
| 4 | @cInclude("stdio.h"); | ||
| 5 | @cInclude("string.h"); | ||
| 6 | }); | ||
| 7 | 3 | ||
| 8 | const msg = "Hello, world!\n"; | 4 | const msg = "Hello, world!\n"; |
| 9 | 5 | ||
| 10 | pub export fn main(argc: c_int, argv: **u8) c_int { | 6 | pub export fn main(argc: c_int, argv: **u8) c_int { |
| 11 | _ = argv; | 7 | _ = argv; |
| 12 | _ = argc; | 8 | _ = argc; |
| 13 | if (c.printf(msg) != @as(c_int, @intCast(c.strlen(msg)))) return -1; | 9 | if (printf(msg) != @as(c_int, @intCast(strlen(msg)))) return -1; |
| 14 | return 0; | 10 | return 0; |
| 15 | } | 11 | } |
test/standalone/static_c_lib/foo.zig+5-3| ... | @@ -1,12 +1,14 @@ | ... | @@ -1,12 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; | 2 | const expect = std.testing.expect; |
| 3 | const c = @cImport(@cInclude("foo.h")); | 3 | |
| 4 | extern fn add(a: u32, b: u32) u32; | ||
| 5 | extern var foo: u32; | ||
| 4 | 6 | ||
| 5 | test "C add" { | 7 | test "C add" { |
| 6 | const result = c.add(1, 2); | 8 | const result = add(1, 2); |
| 7 | try expect(result == 3); | 9 | try expect(result == 3); |
| 8 | } | 10 | } |
| 9 | 11 | ||
| 10 | test "C extern variable" { | 12 | test "C extern variable" { |
| 11 | try expect(c.foo == 12345); | 13 | try expect(foo == 12345); |
| 12 | } | 14 | } |
test/tests.zig+2-8| ... | @@ -419,8 +419,6 @@ const test_targets = blk: { | ... | @@ -419,8 +419,6 @@ const test_targets = blk: { |
| 419 | .os_tag = .linux, | 419 | .os_tag = .linux, |
| 420 | .abi = .none, | 420 | .abi = .none, |
| 421 | }, | 421 | }, |
| 422 | // https://github.com/ziglang/zig/issues/21646 | ||
| 423 | .skip_modules = &.{"std"}, | ||
| 424 | }, | 422 | }, |
| 425 | .{ | 423 | .{ |
| 426 | .target = .{ | 424 | .target = .{ |
| ... | @@ -429,8 +427,6 @@ const test_targets = blk: { | ... | @@ -429,8 +427,6 @@ const test_targets = blk: { |
| 429 | .abi = .musl, | 427 | .abi = .musl, |
| 430 | }, | 428 | }, |
| 431 | .link_libc = true, | 429 | .link_libc = true, |
| 432 | // https://github.com/ziglang/zig/issues/21646 | ||
| 433 | .skip_modules = &.{"std"}, | ||
| 434 | }, | 430 | }, |
| 435 | .{ | 431 | .{ |
| 436 | .target = .{ | 432 | .target = .{ |
| ... | @@ -440,8 +436,6 @@ const test_targets = blk: { | ... | @@ -440,8 +436,6 @@ const test_targets = blk: { |
| 440 | }, | 436 | }, |
| 441 | .linkage = .dynamic, | 437 | .linkage = .dynamic, |
| 442 | .link_libc = true, | 438 | .link_libc = true, |
| 443 | // https://github.com/ziglang/zig/issues/21646 | ||
| 444 | .skip_modules = &.{"std"}, | ||
| 445 | .extra_target = true, | 439 | .extra_target = true, |
| 446 | }, | 440 | }, |
| 447 | .{ | 441 | .{ |
| ... | @@ -451,8 +445,6 @@ const test_targets = blk: { | ... | @@ -451,8 +445,6 @@ const test_targets = blk: { |
| 451 | .abi = .gnu, | 445 | .abi = .gnu, |
| 452 | }, | 446 | }, |
| 453 | .link_libc = true, | 447 | .link_libc = true, |
| 454 | // https://github.com/ziglang/zig/issues/21646 | ||
| 455 | .skip_modules = &.{"std"}, | ||
| 456 | }, | 448 | }, |
| 457 | 449 | ||
| 458 | .{ | 450 | .{ |
| ... | @@ -1901,6 +1893,7 @@ pub fn addStandaloneTests( | ... | @@ -1901,6 +1893,7 @@ pub fn addStandaloneTests( |
| 1901 | enable_macos_sdk: bool, | 1893 | enable_macos_sdk: bool, |
| 1902 | enable_ios_sdk: bool, | 1894 | enable_ios_sdk: bool, |
| 1903 | enable_symlinks_windows: bool, | 1895 | enable_symlinks_windows: bool, |
| 1896 | skip_translate_c: bool, | ||
| 1904 | ) *Step { | 1897 | ) *Step { |
| 1905 | const step = b.step("test-standalone", "Run the standalone tests"); | 1898 | const step = b.step("test-standalone", "Run the standalone tests"); |
| 1906 | if (compilerHasPackageManager(b)) { | 1899 | if (compilerHasPackageManager(b)) { |
| ... | @@ -1913,6 +1906,7 @@ pub fn addStandaloneTests( | ... | @@ -1913,6 +1906,7 @@ pub fn addStandaloneTests( |
| 1913 | .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSafe) == null, | 1906 | .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSafe) == null, |
| 1914 | .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseFast) == null, | 1907 | .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseFast) == null, |
| 1915 | .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSmall) == null, | 1908 | .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSmall) == null, |
| 1909 | .skip_translate_c = skip_translate_c, | ||
| 1916 | }); | 1910 | }); |
| 1917 | const test_cases_dep_step = test_cases_dep.builder.default_step; | 1911 | const test_cases_dep_step = test_cases_dep.builder.default_step; |
| 1918 | test_cases_dep_step.name = b.dupe(test_cases_dep_name); | 1912 | test_cases_dep_step.name = b.dupe(test_cases_dep_name); |
tools/update_cpu_features.zig+30| ... | @@ -986,6 +986,36 @@ const targets = [_]ArchTarget{ | ... | @@ -986,6 +986,36 @@ const targets = [_]ArchTarget{ |
| 986 | .name = "LoongArch", | 986 | .name = "LoongArch", |
| 987 | .td_name = "LoongArch", | 987 | .td_name = "LoongArch", |
| 988 | }, | 988 | }, |
| 989 | .extra_cpus = &.{ | ||
| 990 | .{ | ||
| 991 | .llvm_name = null, | ||
| 992 | .zig_name = "la64v1_0", | ||
| 993 | .features = &.{ | ||
| 994 | "64bit", | ||
| 995 | "lsx", | ||
| 996 | "ual", | ||
| 997 | }, | ||
| 998 | }, | ||
| 999 | .{ | ||
| 1000 | .llvm_name = null, | ||
| 1001 | .zig_name = "la64v1_1", | ||
| 1002 | .features = &.{ | ||
| 1003 | "64bit", | ||
| 1004 | "div32", | ||
| 1005 | "frecipe", | ||
| 1006 | "lam_bh", | ||
| 1007 | "lamcas", | ||
| 1008 | "ld_seq_sa", | ||
| 1009 | "lsx", | ||
| 1010 | "scq", | ||
| 1011 | "ual", | ||
| 1012 | }, | ||
| 1013 | }, | ||
| 1014 | }, | ||
| 1015 | .omit_cpus = &.{ | ||
| 1016 | "generic", | ||
| 1017 | "loongarch64", | ||
| 1018 | }, | ||
| 989 | }, | 1019 | }, |
| 990 | .{ | 1020 | .{ |
| 991 | .zig_name = "m68k", | 1021 | .zig_name = "m68k", |