Skip to content

Commit 7666ec6

Browse files
authored
Nixpkgs work around for strip on aarch64-darwin (#1887)
1 parent 25d82a0 commit 7666ec6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

compiler/ghc/default.nix

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,26 @@ let
265265
else "lib/${targetPrefix}ghc-${ghc-version}" + lib.optionalString (useHadrian) "/lib";
266266
packageConfDir = "${libDir}/package.conf.d";
267267

268+
# This work around comes from nixpkgs/pkgs/development/compilers/ghc
269+
#
270+
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
271+
# derivation for certain tools depending on the platform.
272+
bintoolsFor = {
273+
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
274+
# part of the bintools wrapper (due to codesigning requirements), but not on
275+
# x86_64-darwin.
276+
install_name_tool =
277+
if stdenv.targetPlatform.isAarch64
278+
then targetCC.bintools
279+
else targetCC.bintools.bintools;
280+
# Same goes for strip.
281+
strip =
282+
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
283+
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
284+
then targetCC.bintools
285+
else targetCC.bintools.bintools;
286+
};
287+
268288
in
269289
stdenv.mkDerivation (rec {
270290
version = ghc-version;
@@ -305,7 +325,10 @@ stdenv.mkDerivation (rec {
305325
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
306326
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
307327
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
308-
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
328+
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
329+
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
330+
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
331+
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
309332
'' + lib.optionalString (targetPlatform == hostPlatform && useLdGold)
310333
# set LD explicitly if we want gold even if we aren't cross compiling
311334
''

0 commit comments

Comments
 (0)