authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-16 18:07:02+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-04-16 18:07:02+02:00
log8f75823728d247bc11d916b7257d7eebc7be06de
treec75f34334db2fba833ae91f2ae7a52f9cbd546c8
parenta315d51c0a0c8eda2467c5571f9d7e2495274dbd
parent897df18573c951b49fb6421a9e1b711cabfeda67
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11446 from ziglang/aarch64-macos-llvm

stage2: fix behavior test failures on aarch64-macos (LLVM+native), and other minor fixes

7 files changed, 39 insertions(+), 28 deletions(-)

lib/std/start.zig+2-2
...@@ -30,8 +30,8 @@ comptime {...@@ -30,8 +30,8 @@ comptime {
30 builtin.zig_backend == .stage2_arm or30 builtin.zig_backend == .stage2_arm or
31 builtin.zig_backend == .stage2_riscv64 or31 builtin.zig_backend == .stage2_riscv64 or
32 builtin.zig_backend == .stage2_sparcv9 or32 builtin.zig_backend == .stage2_sparcv9 or
33 (builtin.zig_backend == .stage2_llvm and native_os != .linux) or33 (builtin.zig_backend == .stage2_llvm and native_os != .linux and native_os != .macos) or
34 (builtin.zig_backend == .stage2_llvm and native_arch != .x86_64))34 (builtin.zig_backend == .stage2_llvm and native_arch != .x86_64 and native_arch != .aarch64))
35 {35 {
36 if (builtin.output_mode == .Exe) {36 if (builtin.output_mode == .Exe) {
37 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {37 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
lib/std/target.zig+10-1
...@@ -1718,8 +1718,17 @@ pub const Target = struct {...@@ -1718,8 +1718,17 @@ pub const Target = struct {
1718 }1718 }
1719 return switch (F) {1719 return switch (F) {
1720 f128 => switch (target.cpu.arch) {1720 f128 => switch (target.cpu.arch) {
1721 .aarch64 => {
1722 // According to Apple's official guide:
1723 // > The long double type is a double precision IEEE754 binary floating-point type,
1724 // > which makes it identical to the double type. This behavior contrasts to the
1725 // > standard specification, in which a long double is a quad-precision, IEEE754
1726 // > binary, floating-point type.
1727 // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
1728 return !target.isDarwin();
1729 },
1730
1721 .riscv64,1731 .riscv64,
1722 .aarch64,
1723 .aarch64_be,1732 .aarch64_be,
1724 .aarch64_32,1733 .aarch64_32,
1725 .s390x,1734 .s390x,
src/link.zig+4-7
...@@ -352,11 +352,6 @@ pub const File = struct {...@@ -352,11 +352,6 @@ pub const File = struct {
352 }352 }
353 switch (base.tag) {353 switch (base.tag) {
354 .macho => if (base.file) |f| {354 .macho => if (base.file) |f| {
355 if (base.intermediary_basename != null) {
356 // The file we have open is not the final file that we want to
357 // make executable, so we don't have to close it.
358 return;
359 }
360 if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) {355 if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) {
361 if (base.options.target.cpu.arch == .aarch64) {356 if (base.options.target.cpu.arch == .aarch64) {
362 // XNU starting with Big Sur running on arm64 is caching inodes of running binaries.357 // XNU starting with Big Sur running on arm64 is caching inodes of running binaries.
...@@ -371,8 +366,10 @@ pub const File = struct {...@@ -371,8 +366,10 @@ pub const File = struct {
371 try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{});366 try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{});
372 }367 }
373 }368 }
374 f.close();369 if (base.intermediary_basename == null) {
375 base.file = null;370 f.close();
371 base.file = null;
372 }
376 },373 },
377 .coff, .elf, .plan9 => if (base.file) |f| {374 .coff, .elf, .plan9 => if (base.file) |f| {
378 if (base.intermediary_basename != null) {375 if (base.intermediary_basename != null) {
src/link/MachO.zig+3-2
...@@ -423,7 +423,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {...@@ -423,7 +423,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {
423 if (self.base.options.emit == null) {423 if (self.base.options.emit == null) {
424 if (build_options.have_llvm) {424 if (build_options.have_llvm) {
425 if (self.llvm_object) |llvm_object| {425 if (self.llvm_object) |llvm_object| {
426 return try llvm_object.flushModule(comp);426 try llvm_object.flushModule(comp);
427 }427 }
428 }428 }
429 return;429 return;
...@@ -1116,7 +1116,8 @@ pub fn flushObject(self: *MachO, comp: *Compilation) !void {...@@ -1116,7 +1116,8 @@ pub fn flushObject(self: *MachO, comp: *Compilation) !void {
1116 defer tracy.end();1116 defer tracy.end();
11171117
1118 if (build_options.have_llvm)1118 if (build_options.have_llvm)
1119 if (self.llvm_object) |llvm_object| return llvm_object.flushModule(comp);1119 if (self.llvm_object) |llvm_object|
1120 return llvm_object.flushModule(comp);
11201121
1121 return error.TODOImplementWritingObjFiles;1122 return error.TODOImplementWritingObjFiles;
1122}1123}
src/stage1/target.cpp+9-1
...@@ -1008,8 +1008,16 @@ bool target_long_double_is_f128(const ZigTarget *target) {...@@ -1008,8 +1008,16 @@ bool target_long_double_is_f128(const ZigTarget *target) {
1008 return false;1008 return false;
1009 }1009 }
1010 switch (target->arch) {1010 switch (target->arch) {
1011 case ZigLLVM_riscv64:
1012 case ZigLLVM_aarch64:1011 case ZigLLVM_aarch64:
1012 // According to Apple's official guide:
1013 // > The long double type is a double precision IEEE754 binary floating-point type,
1014 // > which makes it identical to the double type. This behavior contrasts to the
1015 // > standard specification, in which a long double is a quad-precision, IEEE754
1016 // > binary, floating-point type.
1017 // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
1018 return !target_os_is_darwin(target->os);
1019
1020 case ZigLLVM_riscv64:
1013 case ZigLLVM_aarch64_be:1021 case ZigLLVM_aarch64_be:
1014 case ZigLLVM_aarch64_32:1022 case ZigLLVM_aarch64_32:
1015 case ZigLLVM_systemz:1023 case ZigLLVM_systemz:
src/type.zig+1-2
...@@ -6155,7 +6155,6 @@ pub const CType = enum {...@@ -6155,7 +6155,6 @@ pub const CType = enum {
6155 },6155 },
61566156
6157 .linux,6157 .linux,
6158 .macos,
6159 .freebsd,6158 .freebsd,
6160 .netbsd,6159 .netbsd,
6161 .dragonfly,6160 .dragonfly,
...@@ -6198,7 +6197,7 @@ pub const CType = enum {...@@ -6198,7 +6197,7 @@ pub const CType = enum {
6198 .longlong, .ulonglong, .longdouble => return 64,6197 .longlong, .ulonglong, .longdouble => return 64,
6199 },6198 },
62006199
6201 .ios, .tvos, .watchos => switch (self) {6200 .macos, .ios, .tvos, .watchos => switch (self) {
6202 .short, .ushort => return 16,6201 .short, .ushort => return 16,
6203 .int, .uint => return 32,6202 .int, .uint => return 32,
6204 .long, .ulong, .longlong, .ulonglong => return 64,6203 .long, .ulong, .longlong, .ulonglong => return 64,
test/behavior/cast.zig+10-13
...@@ -79,19 +79,16 @@ test "comptime_int @intToFloat" {...@@ -79,19 +79,16 @@ test "comptime_int @intToFloat" {
79 try expect(result == 1234.0);79 try expect(result == 1234.0);
80 }80 }
8181
82 if (!((builtin.zig_backend == .stage2_aarch64 or builtin.zig_backend == .stage2_x86_64) and builtin.os.tag == .macos)) {82 {
83 // TODO investigate why this traps on x86_64-macos and aarch64-macos83 const result = @intToFloat(f128, 1234);
84 {84 try expect(@TypeOf(result) == f128);
85 const result = @intToFloat(f128, 1234);85 try expect(result == 1234.0);
86 try expect(@TypeOf(result) == f128);86 }
87 try expect(result == 1234.0);87 // big comptime_int (> 64 bits) to f128 conversion
88 }88 {
89 // big comptime_int (> 64 bits) to f128 conversion89 const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);
90 {90 try expect(@TypeOf(result) == f128);
91 const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);91 try expect(result == 0x1_0000_0000_0000_0000.0);
92 try expect(@TypeOf(result) == f128);
93 try expect(result == 0x1_0000_0000_0000_0000.0);
94 }
95 }92 }
96}93}
9794