Merge #242202: cctools-llvm: use cctools assembler on LLVM 11 and x86_64-darwin

...into staging-next
This commit is contained in:
Vladimír Čunát 2023-07-11 15:51:56 +02:00
commit b3d701e089
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA
2 changed files with 8 additions and 6 deletions

View File

@ -244,11 +244,6 @@ let
++ lib.optionals (langD) [
"--with-target-system-zlib=yes"
]
# Clang 11 performs an optimization on x86_64 that is sensitive to the presence of debug info.
# This causes GCC to fail to bootstrap due to object file differences between stages 2 and 3.
++ lib.optionals (targetPlatform.isDarwin && targetPlatform.isx86_64) [
"--with-as=${targetPackages.darwin.cctools-port}/bin/${targetPrefix}as"
]
;
in configureFlags

View File

@ -20,6 +20,10 @@ let
# not appear to have issues, but the source is not available yet (as of June 2023).
useLLVMStrip = lib.versionAtLeast llvmVersion "15" || lib.versionAtLeast cctoolsVersion "1005.2";
# Clang 11 performs an optimization on x86_64 that is sensitive to the presence of debug info.
# This causes GCC to fail to bootstrap due to object file differences between stages 2 and 3.
useClangAssembler = lib.versionAtLeast llvmVersion "12" || !stdenv.isx86_64;
llvm_bins = [
"dwarfdump"
"nm"
@ -52,7 +56,8 @@ let
]
++ lib.optional (!useLLVMBitcodeStrip) "bitcode_strip"
++ lib.optional (!useLLVMOtool) "otool"
++ lib.optional (!useLLVMStrip) "strip";
++ lib.optional (!useLLVMStrip) "strip"
++ lib.optional (!useClangAssembler) "as";
targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
@ -79,10 +84,12 @@ stdenv.mkDerivation {
mkdir -p "$out/bin" "$man"
ln -s ${lib.getDev cctools-port} "$dev"
'' + lib.optionalString useClangAssembler ''
# Use the clang-integrated assembler instead of using `as` from cctools.
makeWrapper "${lib.getBin llvmPackages.clang-unwrapped}/bin/clang" "$out/bin/${targetPrefix}as" \
--add-flags "-x assembler -integrated-as -c"
'' + ''
ln -s "${lib.getBin llvmPackages.bintools-unwrapped}/bin/${targetPrefix}llvm-ar" "$out/bin/${targetPrefix}ar"
${linkManPages llvmPackages.llvm-manpages "llvm-ar" "ar"}