Merge pull request #186575 from stephank/fix/compiler-rt-builtins

compiler-rt: build builtins on darwin

authored by 7c6f434c and committed by GitHub 711191ca d89b2002

+61 -32
+6 -6
pkgs/development/compilers/llvm/11/compiler-rt/default.nix
··· 1 - { lib, stdenv, llvm_meta, version, fetch, cmake, python3, libllvm, libcxxabi }: 2 3 let 4 ··· 15 inherit version; 16 src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy"; 17 18 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 19 20 NIX_CFLAGS_COMPILE = [ 21 "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" ··· 59 # extra `/`. 60 ./normalize-var.patch 61 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 62 - ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 - 64 65 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin '' 66 cmakeFlagsArray+=("-DCMAKE_LIPO=$(command -v ${stdenv.cc.targetPrefix}lipo)") ··· 75 substituteInPlace cmake/builtin-config-ix.cmake \ 76 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 77 '' + lib.optionalString stdenv.isDarwin '' 78 - substituteInPlace cmake/builtin-config-ix.cmake \ 79 - --replace 'foreach(arch ''${ARM64})' 'foreach(arch)' 80 substituteInPlace cmake/config-ix.cmake \ 81 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 82 '' + lib.optionalString (useLLVM) ''
··· 1 + { lib, stdenv, llvm_meta, version, fetch, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 3 let 4 ··· 15 inherit version; 16 src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy"; 17 18 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 19 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 20 21 NIX_CFLAGS_COMPILE = [ 22 "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" ··· 60 # extra `/`. 61 ./normalize-var.patch 62 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 63 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 64 + ./armv7l.patch 65 + ]; 66 67 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin '' 68 cmakeFlagsArray+=("-DCMAKE_LIPO=$(command -v ${stdenv.cc.targetPrefix}lipo)") ··· 77 substituteInPlace cmake/builtin-config-ix.cmake \ 78 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 79 '' + lib.optionalString stdenv.isDarwin '' 80 substituteInPlace cmake/config-ix.cmake \ 81 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 82 '' + lib.optionalString (useLLVM) ''
+6 -5
pkgs/development/compilers/llvm/12/compiler-rt/default.nix
··· 1 - { lib, stdenv, llvm_meta, version, fetch, cmake, python3, libllvm, libcxxabi }: 2 3 let 4 ··· 14 inherit version; 15 src = fetch "compiler-rt" "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"; 16 17 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 18 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 19 20 NIX_CFLAGS_COMPILE = [ ··· 59 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 60 # extra `/`. 61 ./normalize-var.patch 62 - ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 64 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 65 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 70 substituteInPlace cmake/builtin-config-ix.cmake \ 71 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 72 '' + lib.optionalString stdenv.isDarwin '' 73 - substituteInPlace cmake/builtin-config-ix.cmake \ 74 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 75 substituteInPlace cmake/config-ix.cmake \ 76 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 77 '' + lib.optionalString (useLLVM) ''
··· 1 + { lib, stdenv, llvm_meta, version, fetch, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 3 let 4 ··· 14 inherit version; 15 src = fetch "compiler-rt" "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"; 16 17 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 18 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 19 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 20 21 NIX_CFLAGS_COMPILE = [ ··· 60 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 61 # extra `/`. 62 ./normalize-var.patch 63 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 64 + ./armv7l.patch 65 + ]; 66 67 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 68 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 73 substituteInPlace cmake/builtin-config-ix.cmake \ 74 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 75 '' + lib.optionalString stdenv.isDarwin '' 76 substituteInPlace cmake/config-ix.cmake \ 77 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 78 '' + lib.optionalString (useLLVM) ''
+8 -7
pkgs/development/compilers/llvm/13/compiler-rt/default.nix
··· 1 - { lib, stdenv, llvm_meta, version, src, cmake, python3, libllvm, libcxxabi }: 2 3 let 4 ··· 16 inherit src; 17 sourceRoot = "source/compiler-rt"; 18 19 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 20 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 21 22 NIX_CFLAGS_COMPILE = [ ··· 62 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 63 # extra `/`. 64 ./normalize-var.patch 65 - ] # Prevent a compilation error on darwin 66 - ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 67 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 68 69 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 70 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 75 substituteInPlace cmake/builtin-config-ix.cmake \ 76 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 77 '' + lib.optionalString stdenv.isDarwin '' 78 - substituteInPlace cmake/builtin-config-ix.cmake \ 79 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 80 substituteInPlace cmake/config-ix.cmake \ 81 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 82 '' + lib.optionalString (useLLVM) ''
··· 1 + { lib, stdenv, llvm_meta, version, src, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 3 let 4 ··· 16 inherit src; 17 sourceRoot = "source/compiler-rt"; 18 19 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 20 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 21 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 22 23 NIX_CFLAGS_COMPILE = [ ··· 63 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 64 # extra `/`. 65 ./normalize-var.patch 66 + # Prevent a compilation error on darwin 67 + ./darwin-targetconditionals.patch 68 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 69 + ./armv7l.patch 70 + ]; 71 72 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 73 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 78 substituteInPlace cmake/builtin-config-ix.cmake \ 79 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 80 '' + lib.optionalString stdenv.isDarwin '' 81 substituteInPlace cmake/config-ix.cmake \ 82 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 83 '' + lib.optionalString (useLLVM) ''
+8 -7
pkgs/development/compilers/llvm/14/compiler-rt/default.nix
··· 1 { lib, stdenv, llvm_meta, version 2 , monorepoSrc, runCommand 3 - , cmake, python3, libllvm, libcxxabi 4 }: 5 6 let ··· 26 inherit src; 27 sourceRoot = "${src.name}/${baseName}"; 28 29 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 30 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 31 32 NIX_CFLAGS_COMPILE = [ ··· 73 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 74 # extra `/`. 75 ./normalize-var.patch 76 - ] # Prevent a compilation error on darwin 77 - ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 78 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 79 80 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 81 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 86 substituteInPlace cmake/builtin-config-ix.cmake \ 87 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 88 '' + lib.optionalString stdenv.isDarwin '' 89 - substituteInPlace cmake/builtin-config-ix.cmake \ 90 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 91 substituteInPlace cmake/config-ix.cmake \ 92 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 93 '' + lib.optionalString (useLLVM) ''
··· 1 { lib, stdenv, llvm_meta, version 2 , monorepoSrc, runCommand 3 + , cmake, python3, xcbuild, libllvm, libcxxabi 4 }: 5 6 let ··· 26 inherit src; 27 sourceRoot = "${src.name}/${baseName}"; 28 29 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 30 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 31 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 32 33 NIX_CFLAGS_COMPILE = [ ··· 74 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 75 # extra `/`. 76 ./normalize-var.patch 77 + # Prevent a compilation error on darwin 78 + ./darwin-targetconditionals.patch 79 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 80 + ./armv7l.patch 81 + ]; 82 83 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 84 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 89 substituteInPlace cmake/builtin-config-ix.cmake \ 90 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 91 '' + lib.optionalString stdenv.isDarwin '' 92 substituteInPlace cmake/config-ix.cmake \ 93 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 94 '' + lib.optionalString (useLLVM) ''
+25
pkgs/development/compilers/llvm/common/compiler-rt/darwin-plistbuddy-workaround.patch
···
··· 1 + CMake tries to read a list field from SDKSettings.plist, but the output of 2 + xcbuild PlistBuddy is incompatible with Apple's. (Plus we don't want it in our 3 + dependencies.) 4 + 5 + Simply assume ARM64 is supported by the SDK. We already limit the actual archs 6 + we build for by setting DARWIN_osx_BUILTIN_ARCHS explicitely. 7 + 8 + --- a/cmake/builtin-config-ix.cmake 9 + +++ b/cmake/builtin-config-ix.cmake 10 + @@ -97,14 +97,7 @@ if(APPLE) 11 + set(DARWIN_osx_BUILTIN_MIN_VER 10.5) 12 + set(DARWIN_osx_BUILTIN_MIN_VER_FLAG 13 + -mmacosx-version-min=${DARWIN_osx_BUILTIN_MIN_VER}) 14 + - set(DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64}) 15 + - # Add support for arm64 macOS if available in SDK. 16 + - foreach(arch ${ARM64}) 17 + - sdk_has_arch_support(${DARWIN_osx_SYSROOT} macosx ${arch} MACOS_ARM_SUPPORT) 18 + - if (MACOS_ARM_SUPPORT) 19 + - list(APPEND DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS ${arch}) 20 + - endif() 21 + - endforeach(arch) 22 + + set(DARWIN_osx_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64} ${ARM64}) 23 + 24 + if(COMPILER_RT_ENABLE_IOS) 25 + list(APPEND DARWIN_EMBEDDED_PLATFORMS ios)
+8 -7
pkgs/development/compilers/llvm/git/compiler-rt/default.nix
··· 1 { lib, stdenv, llvm_meta, version 2 , monorepoSrc, runCommand 3 - , cmake, python3, libllvm, libcxxabi 4 }: 5 6 let ··· 26 inherit src; 27 sourceRoot = "${src.name}/${baseName}"; 28 29 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 30 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 31 32 NIX_CFLAGS_COMPILE = [ ··· 71 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 72 # extra `/`. 73 ./normalize-var.patch 74 - ] # Prevent a compilation error on darwin 75 - ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 76 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 77 78 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 79 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 84 substituteInPlace cmake/builtin-config-ix.cmake \ 85 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 86 '' + lib.optionalString stdenv.isDarwin '' 87 - substituteInPlace cmake/builtin-config-ix.cmake \ 88 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 89 substituteInPlace cmake/config-ix.cmake \ 90 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 91 '' + lib.optionalString (useLLVM) ''
··· 1 { lib, stdenv, llvm_meta, version 2 , monorepoSrc, runCommand 3 + , cmake, python3, xcbuild, libllvm, libcxxabi 4 }: 5 6 let ··· 26 inherit src; 27 sourceRoot = "${src.name}/${baseName}"; 28 29 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 30 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 31 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 32 33 NIX_CFLAGS_COMPILE = [ ··· 72 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 73 # extra `/`. 74 ./normalize-var.patch 75 + # Prevent a compilation error on darwin 76 + ./darwin-targetconditionals.patch 77 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 78 + ./armv7l.patch 79 + ]; 80 81 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 82 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 87 substituteInPlace cmake/builtin-config-ix.cmake \ 88 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 89 '' + lib.optionalString stdenv.isDarwin '' 90 substituteInPlace cmake/config-ix.cmake \ 91 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 92 '' + lib.optionalString (useLLVM) ''