Jakub Konka 5b813f1a2a 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.
2022-05-22 17:45:02 +02:00

120 lines
3.8 KiB
C
Vendored

#ifndef __XPC_AVAILABILITY_H__
#define __XPC_AVAILABILITY_H__
#include <Availability.h>
// Certain parts of the project use all the project's headers but have to build
// against newer OSX SDKs than ebuild uses -- liblaunch_host being the example.
// So we need to define these.
#ifndef __MAC_10_15
#define __MAC_10_15 101500
#define __AVAILABILITY_INTERNAL__MAC_10_15 \
__attribute__((availability(macosx, introduced=10.15)))
#endif // __MAC_10_15
#ifndef __MAC_10_14
#define __MAC_10_14 101400
#define __AVAILABILITY_INTERNAL__MAC_10_14 \
__attribute__((availability(macosx, introduced=10.14)))
#endif // __MAC_10_14
#ifndef __MAC_10_13
#define __MAC_10_13 101300
#define __AVAILABILITY_INTERNAL__MAC_10_13 \
__attribute__((availability(macosx, introduced=10.13)))
#endif // __MAC_10_13
#ifndef __MAC_10_12
#define __MAC_10_12 101200
#define __AVAILABILITY_INTERNAL__MAC_10_12 \
__attribute__((availability(macosx, introduced=10.12)))
#endif // __MAC_10_12
#ifndef __MAC_10_11
#define __MAC_10_11 101100
#define __AVAILABILITY_INTERNAL__MAC_10_11 \
__attribute__((availability(macosx, introduced=10.11)))
#endif // __MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
#define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
#endif // __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
#if __has_include(<simulator_host.h>)
#include <simulator_host.h>
#else // __has_include(<simulator_host.h>)
#ifndef IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
#define IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED 999999
#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
#endif // __has_include(<simulator_host.h>)
#ifndef __WATCHOS_UNAVAILABLE
#define __WATCHOS_UNAVAILABLE
#endif
#ifndef __TVOS_UNAVAILABLE
#define __TVOS_UNAVAILABLE
#endif
// simulator host-side bits build against SDKs not having __*_AVAILABLE() yet
#ifndef __OSX_AVAILABLE
#define __OSX_AVAILABLE(...)
#endif
#ifndef __IOS_AVAILABLE
#define __IOS_AVAILABLE(...)
#endif
#ifndef __TVOS_AVAILABLE
#define __TVOS_AVAILABLE(...)
#endif
#ifndef __WATCHOS_AVAILABLE
#define __WATCHOS_AVAILABLE(...)
#endif
#ifndef __API_AVAILABLE
#define __API_AVAILABLE(...)
#endif
#endif // __XPC_AVAILABILITY_H__