From 03137b50d2e44e4649e505a429deac7272c3084f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 17 Jun 2021 11:01:16 -0400 Subject: [PATCH 1/2] darwin.Libsystem: add definitions TARGET_OS_{IOS,WATCH,BRIDGE,TV,SIMULATOR,NANO} to TargetConditionals.h These are defined in the SDK for Apple compilers and some projects assume those are defined unconditionally. https://reviews.llvm.org/D103598 --- .../darwin/apple-source-releases/Libsystem/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix index cb85566b5128..66190b7b4e37 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix @@ -69,7 +69,13 @@ appleDerivation' stdenv { #define TARGET_OS_UNIX 0 #define TARGET_OS_EMBEDDED 0 #define TARGET_OS_IPHONE 0 + #define TARGET_OS_IOS 0 + #define TARGET_OS_WATCH 0 + #define TARGET_OS_BRIDGE 0 + #define TARGET_OS_TV 0 + #define TARGET_OS_SIMULATOR 0 #define TARGET_IPHONE_SIMULATOR 0 + #define TARGET_OS_NANO 0 #define TARGET_OS_LINUX 0 #define TARGET_CPU_PPC 0 From 4c483076c5658911dc9860bef15c19da29a0248f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 17 Jun 2021 11:04:04 -0400 Subject: [PATCH 2/2] Revert "llvmPackages_12.compiler-rt: fix build on darwin" This is not needed after we've added the defintions to the TargetConditionals.h from darwin.Libsystem This reverts commit cf4e1b9e62ab987552eb676f7618ea085f12a751. --- .../darwin-targetconditionals.patch | 71 ------------------- .../compilers/llvm/12/compiler-rt/default.nix | 2 - 2 files changed, 73 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/12/compiler-rt/darwin-targetconditionals.patch diff --git a/pkgs/development/compilers/llvm/12/compiler-rt/darwin-targetconditionals.patch b/pkgs/development/compilers/llvm/12/compiler-rt/darwin-targetconditionals.patch deleted file mode 100644 index 425dc2af01e7..000000000000 --- a/pkgs/development/compilers/llvm/12/compiler-rt/darwin-targetconditionals.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp ---- a/lib/sanitizer_common/sanitizer_mac.cpp -+++ b/lib/sanitizer_common/sanitizer_mac.cpp -@@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) { - // Offset example: - // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4 - constexpr u16 GetOSMajorKernelOffset() { -- if (TARGET_OS_OSX) return 4; -- if (TARGET_OS_IOS || TARGET_OS_TV) return 6; -- if (TARGET_OS_WATCH) return 13; -+#if TARGET_OS_OSX -+ return 4; -+#endif -+#if TARGET_OS_IOS || TARGET_OS_TV -+ return 6; -+#endif -+#if TARGET_OS_WATCH -+ return 13; -+#endif - } - - using VersStr = char[64]; -@@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) { - u16 os_major = kernel_major - offset; - - const char *format = "%d.0"; -- if (TARGET_OS_OSX) { -- if (os_major >= 16) { // macOS 11+ -- os_major -= 5; -- } else { // macOS 10.15 and below -- format = "10.%d"; -- } -+#if TARGET_OS_OSX -+ if (os_major >= 16) { // macOS 11+ -+ os_major -= 5; -+ } else { // macOS 10.15 and below -+ format = "10.%d"; - } -+#endif - return internal_snprintf(vers, sizeof(VersStr), format, os_major); - } - -@@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) { - // Aligned versions example: - // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6 - static void MapToMacos(u16 *major, u16 *minor) { -- if (TARGET_OS_OSX) -- return; -- -- if (TARGET_OS_IOS || TARGET_OS_TV) -+#if !TARGET_OS_OSX -+#if TARGET_OS_IOS || TARGET_OS_TV - *major += 2; -- else if (TARGET_OS_WATCH) -+#elif TARGET_OS_WATCH - *major += 9; -- else -+#else - UNREACHABLE("unsupported platform"); -+#endif - - if (*major >= 16) { // macOS 11+ - *major -= 5; -@@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) { - *minor = *major; - *major = 10; - } -+#endif - } - - static MacosVersion GetMacosAlignedVersionInternal() { diff --git a/pkgs/development/compilers/llvm/12/compiler-rt/default.nix b/pkgs/development/compilers/llvm/12/compiler-rt/default.nix index cde1317ca35d..895af8f2f020 100644 --- a/pkgs/development/compilers/llvm/12/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/12/compiler-rt/default.nix @@ -59,8 +59,6 @@ stdenv.mkDerivation { # extra `/`. ./normalize-var.patch ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch - # Prevent a compilation error on darwin - ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks