Skip to content

Commit 75f9476

Browse files
committed
gcc-arm-embedded: fix hardcoded library paths on x86_64-darwin
1 parent 7234c1e commit 75f9476

File tree

2 files changed

+70
-30
lines changed

2 files changed

+70
-30
lines changed

pkgs/by-name/gc/gcc-arm-embedded-13/package.nix

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
fetchurl,
55
ncurses5,
66
libxcrypt-legacy,
7+
xz,
8+
zstd,
9+
makeBinaryWrapper,
10+
darwin,
711
}:
812

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

45+
nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
46+
makeBinaryWrapper
47+
darwin.sigtool
48+
];
49+
4150
dontConfigure = true;
4251
dontBuild = true;
4352
dontPatchELF = true;
@@ -50,20 +59,32 @@ stdenv.mkDerivation rec {
5059
rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || :
5160
'';
5261

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+
'';
6788

6889
meta = with lib; {
6990
description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";

pkgs/by-name/gc/gcc-arm-embedded-14/package.nix

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
libxcrypt-legacy,
77
xz,
88
zstd,
9+
makeBinaryWrapper,
10+
darwin,
911
}:
1012

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

39+
nativeBuildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
40+
makeBinaryWrapper
41+
darwin.sigtool
42+
];
43+
3744
patches = [
3845
# fix double entry in share/info/porting.info
3946
# https://github.com/NixOS/nixpkgs/issues/363902
@@ -52,22 +59,34 @@ stdenv.mkDerivation rec {
5259
rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || :
5360
'';
5461

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+
'';
7190

7291
meta = with lib; {
7392
description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";

0 commit comments

Comments
 (0)