mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-22 13:08:39 +03:00
cctools: support LTO on Darwin
LTO is disabled during bootstrap to keep the bootstrap tools small and avoid unnecessary LLVM rebuilds, but is enabled in the final stdenv stage and should be usable by normal packages.
This commit is contained in:
parent
b91ad0e54f
commit
110c252870
@ -119,12 +119,14 @@ in stdenv.mkDerivation (rec {
|
||||
+ stdenv.lib.optionalString enableSharedLibraries ''
|
||||
moveToOutput "lib/libLLVM-*" "$lib"
|
||||
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
|
||||
moveToOutput "lib/libLTO${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
|
||||
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
|
||||
''
|
||||
+ stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
|
||||
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" \
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/libLTO.dylib" "$lib/lib/libLTO.dylib"
|
||||
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
|
||||
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
|
||||
'';
|
||||
|
@ -1,8 +1,6 @@
|
||||
{ cctools, appleDerivation }:
|
||||
{ appleDerivation }:
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ cctools ];
|
||||
|
||||
patches = [ ./clang-5.patch ];
|
||||
|
||||
postPatch = ''
|
||||
|
@ -215,7 +215,7 @@ let
|
||||
|
||||
# Splicing is currently broken in Nixpkgs
|
||||
# cctools need to be specified manually here to handle this
|
||||
ICU = applePackage "ICU" "osx-10.10.5" "1qihlp42n5g4dl0sn0f9pc0bkxy1452dxzf0vr6y5gqpshlzy03p" { inherit (buildPackages.darwin) cctools; };
|
||||
ICU = applePackage "ICU" "osx-10.10.5" "1qihlp42n5g4dl0sn0f9pc0bkxy1452dxzf0vr6y5gqpshlzy03p" {};
|
||||
|
||||
IOKit = applePackage "IOKit" "osx-10.11.6" "0kcbrlyxcyirvg5p95hjd9k8a01k161zg0bsfgfhkb90kh2s8x00" { inherit IOKitSrcs; };
|
||||
launchd = applePackage "launchd" "osx-10.9.5" "0w30hvwqq8j5n90s3qyp0fccxflvrmmjnicjri4i1vd2g196jdgj" {};
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ stdenv, fetchFromGitHub, autoconf, automake, libtool_2, autoreconfHook
|
||||
, libcxxabi, libuuid
|
||||
, libcxxabi, libuuid, llvm
|
||||
, libobjc ? null, maloader ? null
|
||||
, enableDumpNormalizedLibArgs ? false
|
||||
}:
|
||||
@ -56,7 +56,7 @@ let
|
||||
autoreconfHook
|
||||
];
|
||||
buildInputs = [ libuuid ] ++
|
||||
stdenv.lib.optionals stdenv.isDarwin [ libcxxabi libobjc ];
|
||||
stdenv.lib.optionals stdenv.isDarwin [ llvm libcxxabi libobjc ];
|
||||
|
||||
patches = [
|
||||
./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch
|
||||
|
@ -201,6 +201,7 @@ in rec {
|
||||
python2 = self.python;
|
||||
|
||||
ninja = super.ninja.override { buildDocs = false; };
|
||||
darwin = super.darwin // { cctools = super.darwin.cctools.override { llvm = null; }; };
|
||||
};
|
||||
in with prevStage; stageFun 1 prevStage {
|
||||
extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
|
||||
|
@ -12,6 +12,10 @@ in rec {
|
||||
singleBinary = false;
|
||||
});
|
||||
|
||||
# We want a version of cctools without LLVM, because the LTO support ends up making
|
||||
# the bootstrap tools huge and isn't really necessary for bootstrap
|
||||
cctools_ = darwin.cctools.override { llvm = null; };
|
||||
|
||||
# Avoid debugging larger changes for now.
|
||||
bzip2_ = bzip2.override (args: { linkStatic = true; });
|
||||
|
||||
@ -95,7 +99,7 @@ in rec {
|
||||
|
||||
# Copy binutils.
|
||||
for i in as ld ar ranlib nm strip otool install_name_tool dsymutil lipo; do
|
||||
cp ${darwin.cctools}/bin/$i $out/bin
|
||||
cp ${cctools_}/bin/$i $out/bin
|
||||
done
|
||||
|
||||
cp -rd ${pkgs.darwin.CF}/Library $out
|
||||
@ -105,9 +109,9 @@ in rec {
|
||||
nuke-refs $out/bin/*
|
||||
|
||||
rpathify() {
|
||||
local libs=$(${darwin.cctools}/bin/otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
|
||||
local libs=$(${cctools_}/bin/otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
|
||||
for lib in $libs; do
|
||||
${darwin.cctools}/bin/install_name_tool -change $lib "@rpath/$(basename $lib)" "$1"
|
||||
${cctools_}/bin/install_name_tool -change $lib "@rpath/$(basename $lib)" "$1"
|
||||
done
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user