| author | |
| committer | |
| log | edf785db0f30842b958f540a3aaf7205b8b82493 |
| tree | 88225d506adb78ce88b8b9de64c482810e448b9d |
| parent | ee6d19480da53b3a351749e2a7b18c45ad072018 |
| parent | 8e511e031f72ef2bf236d498f32bf1013cacb882 |
| signature |
Native RISC-V bootstrap and test fixes17 files changed, 142 insertions(+), 20 deletions(-)
doc/langref/runtime_shrExact_overflow.zig+3| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | const builtin = @import("builtin"); | |
| 1 | 2 | const std = @import("std"); |
| 2 | 3 | |
| 3 | 4 | pub fn main() void { |
| ... | ... | @@ -5,6 +6,8 @@ pub fn main() void { |
| 5 | 6 | _ = &x; |
| 6 | 7 | const y = @shrExact(x, 2); |
| 7 | 8 | std.debug.print("value: {}\n", .{y}); |
| 9 | ||
| 10 | if (builtin.cpu.arch.isRISCV() and builtin.zig_backend == .stage2_llvm) @panic("https://github.com/ziglang/zig/issues/24304"); | |
| 8 | 11 | } |
| 9 | 12 | |
| 10 | 13 | // exe=fail |
lib/libunwind/src/UnwindCursor.hpp+1-1| ... | ... | @@ -150,7 +150,7 @@ bool DwarfFDECache<A>::_registeredForDyldUnloads = false; |
| 150 | 150 | #endif |
| 151 | 151 | |
| 152 | 152 | template <typename A> |
| 153 | typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { | |
| 153 | typename DwarfFDECache<A>::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { | |
| 154 | 154 | pint_t result = 0; |
| 155 | 155 | _LIBUNWIND_LOG_IF_FALSE(_lock.lock_shared()); |
| 156 | 156 | for (entry *p = _buffer; p < _bufferUsed; ++p) { |
lib/std/Build/Step/CheckObject.zig+1-1| ... | ... | @@ -2270,7 +2270,7 @@ const ElfDumper = struct { |
| 2270 | 2270 | try writer.print(" {s}", .{sym_bind}); |
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | const sym_vis = @as(elf.STV, @enumFromInt(sym.st_other)); | |
| 2273 | const sym_vis = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other)))); | |
| 2274 | 2274 | try writer.print(" {s}", .{@tagName(sym_vis)}); |
| 2275 | 2275 | |
| 2276 | 2276 | const sym_name = switch (sym.st_type()) { |
lib/std/bit_set.zig+1| ... | ... | @@ -1699,6 +1699,7 @@ fn testStaticBitSet(comptime Set: type) !void { |
| 1699 | 1699 | |
| 1700 | 1700 | test IntegerBitSet { |
| 1701 | 1701 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1702 | if (comptime builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24300 | |
| 1702 | 1703 | |
| 1703 | 1704 | try testStaticBitSet(IntegerBitSet(0)); |
| 1704 | 1705 | try testStaticBitSet(IntegerBitSet(1)); |
lib/std/crypto/salsa20.zig+6| ... | ... | @@ -557,6 +557,8 @@ pub const SealedBox = struct { |
| 557 | 557 | const htest = @import("test.zig"); |
| 558 | 558 | |
| 559 | 559 | test "(x)salsa20" { |
| 560 | if (builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24299 | |
| 561 | ||
| 560 | 562 | const key = [_]u8{0x69} ** 32; |
| 561 | 563 | const nonce = [_]u8{0x42} ** 8; |
| 562 | 564 | const msg = [_]u8{0} ** 20; |
| ... | ... | @@ -600,6 +602,8 @@ test "xsalsa20poly1305 secretbox" { |
| 600 | 602 | } |
| 601 | 603 | |
| 602 | 604 | test "xsalsa20poly1305 box" { |
| 605 | if (builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24299 | |
| 606 | ||
| 603 | 607 | var msg: [100]u8 = undefined; |
| 604 | 608 | var msg2: [msg.len]u8 = undefined; |
| 605 | 609 | var nonce: [Box.nonce_length]u8 = undefined; |
| ... | ... | @@ -614,6 +618,8 @@ test "xsalsa20poly1305 box" { |
| 614 | 618 | } |
| 615 | 619 | |
| 616 | 620 | test "xsalsa20poly1305 sealedbox" { |
| 621 | if (builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24299 | |
| 622 | ||
| 617 | 623 | var msg: [100]u8 = undefined; |
| 618 | 624 | var msg2: [msg.len]u8 = undefined; |
| 619 | 625 | var boxed: [msg.len + SealedBox.seal_length]u8 = undefined; |
lib/std/os/linux/riscv32.zig+36-2| ... | ... | @@ -7,6 +7,8 @@ const SYS = linux.SYS; |
| 7 | 7 | const uid_t = std.os.linux.uid_t; |
| 8 | 8 | const gid_t = std.os.linux.gid_t; |
| 9 | 9 | const pid_t = std.os.linux.pid_t; |
| 10 | const stack_t = linux.stack_t; | |
| 11 | const sigset_t = linux.sigset_t; | |
| 10 | 12 | const sockaddr = linux.sockaddr; |
| 11 | 13 | const socklen_t = linux.socklen_t; |
| 12 | 14 | const timespec = std.os.linux.timespec; |
| ... | ... | @@ -261,8 +263,40 @@ pub const VDSO = struct { |
| 261 | 263 | pub const CGT_VER = "LINUX_4.15"; |
| 262 | 264 | }; |
| 263 | 265 | |
| 264 | /// TODO | |
| 265 | pub const ucontext_t = void; | |
| 266 | pub const f_ext_state = extern struct { | |
| 267 | f: [32]f32, | |
| 268 | fcsr: u32, | |
| 269 | }; | |
| 270 | ||
| 271 | pub const d_ext_state = extern struct { | |
| 272 | f: [32]f64, | |
| 273 | fcsr: u32, | |
| 274 | }; | |
| 275 | ||
| 276 | pub const q_ext_state = extern struct { | |
| 277 | f: [32]f128, | |
| 278 | fcsr: u32, | |
| 279 | _reserved: [3]u32, | |
| 280 | }; | |
| 281 | ||
| 282 | pub const fpstate = extern union { | |
| 283 | f: f_ext_state, | |
| 284 | d: d_ext_state, | |
| 285 | q: q_ext_state, | |
| 286 | }; | |
| 287 | ||
| 288 | pub const mcontext_t = extern struct { | |
| 289 | gregs: [32]u32, | |
| 290 | fpregs: fpstate, | |
| 291 | }; | |
| 292 | ||
| 293 | pub const ucontext_t = extern struct { | |
| 294 | flags: c_ulong, | |
| 295 | link: ?*ucontext_t, | |
| 296 | stack: stack_t, | |
| 297 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | |
| 298 | mcontext: mcontext_t, | |
| 299 | }; | |
| 266 | 300 | |
| 267 | 301 | /// TODO |
| 268 | 302 | pub const getcontext = {}; |
lib/std/os/linux/riscv64.zig+36-2| ... | ... | @@ -7,6 +7,8 @@ const SYS = linux.SYS; |
| 7 | 7 | const uid_t = std.os.linux.uid_t; |
| 8 | 8 | const gid_t = std.os.linux.gid_t; |
| 9 | 9 | const pid_t = std.os.linux.pid_t; |
| 10 | const stack_t = linux.stack_t; | |
| 11 | const sigset_t = linux.sigset_t; | |
| 10 | 12 | const sockaddr = linux.sockaddr; |
| 11 | 13 | const socklen_t = linux.socklen_t; |
| 12 | 14 | const timespec = std.os.linux.timespec; |
| ... | ... | @@ -261,8 +263,40 @@ pub const VDSO = struct { |
| 261 | 263 | pub const CGT_VER = "LINUX_4.15"; |
| 262 | 264 | }; |
| 263 | 265 | |
| 264 | /// TODO | |
| 265 | pub const ucontext_t = void; | |
| 266 | pub const f_ext_state = extern struct { | |
| 267 | f: [32]f32, | |
| 268 | fcsr: u32, | |
| 269 | }; | |
| 270 | ||
| 271 | pub const d_ext_state = extern struct { | |
| 272 | f: [32]f64, | |
| 273 | fcsr: u32, | |
| 274 | }; | |
| 275 | ||
| 276 | pub const q_ext_state = extern struct { | |
| 277 | f: [32]f128, | |
| 278 | fcsr: u32, | |
| 279 | _reserved: [3]u32, | |
| 280 | }; | |
| 281 | ||
| 282 | pub const fpstate = extern union { | |
| 283 | f: f_ext_state, | |
| 284 | d: d_ext_state, | |
| 285 | q: q_ext_state, | |
| 286 | }; | |
| 287 | ||
| 288 | pub const mcontext_t = extern struct { | |
| 289 | gregs: [32]u64, | |
| 290 | fpregs: fpstate, | |
| 291 | }; | |
| 292 | ||
| 293 | pub const ucontext_t = extern struct { | |
| 294 | flags: c_ulong, | |
| 295 | link: ?*ucontext_t, | |
| 296 | stack: stack_t, | |
| 297 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | |
| 298 | mcontext: mcontext_t, | |
| 299 | }; | |
| 266 | 300 | |
| 267 | 301 | /// TODO |
| 268 | 302 | pub const getcontext = {}; |
lib/std/simd.zig+2| ... | ... | @@ -9,6 +9,8 @@ const std = @import("std"); |
| 9 | 9 | const builtin = @import("builtin"); |
| 10 | 10 | |
| 11 | 11 | pub fn suggestVectorLengthForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?comptime_int { |
| 12 | @setEvalBranchQuota(2_000); | |
| 13 | ||
| 12 | 14 | // This is guesswork, if you have better suggestions can add it or edit the current here |
| 13 | 15 | const element_bit_size = @max(8, std.math.ceilPowerOfTwo(u16, @bitSizeOf(T)) catch unreachable); |
| 14 | 16 | const vector_bit_size: u16 = blk: { |
lib/std/zig/system/linux.zig+2| ... | ... | @@ -76,9 +76,11 @@ const RiscvCpuinfoImpl = struct { |
| 76 | 76 | |
| 77 | 77 | const cpu_names = .{ |
| 78 | 78 | .{ "sifive,u54", &Target.riscv.cpu.sifive_u54 }, |
| 79 | .{ "sifive,u54-mc", &Target.riscv.cpu.sifive_u54 }, | |
| 79 | 80 | .{ "sifive,u7", &Target.riscv.cpu.sifive_7_series }, |
| 80 | 81 | .{ "sifive,u74", &Target.riscv.cpu.sifive_u74 }, |
| 81 | 82 | .{ "sifive,u74-mc", &Target.riscv.cpu.sifive_u74 }, |
| 83 | .{ "spacemit,x60", &Target.riscv.cpu.spacemit_x60 }, | |
| 82 | 84 | }; |
| 83 | 85 | |
| 84 | 86 | fn line_hook(self: *RiscvCpuinfoImpl, key: []const u8, value: []const u8) !bool { |
src/codegen/llvm.zig+7-4| ... | ... | @@ -1068,6 +1068,9 @@ pub const Object = struct { |
| 1068 | 1068 | .full => .FullPreLink, |
| 1069 | 1069 | }, |
| 1070 | 1070 | .allow_fast_isel = true, |
| 1071 | // LLVM's RISC-V backend for some reason enables the machine outliner by default even | |
| 1072 | // though it's clearly not ready and produces multiple miscompilations in our std tests. | |
| 1073 | .allow_machine_outliner = !comp.root_mod.resolved_target.result.cpu.arch.isRISCV(), | |
| 1071 | 1074 | .asm_filename = null, |
| 1072 | 1075 | .bin_filename = options.bin_path, |
| 1073 | 1076 | .llvm_ir_filename = options.post_ir_path, |
| ... | ... | @@ -6831,8 +6834,8 @@ pub const FuncGen = struct { |
| 6831 | 6834 | |
| 6832 | 6835 | self.maybeMarkAllowZeroAccess(slice_ty.ptrInfo(zcu)); |
| 6833 | 6836 | |
| 6834 | const elem_alignment = elem_ty.abiAlignment(zcu).toLlvm(); | |
| 6835 | return self.loadByRef(ptr, elem_ty, elem_alignment, if (slice_ty.isVolatilePtr(zcu)) .@"volatile" else .normal); | |
| 6837 | const slice_align = (slice_ty.ptrAlignment(zcu).min(elem_ty.abiAlignment(zcu))).toLlvm(); | |
| 6838 | return self.loadByRef(ptr, elem_ty, slice_align, if (slice_ty.isVolatilePtr(zcu)) .@"volatile" else .normal); | |
| 6836 | 6839 | } |
| 6837 | 6840 | |
| 6838 | 6841 | self.maybeMarkAllowZeroAccess(slice_ty.ptrInfo(zcu)); |
| ... | ... | @@ -6909,8 +6912,8 @@ pub const FuncGen = struct { |
| 6909 | 6912 | |
| 6910 | 6913 | self.maybeMarkAllowZeroAccess(ptr_ty.ptrInfo(zcu)); |
| 6911 | 6914 | |
| 6912 | const elem_alignment = elem_ty.abiAlignment(zcu).toLlvm(); | |
| 6913 | return self.loadByRef(ptr, elem_ty, elem_alignment, if (ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal); | |
| 6915 | const ptr_align = (ptr_ty.ptrAlignment(zcu).min(elem_ty.abiAlignment(zcu))).toLlvm(); | |
| 6916 | return self.loadByRef(ptr, elem_ty, ptr_align, if (ptr_ty.isVolatilePtr(zcu)) .@"volatile" else .normal); | |
| 6914 | 6917 | } |
| 6915 | 6918 | |
| 6916 | 6919 | self.maybeMarkAllowZeroAccess(ptr_ty.ptrInfo(zcu)); |
src/codegen/llvm/bindings.zig+1| ... | ... | @@ -92,6 +92,7 @@ pub const TargetMachine = opaque { |
| 92 | 92 | sancov: bool, |
| 93 | 93 | lto: LtoPhase, |
| 94 | 94 | allow_fast_isel: bool, |
| 95 | allow_machine_outliner: bool, | |
| 95 | 96 | asm_filename: ?[*:0]const u8, |
| 96 | 97 | bin_filename: ?[*:0]const u8, |
| 97 | 98 | llvm_ir_filename: ?[*:0]const u8, |
src/zig_llvm.cpp+10-6| ... | ... | @@ -260,6 +260,16 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi |
| 260 | 260 | |
| 261 | 261 | TargetMachine &target_machine = *reinterpret_cast<TargetMachine*>(targ_machine_ref); |
| 262 | 262 | |
| 263 | if (options->allow_fast_isel) { | |
| 264 | target_machine.setO0WantsFastISel(true); | |
| 265 | } else { | |
| 266 | target_machine.setFastISel(false); | |
| 267 | } | |
| 268 | ||
| 269 | if (!options->allow_machine_outliner) { | |
| 270 | target_machine.setMachineOutliner(false); | |
| 271 | } | |
| 272 | ||
| 263 | 273 | Module &llvm_module = *unwrap(module_ref); |
| 264 | 274 | |
| 265 | 275 | // Pipeline configurations |
| ... | ... | @@ -385,12 +395,6 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi |
| 385 | 395 | } |
| 386 | 396 | } |
| 387 | 397 | |
| 388 | if (options->allow_fast_isel) { | |
| 389 | target_machine.setO0WantsFastISel(true); | |
| 390 | } else { | |
| 391 | target_machine.setFastISel(false); | |
| 392 | } | |
| 393 | ||
| 394 | 398 | // Optimization phase |
| 395 | 399 | module_pm.run(llvm_module, module_am); |
| 396 | 400 |
src/zig_llvm.h+1| ... | ... | @@ -71,6 +71,7 @@ struct ZigLLVMEmitOptions { |
| 71 | 71 | bool sancov; |
| 72 | 72 | ZigLLVMThinOrFullLTOPhase lto; |
| 73 | 73 | bool allow_fast_isel; |
| 74 | bool allow_machine_outliner; | |
| 74 | 75 | const char *asm_filename; |
| 75 | 76 | const char *bin_filename; |
| 76 | 77 | const char *llvm_ir_filename; |
test/behavior/vector.zig+1| ... | ... | @@ -560,6 +560,7 @@ test "vector division operators" { |
| 560 | 560 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 561 | 561 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 562 | 562 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 563 | if (comptime builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24301 | |
| 563 | 564 | |
| 564 | 565 | const S = struct { |
| 565 | 566 | fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void { |
test/link/glibc_compat/build.zig+21-4| ... | ... | @@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void { |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Build & run a C test case against a sampling of supported glibc versions |
| 36 | for ([_][]const u8{ | |
| 36 | versions: for ([_][]const u8{ | |
| 37 | 37 | // "native-linux-gnu.2.0", // fails with a pile of missing symbols. |
| 38 | 38 | "native-linux-gnu.2.2.5", |
| 39 | 39 | "native-linux-gnu.2.4", |
| ... | ... | @@ -52,9 +52,14 @@ pub fn build(b: *std.Build) void { |
| 52 | 52 | const glibc_ver = target.result.os.version_range.linux.glibc; |
| 53 | 53 | |
| 54 | 54 | // only build test if glibc version supports the architecture |
| 55 | if (target.result.cpu.arch.isAARCH64()) { | |
| 56 | if (glibc_ver.order(.{ .major = 2, .minor = 17, .patch = 0 }) == .lt) { | |
| 55 | for (std.zig.target.available_libcs) |libc| { | |
| 56 | if (libc.arch != target.result.cpu.arch or | |
| 57 | libc.os != target.result.os.tag or | |
| 58 | libc.abi != target.result.abi) | |
| 57 | 59 | continue; |
| 60 | ||
| 61 | if (libc.glibc_min) |min| { | |
| 62 | if (glibc_ver.order(min) == .lt) continue :versions; | |
| 58 | 63 | } |
| 59 | 64 | } |
| 60 | 65 | |
| ... | ... | @@ -147,7 +152,7 @@ pub fn build(b: *std.Build) void { |
| 147 | 152 | } |
| 148 | 153 | |
| 149 | 154 | // Build & run a Zig test case against a sampling of supported glibc versions |
| 150 | for ([_][]const u8{ | |
| 155 | versions: for ([_][]const u8{ | |
| 151 | 156 | "native-linux-gnu.2.17", // Currently oldest supported, see #17769 |
| 152 | 157 | "native-linux-gnu.2.23", |
| 153 | 158 | "native-linux-gnu.2.28", |
| ... | ... | @@ -161,6 +166,18 @@ pub fn build(b: *std.Build) void { |
| 161 | 166 | |
| 162 | 167 | const glibc_ver = target.result.os.version_range.linux.glibc; |
| 163 | 168 | |
| 169 | // only build test if glibc version supports the architecture | |
| 170 | for (std.zig.target.available_libcs) |libc| { | |
| 171 | if (libc.arch != target.result.cpu.arch or | |
| 172 | libc.os != target.result.os.tag or | |
| 173 | libc.abi != target.result.abi) | |
| 174 | continue; | |
| 175 | ||
| 176 | if (libc.glibc_min) |min| { | |
| 177 | if (glibc_ver.order(min) == .lt) continue :versions; | |
| 178 | } | |
| 179 | } | |
| 180 | ||
| 164 | 181 | const exe = b.addExecutable(.{ |
| 165 | 182 | .name = t, |
| 166 | 183 | .root_module = b.createModule(.{ |
test/standalone/coff_dwarf/build.zig+8| ... | ... | @@ -3,6 +3,14 @@ const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | /// This tests the path where DWARF information is embedded in a COFF binary |
| 5 | 5 | pub fn build(b: *std.Build) void { |
| 6 | switch (builtin.cpu.arch) { | |
| 7 | .aarch64, | |
| 8 | .x86, | |
| 9 | .x86_64, | |
| 10 | => {}, | |
| 11 | else => return, | |
| 12 | } | |
| 13 | ||
| 6 | 14 | const test_step = b.step("test", "Test it"); |
| 7 | 15 | b.default_step = test_step; |
| 8 | 16 |
test/standalone/stack_iterator/build.zig+5| ... | ... | @@ -8,6 +8,11 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | const target = b.standardTargetOptions(.{}); |
| 9 | 9 | const optimize = b.standardOptimizeOption(.{}); |
| 10 | 10 | |
| 11 | if (target.result.cpu.arch.isRISCV() and target.result.os.tag == .linux) { | |
| 12 | // https://github.com/ziglang/zig/issues/24310 | |
| 13 | return; | |
| 14 | } | |
| 15 | ||
| 11 | 16 | // Unwinding with a frame pointer |
| 12 | 17 | // |
| 13 | 18 | // getcontext version: zig std |