Unverified Commit 8098aca4 authored by Pavol Rusnak's avatar Pavol Rusnak Committed by GitHub
Browse files

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

parents 8f2f7ab5 75f94762
Loading
Loading
Loading
Loading
+35 −14
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@
  fetchurl,
  ncurses5,
  libxcrypt-legacy,
  xz,
  zstd,
  makeBinaryWrapper,
  darwin,
}:

stdenv.mkDerivation rec {
@@ -38,6 +42,11 @@ stdenv.mkDerivation rec {
    ./info-fix.patch
  ];

  nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
    makeBinaryWrapper
    darwin.sigtool
  ];

  dontConfigure = true;
  dontBuild = true;
  dontPatchELF = true;
@@ -50,7 +59,8 @@ stdenv.mkDerivation rec {
    rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || :
  '';

  preFixup = lib.optionalString stdenv.isLinux ''
  preFixup =
    lib.optionalString stdenv.isLinux ''
      find $out -type f | while read f; do
        patchelf "$f" > /dev/null 2>&1 || continue
        patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
@@ -63,6 +73,17 @@ stdenv.mkDerivation rec {
          ]
        } "$f" || true
      done
    ''
    + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
      find "$out" -executable -type f | while read executable; do
        ( \
          install_name_tool \
            -change "/usr/local/opt/zstd/lib/libzstd.1.dylib" "${lib.getLib zstd}/lib/libzstd.1.dylib" \
            -change "/usr/local/opt/xz/lib/liblzma.5.dylib" "${lib.getLib xz}/lib/liblzma.5.dylib" \
            "$executable" \
          && codesign -f -s - "$executable" \
        ) || true
      done
    '';

  meta = with lib; {
+35 −16
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@
  libxcrypt-legacy,
  xz,
  zstd,
  makeBinaryWrapper,
  darwin,
}:

stdenv.mkDerivation rec {
@@ -34,6 +36,11 @@ stdenv.mkDerivation rec {
      .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
  };

  nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
    makeBinaryWrapper
    darwin.sigtool
  ];

  patches = [
    # fix double entry in share/info/porting.info
    # https://github.com/NixOS/nixpkgs/issues/363902
@@ -52,7 +59,8 @@ stdenv.mkDerivation rec {
    rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || :
  '';

  preFixup = lib.optionalString stdenv.isLinux ''
  preFixup =
    lib.optionalString stdenv.isLinux ''
      find $out -type f | while read f; do
        patchelf "$f" > /dev/null 2>&1 || continue
        patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
@@ -67,6 +75,17 @@ stdenv.mkDerivation rec {
          ]
        } "$f" || true
      done
    ''
    + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
      find "$out" -executable -type f | while read executable; do
        ( \
          install_name_tool \
            -change "/usr/local/opt/zstd/lib/libzstd.1.dylib" "${lib.getLib zstd}/lib/libzstd.1.dylib" \
            -change "/usr/local/opt/xz/lib/liblzma.5.dylib" "${lib.getLib xz}/lib/liblzma.5.dylib" \
            "$executable" \
          && codesign -f -s - "$executable" \
        ) || true
      done
    '';

  meta = with lib; {