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 }: 1 + { lib, stdenv, llvm_meta, version, fetch, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 2 3 3 let 4 4 ··· 15 15 inherit version; 16 16 src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy"; 17 17 18 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 18 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 19 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 19 20 20 21 NIX_CFLAGS_COMPILE = [ 21 22 "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" ··· 59 60 # extra `/`. 60 61 ./normalize-var.patch 61 62 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 62 - ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 - 63 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 64 + ./armv7l.patch 65 + ]; 64 66 65 67 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin '' 66 68 cmakeFlagsArray+=("-DCMAKE_LIPO=$(command -v ${stdenv.cc.targetPrefix}lipo)") ··· 75 77 substituteInPlace cmake/builtin-config-ix.cmake \ 76 78 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 77 79 '' + lib.optionalString stdenv.isDarwin '' 78 - substituteInPlace cmake/builtin-config-ix.cmake \ 79 - --replace 'foreach(arch ''${ARM64})' 'foreach(arch)' 80 80 substituteInPlace cmake/config-ix.cmake \ 81 81 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 82 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 }: 1 + { lib, stdenv, llvm_meta, version, fetch, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 2 3 3 let 4 4 ··· 14 14 inherit version; 15 15 src = fetch "compiler-rt" "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"; 16 16 17 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 17 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 18 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 18 19 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 19 20 20 21 NIX_CFLAGS_COMPILE = [ ··· 59 60 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 60 61 # extra `/`. 61 62 ./normalize-var.patch 62 - ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 64 + ./armv7l.patch 65 + ]; 63 66 64 67 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 65 68 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 70 73 substituteInPlace cmake/builtin-config-ix.cmake \ 71 74 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 72 75 '' + lib.optionalString stdenv.isDarwin '' 73 - substituteInPlace cmake/builtin-config-ix.cmake \ 74 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 75 76 substituteInPlace cmake/config-ix.cmake \ 76 77 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 77 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 }: 1 + { lib, stdenv, llvm_meta, version, src, cmake, python3, xcbuild, libllvm, libcxxabi }: 2 2 3 3 let 4 4 ··· 16 16 inherit src; 17 17 sourceRoot = "source/compiler-rt"; 18 18 19 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 19 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 20 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 20 21 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 21 22 22 23 NIX_CFLAGS_COMPILE = [ ··· 62 63 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 63 64 # extra `/`. 64 65 ./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; 66 + # Prevent a compilation error on darwin 67 + ./darwin-targetconditionals.patch 68 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 69 + ./armv7l.patch 70 + ]; 68 71 69 72 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 70 73 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 75 78 substituteInPlace cmake/builtin-config-ix.cmake \ 76 79 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 77 80 '' + lib.optionalString stdenv.isDarwin '' 78 - substituteInPlace cmake/builtin-config-ix.cmake \ 79 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 80 81 substituteInPlace cmake/config-ix.cmake \ 81 82 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 82 83 '' + lib.optionalString (useLLVM) ''
+8 -7
pkgs/development/compilers/llvm/14/compiler-rt/default.nix
··· 1 1 { lib, stdenv, llvm_meta, version 2 2 , monorepoSrc, runCommand 3 - , cmake, python3, libllvm, libcxxabi 3 + , cmake, python3, xcbuild, libllvm, libcxxabi 4 4 }: 5 5 6 6 let ··· 26 26 inherit src; 27 27 sourceRoot = "${src.name}/${baseName}"; 28 28 29 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 29 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 30 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 30 31 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 31 32 32 33 NIX_CFLAGS_COMPILE = [ ··· 73 74 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 74 75 # extra `/`. 75 76 ./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; 77 + # Prevent a compilation error on darwin 78 + ./darwin-targetconditionals.patch 79 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 80 + ./armv7l.patch 81 + ]; 79 82 80 83 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 81 84 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 86 89 substituteInPlace cmake/builtin-config-ix.cmake \ 87 90 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 88 91 '' + lib.optionalString stdenv.isDarwin '' 89 - substituteInPlace cmake/builtin-config-ix.cmake \ 90 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 91 92 substituteInPlace cmake/config-ix.cmake \ 92 93 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 93 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 1 { lib, stdenv, llvm_meta, version 2 2 , monorepoSrc, runCommand 3 - , cmake, python3, libllvm, libcxxabi 3 + , cmake, python3, xcbuild, libllvm, libcxxabi 4 4 }: 5 5 6 6 let ··· 26 26 inherit src; 27 27 sourceRoot = "${src.name}/${baseName}"; 28 28 29 - nativeBuildInputs = [ cmake python3 libllvm.dev ]; 29 + nativeBuildInputs = [ cmake python3 libllvm.dev ] 30 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 30 31 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 31 32 32 33 NIX_CFLAGS_COMPILE = [ ··· 71 72 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 72 73 # extra `/`. 73 74 ./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; 75 + # Prevent a compilation error on darwin 76 + ./darwin-targetconditionals.patch 77 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 78 + ./armv7l.patch 79 + ]; 77 80 78 81 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 79 82 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 84 87 substituteInPlace cmake/builtin-config-ix.cmake \ 85 88 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 86 89 '' + lib.optionalString stdenv.isDarwin '' 87 - substituteInPlace cmake/builtin-config-ix.cmake \ 88 - --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 89 90 substituteInPlace cmake/config-ix.cmake \ 90 91 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 91 92 '' + lib.optionalString (useLLVM) ''