diff --git a/lib/std/start.zig b/lib/std/start.zig index f4a5cbb763..5690337317 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -30,8 +30,8 @@ comptime { builtin.zig_backend == .stage2_arm or builtin.zig_backend == .stage2_riscv64 or builtin.zig_backend == .stage2_sparcv9 or - (builtin.zig_backend == .stage2_llvm and native_os != .linux) or - (builtin.zig_backend == .stage2_llvm and native_arch != .x86_64)) + (builtin.zig_backend == .stage2_llvm and native_os != .linux and native_os != .macos) or + (builtin.zig_backend == .stage2_llvm and native_arch != .x86_64 and native_arch != .aarch64)) { if (builtin.output_mode == .Exe) { if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { diff --git a/lib/std/target.zig b/lib/std/target.zig index 45a9c985b5..95fbd7e4e7 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -1718,8 +1718,17 @@ pub const Target = struct { } return switch (F) { f128 => switch (target.cpu.arch) { + .aarch64 => { + // According to Apple's official guide: + // > The long double type is a double precision IEEE754 binary floating-point type, + // > which makes it identical to the double type. This behavior contrasts to the + // > standard specification, in which a long double is a quad-precision, IEEE754 + // > binary, floating-point type. + // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms + return !target.isDarwin(); + }, + .riscv64, - .aarch64, .aarch64_be, .aarch64_32, .s390x, diff --git a/src/link.zig b/src/link.zig index dbef400189..2d7e577b70 100644 --- a/src/link.zig +++ b/src/link.zig @@ -352,11 +352,6 @@ pub const File = struct { } switch (base.tag) { .macho => if (base.file) |f| { - if (base.intermediary_basename != null) { - // The file we have open is not the final file that we want to - // make executable, so we don't have to close it. - return; - } if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) { if (base.options.target.cpu.arch == .aarch64) { // XNU starting with Big Sur running on arm64 is caching inodes of running binaries. @@ -371,8 +366,10 @@ pub const File = struct { try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{}); } } - f.close(); - base.file = null; + if (base.intermediary_basename == null) { + f.close(); + base.file = null; + } }, .coff, .elf, .plan9 => if (base.file) |f| { if (base.intermediary_basename != null) { diff --git a/src/link/MachO.zig b/src/link/MachO.zig index fa1ba2835a..a7437ed576 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -423,7 +423,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { if (self.base.options.emit == null) { if (build_options.have_llvm) { if (self.llvm_object) |llvm_object| { - return try llvm_object.flushModule(comp); + try llvm_object.flushModule(comp); } } return; @@ -1116,7 +1116,8 @@ pub fn flushObject(self: *MachO, comp: *Compilation) !void { defer tracy.end(); if (build_options.have_llvm) - if (self.llvm_object) |llvm_object| return llvm_object.flushModule(comp); + if (self.llvm_object) |llvm_object| + return llvm_object.flushModule(comp); return error.TODOImplementWritingObjFiles; } diff --git a/src/stage1/target.cpp b/src/stage1/target.cpp index 51aac6c072..7ff3008911 100644 --- a/src/stage1/target.cpp +++ b/src/stage1/target.cpp @@ -1008,8 +1008,16 @@ bool target_long_double_is_f128(const ZigTarget *target) { return false; } switch (target->arch) { - case ZigLLVM_riscv64: case ZigLLVM_aarch64: + // According to Apple's official guide: + // > The long double type is a double precision IEEE754 binary floating-point type, + // > which makes it identical to the double type. This behavior contrasts to the + // > standard specification, in which a long double is a quad-precision, IEEE754 + // > binary, floating-point type. + // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms + return !target_os_is_darwin(target->os); + + case ZigLLVM_riscv64: case ZigLLVM_aarch64_be: case ZigLLVM_aarch64_32: case ZigLLVM_systemz: diff --git a/src/type.zig b/src/type.zig index b087f7ab23..72cf2cd534 100644 --- a/src/type.zig +++ b/src/type.zig @@ -6155,7 +6155,6 @@ pub const CType = enum { }, .linux, - .macos, .freebsd, .netbsd, .dragonfly, @@ -6198,7 +6197,7 @@ pub const CType = enum { .longlong, .ulonglong, .longdouble => return 64, }, - .ios, .tvos, .watchos => switch (self) { + .macos, .ios, .tvos, .watchos => switch (self) { .short, .ushort => return 16, .int, .uint => return 32, .long, .ulong, .longlong, .ulonglong => return 64, diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 8793e7cb19..a1bd41e7b0 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -79,19 +79,16 @@ test "comptime_int @intToFloat" { try expect(result == 1234.0); } - if (!((builtin.zig_backend == .stage2_aarch64 or builtin.zig_backend == .stage2_x86_64) and builtin.os.tag == .macos)) { - // TODO investigate why this traps on x86_64-macos and aarch64-macos - { - const result = @intToFloat(f128, 1234); - try expect(@TypeOf(result) == f128); - try expect(result == 1234.0); - } - // big comptime_int (> 64 bits) to f128 conversion - { - const result = @intToFloat(f128, 0x1_0000_0000_0000_0000); - try expect(@TypeOf(result) == f128); - try expect(result == 0x1_0000_0000_0000_0000.0); - } + { + const result = @intToFloat(f128, 1234); + try expect(@TypeOf(result) == f128); + try expect(result == 1234.0); + } + // big comptime_int (> 64 bits) to f128 conversion + { + const result = @intToFloat(f128, 0x1_0000_0000_0000_0000); + try expect(@TypeOf(result) == f128); + try expect(result == 0x1_0000_0000_0000_0000.0); } }