diff options
Diffstat (limited to 'nixpkgs/pkgs/build-support/bintools-wrapper/default.nix')
-rw-r--r-- | nixpkgs/pkgs/build-support/bintools-wrapper/default.nix | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix index 859e37905949..5d2f2f977a70 100644 --- a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix +++ b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix @@ -9,11 +9,28 @@ , lib , stdenvNoCC , bintools ? null, libc ? null, coreutils ? null, shell ? stdenvNoCC.shell, gnugrep ? null +, netbsd ? null, netbsdCross ? null +, sharedLibraryLoader ? + if libc == null then + null + else if stdenvNoCC.targetPlatform.isNetBSD then + if !(targetPackages ? netbsdCross) then + netbsd.ld_elf_so + else if libc != targetPackages.netbsdCross.headers then + targetPackages.netbsdCross.ld_elf_so + else + null + else + lib.getLib libc , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" , propagateDoc ? bintools != null && bintools ? man , extraPackages ? [], extraBuildCommands ? "" , buildPackages ? {} +, targetPackages ? {} , useMacosReexportHack ? false + +# Darwin code signing support utilities +, postLinkSignHook ? null, signingUtils ? null }: with lib; @@ -51,19 +68,19 @@ let # The dynamic linker has different names on different platforms. This is a # shell glob that ought to match it. dynamicLinker = - /**/ if libc == null then null - else if targetPlatform.libc == "musl" then "${libc_lib}/lib/ld-musl-*" + /**/ if sharedLibraryLoader == null then null + else if targetPlatform.libc == "musl" then "${sharedLibraryLoader}/lib/ld-musl-*" else if (targetPlatform.libc == "bionic" && targetPlatform.is32bit) then "/system/bin/linker" else if (targetPlatform.libc == "bionic" && targetPlatform.is64bit) then "/system/bin/linker64" - else if targetPlatform.libc == "nblibc" then "${libc_lib}/libexec/ld.elf_so" - else if targetPlatform.system == "i686-linux" then "${libc_lib}/lib/ld-linux.so.2" - else if targetPlatform.system == "x86_64-linux" then "${libc_lib}/lib/ld-linux-x86-64.so.2" - else if targetPlatform.system == "powerpc64le-linux" then "${libc_lib}/lib/ld64.so.2" + else if targetPlatform.libc == "nblibc" then "${sharedLibraryLoader}/libexec/ld.elf_so" + else if targetPlatform.system == "i686-linux" then "${sharedLibraryLoader}/lib/ld-linux.so.2" + else if targetPlatform.system == "x86_64-linux" then "${sharedLibraryLoader}/lib/ld-linux-x86-64.so.2" + else if targetPlatform.system == "powerpc64le-linux" then "${sharedLibraryLoader}/lib/ld64.so.2" # ARM with a wildcard, which can be "" or "-armhf". - else if (with targetPlatform; isAarch32 && isLinux) then "${libc_lib}/lib/ld-linux*.so.3" - else if targetPlatform.system == "aarch64-linux" then "${libc_lib}/lib/ld-linux-aarch64.so.1" - else if targetPlatform.system == "powerpc-linux" then "${libc_lib}/lib/ld.so.1" - else if targetPlatform.isMips then "${libc_lib}/lib/ld.so.1" + else if (with targetPlatform; isAarch32 && isLinux) then "${sharedLibraryLoader}/lib/ld-linux*.so.3" + else if targetPlatform.system == "aarch64-linux" then "${sharedLibraryLoader}/lib/ld-linux-aarch64.so.1" + else if targetPlatform.system == "powerpc-linux" then "${sharedLibraryLoader}/lib/ld.so.1" + else if targetPlatform.isMips then "${sharedLibraryLoader}/lib/ld.so.1" else if targetPlatform.isDarwin then "/usr/lib/dyld" else if targetPlatform.isFreeBSD then "/libexec/ld-elf.so.1" else if lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" @@ -221,10 +238,10 @@ stdenv.mkDerivation { ## ## Dynamic linker support ## - + '' + + optionalString (sharedLibraryLoader != null) '' if [[ -z ''${dynamicLinker+x} ]]; then echo "Don't know the name of the dynamic linker for platform '${targetPlatform.config}', so guessing instead." >&2 - local dynamicLinker="${libc_lib}/lib/ld*.so.?" + local dynamicLinker="${sharedLibraryLoader}/lib/ld*.so.?" fi '' @@ -243,9 +260,9 @@ stdenv.mkDerivation { ${if targetPlatform.isDarwin then '' printf "export LD_DYLD_PATH=%q\n" "$dynamicLinker" >> $out/nix-support/setup-hook - '' else '' - if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then - echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + '' else lib.optionalString (sharedLibraryLoader != null) '' + if [ -e ${sharedLibraryLoader}/lib/32/ld-linux.so.2 ]; then + echo ${sharedLibraryLoader}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 fi touch $out/nix-support/ld-set-dynamic-linker ''} @@ -340,6 +357,24 @@ stdenv.mkDerivation { ) ## + ## Code signing on Apple Silicon + ## + + optionalString (targetPlatform.isDarwin && targetPlatform.isAarch64) '' + echo 'source ${postLinkSignHook}' >> $out/nix-support/post-link-hook + + export signingUtils=${signingUtils} + + wrap \ + ${targetPrefix}install_name_tool \ + ${./darwin-install_name_tool-wrapper.sh} \ + "${bintools_bin}/bin/${targetPrefix}install_name_tool" + + wrap \ + ${targetPrefix}strip ${./darwin-strip-wrapper.sh} \ + "${bintools_bin}/bin/${targetPrefix}strip" + '' + + ## ## Extra custom steps ## + extraBuildCommands; |