gcc-arm-embedded: fix hardcoded library paths on x86_64-darwin (#407272)

authored by Pavol Rusnak and committed by GitHub 8098aca4 8f2f7ab5

+70 -30
+35 -14
pkgs/by-name/gc/gcc-arm-embedded-13/package.nix
··· 4 4 fetchurl, 5 5 ncurses5, 6 6 libxcrypt-legacy, 7 + xz, 8 + zstd, 9 + makeBinaryWrapper, 10 + darwin, 7 11 }: 8 12 9 13 stdenv.mkDerivation rec { ··· 38 42 ./info-fix.patch 39 43 ]; 40 44 45 + nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ 46 + makeBinaryWrapper 47 + darwin.sigtool 48 + ]; 49 + 41 50 dontConfigure = true; 42 51 dontBuild = true; 43 52 dontPatchELF = true; ··· 50 59 rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || : 51 60 ''; 52 61 53 - preFixup = lib.optionalString stdenv.isLinux '' 54 - find $out -type f | while read f; do 55 - patchelf "$f" > /dev/null 2>&1 || continue 56 - patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true 57 - patchelf --set-rpath ${ 58 - lib.makeLibraryPath [ 59 - "$out" 60 - stdenv.cc.cc 61 - ncurses5 62 - libxcrypt-legacy 63 - ] 64 - } "$f" || true 65 - done 66 - ''; 62 + preFixup = 63 + lib.optionalString stdenv.isLinux '' 64 + find $out -type f | while read f; do 65 + patchelf "$f" > /dev/null 2>&1 || continue 66 + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true 67 + patchelf --set-rpath ${ 68 + lib.makeLibraryPath [ 69 + "$out" 70 + stdenv.cc.cc 71 + ncurses5 72 + libxcrypt-legacy 73 + ] 74 + } "$f" || true 75 + done 76 + '' 77 + + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' 78 + find "$out" -executable -type f | while read executable; do 79 + ( \ 80 + install_name_tool \ 81 + -change "/usr/local/opt/zstd/lib/libzstd.1.dylib" "${lib.getLib zstd}/lib/libzstd.1.dylib" \ 82 + -change "/usr/local/opt/xz/lib/liblzma.5.dylib" "${lib.getLib xz}/lib/liblzma.5.dylib" \ 83 + "$executable" \ 84 + && codesign -f -s - "$executable" \ 85 + ) || true 86 + done 87 + ''; 67 88 68 89 meta = with lib; { 69 90 description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
+35 -16
pkgs/by-name/gc/gcc-arm-embedded-14/package.nix
··· 6 6 libxcrypt-legacy, 7 7 xz, 8 8 zstd, 9 + makeBinaryWrapper, 10 + darwin, 9 11 }: 10 12 11 13 stdenv.mkDerivation rec { ··· 33 35 } 34 36 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 35 37 }; 38 + 39 + nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ 40 + makeBinaryWrapper 41 + darwin.sigtool 42 + ]; 36 43 37 44 patches = [ 38 45 # fix double entry in share/info/porting.info ··· 52 59 rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || : 53 60 ''; 54 61 55 - preFixup = lib.optionalString stdenv.isLinux '' 56 - find $out -type f | while read f; do 57 - patchelf "$f" > /dev/null 2>&1 || continue 58 - patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true 59 - patchelf --set-rpath ${ 60 - lib.makeLibraryPath [ 61 - "$out" 62 - stdenv.cc.cc 63 - ncurses6 64 - libxcrypt-legacy 65 - xz 66 - zstd 67 - ] 68 - } "$f" || true 69 - done 70 - ''; 62 + preFixup = 63 + lib.optionalString stdenv.isLinux '' 64 + find $out -type f | while read f; do 65 + patchelf "$f" > /dev/null 2>&1 || continue 66 + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true 67 + patchelf --set-rpath ${ 68 + lib.makeLibraryPath [ 69 + "$out" 70 + stdenv.cc.cc 71 + ncurses6 72 + libxcrypt-legacy 73 + xz 74 + zstd 75 + ] 76 + } "$f" || true 77 + done 78 + '' 79 + + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' 80 + find "$out" -executable -type f | while read executable; do 81 + ( \ 82 + install_name_tool \ 83 + -change "/usr/local/opt/zstd/lib/libzstd.1.dylib" "${lib.getLib zstd}/lib/libzstd.1.dylib" \ 84 + -change "/usr/local/opt/xz/lib/liblzma.5.dylib" "${lib.getLib xz}/lib/liblzma.5.dylib" \ 85 + "$executable" \ 86 + && codesign -f -s - "$executable" \ 87 + ) || true 88 + done 89 + ''; 71 90 72 91 meta = with lib; { 73 92 description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";