Skip to content

Commit

Permalink
Merge branch 'hkm/aarch64-darwin-fix' into hkm/ghcjs-9.6.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	compiler/ghc/default.nix
  • Loading branch information
hamishmack committed Mar 17, 2023
2 parents 1626b97 + b7e8bc1 commit ba40383
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
25 changes: 24 additions & 1 deletion compiler/ghc/default.nix
Expand Up @@ -270,6 +270,26 @@ let
else "lib/${targetPrefix}ghc-${ghc-version}" + lib.optionalString (useHadrian) "/lib";
packageConfDir = "${libDir}/package.conf.d";

# This work around comes from nixpkgs/pkgs/development/compilers/ghc
#
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
# derivation for certain tools depending on the platform.
bintoolsFor = {
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
# part of the bintools wrapper (due to codesigning requirements), but not on
# x86_64-darwin.
install_name_tool =
if stdenv.targetPlatform.isAarch64
then targetCC.bintools
else targetCC.bintools.bintools;
# Same goes for strip.
strip =
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
then targetCC.bintools
else targetCC.bintools.bintools;
};

in
stdenv.mkDerivation (rec {
version = ghc-version;
Expand Down Expand Up @@ -315,7 +335,10 @@ stdenv.mkDerivation (rec {
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
'') + lib.optionalString (targetPlatform == hostPlatform && useLdGold)
# set LD explicitly if we want gold even if we aren't cross compiling
''
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba40383

Please sign in to comment.