aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-05-15 11:17:20 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-05-22 17:45:02 +0200
commit5b813f1a2acdc1668e39008b02a234f3da724552 (patch)
treeeabcb979be04296d5bec8c6f4947dc2dd8621731 /src
parent9747303d16dfca61316a292d1e05ac901191e3a3 (diff)
downloadzig-5b813f1a2acdc1668e39008b02a234f3da724552.tar.gz
zig-5b813f1a2acdc1668e39008b02a234f3da724552.zip
Set macOS/iPhoneOS/tvOS/watchOS ABI to none (unspecified) by default
Prior to this change we would assume the ABI for Apple targets to be GNU which could result in subtle errors in LLVM emitting calls to non-existent system libc provided functions such as `_sincosf` which is a GNU extension and as such is not provided by macOS for example. This would result in linker errors where the linker would not be able to find the said symbol in `libSystem.tbd`. With this change, we now correctly identify macOS (and other Apple platforms) as having ABI `unknown` which translates to unspecified in LLVM under-the-hood: ``` // main.ll target triple = "aarch64-unknown-macos-unknown" ``` Note however that we never suffix the target OS with target version such as `macos11` or `macos12` which means we fail to instruct LLVM of potential optimisations provided by the OS such as the availability of function `___sincosf_stret`. I suggest we investigate that in a follow-up commit.
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig2
-rw-r--r--src/link/MachO/Dylib.zig2
-rw-r--r--src/stage1/target.cpp8
-rw-r--r--src/target.zig10
4 files changed, 11 insertions, 11 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 7ac1e49196..2c15cb95a3 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -4289,7 +4289,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8,
list[0] = try std.fmt.allocPrint(
arena,
- "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-gnu",
+ "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-none",
.{ zig_lib_dir, arch_name, os_name },
);
list[1] = try std.fmt.allocPrint(
diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig
index 57c8238827..b8b8f50e67 100644
--- a/src/link/MachO/Dylib.zig
+++ b/src/link/MachO/Dylib.zig
@@ -303,7 +303,7 @@ const TargetMatcher = struct {
};
const os = @tagName(target.os.tag);
const abi: ?[]const u8 = switch (target.abi) {
- .gnu => null,
+ .none => null,
.simulator => "simulator",
else => unreachable,
};
diff --git a/src/stage1/target.cpp b/src/stage1/target.cpp
index da6565f0be..81377b5d49 100644
--- a/src/stage1/target.cpp
+++ b/src/stage1/target.cpp
@@ -971,11 +971,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
case OsOther:
return ZigLLVM_EABI;
case OsOpenBSD:
- case OsMacOSX:
case OsFreeBSD:
- case OsIOS:
- case OsTvOS:
- case OsWatchOS:
case OsFuchsia:
case OsKFreeBSD:
case OsNetBSD:
@@ -994,6 +990,10 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
case OsGLSL450:
case OsVulkan:
case OsPlan9:
+ case OsMacOSX:
+ case OsIOS:
+ case OsTvOS:
+ case OsWatchOS:
return ZigLLVM_UnknownEnvironment;
}
zig_unreachable();
diff --git a/src/target.zig b/src/target.zig
index c794ea52b0..14af2675d2 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -16,8 +16,8 @@ pub const available_libcs = [_]ArchOsAbi{
.{ .arch = .aarch64, .os = .linux, .abi = .gnu },
.{ .arch = .aarch64, .os = .linux, .abi = .musl },
.{ .arch = .aarch64, .os = .windows, .abi = .gnu },
- .{ .arch = .aarch64, .os = .macos, .abi = .gnu, .os_ver = .{ .major = 11, .minor = 0 } },
- .{ .arch = .aarch64, .os = .macos, .abi = .gnu, .os_ver = .{ .major = 12, .minor = 0 } },
+ .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0 } },
+ .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0 } },
.{ .arch = .armeb, .os = .linux, .abi = .gnueabi },
.{ .arch = .armeb, .os = .linux, .abi = .gnueabihf },
.{ .arch = .armeb, .os = .linux, .abi = .musleabi },
@@ -70,9 +70,9 @@ pub const available_libcs = [_]ArchOsAbi{
.{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },
.{ .arch = .x86_64, .os = .linux, .abi = .musl },
.{ .arch = .x86_64, .os = .windows, .abi = .gnu },
- .{ .arch = .x86_64, .os = .macos, .abi = .gnu, .os_ver = .{ .major = 10, .minor = 0 } },
- .{ .arch = .x86_64, .os = .macos, .abi = .gnu, .os_ver = .{ .major = 11, .minor = 0 } },
- .{ .arch = .x86_64, .os = .macos, .abi = .gnu, .os_ver = .{ .major = 12, .minor = 0 } },
+ .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 10, .minor = 0 } },
+ .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0 } },
+ .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0 } },
};
pub fn libCGenericName(target: std.Target) [:0]const u8 {