|
265 | 265 | else "lib/${targetPrefix}ghc-${ghc-version}" + lib.optionalString (useHadrian) "/lib";
|
266 | 266 | packageConfDir = "${libDir}/package.conf.d";
|
267 | 267 |
|
| 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 | + |
268 | 288 | in
|
269 | 289 | stdenv.mkDerivation (rec {
|
270 | 290 | version = ghc-version;
|
@@ -305,7 +325,10 @@ stdenv.mkDerivation (rec {
|
305 | 325 | export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
306 | 326 | export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
307 | 327 | 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" |
309 | 332 | '' + lib.optionalString (targetPlatform == hostPlatform && useLdGold)
|
310 | 333 | # set LD explicitly if we want gold even if we aren't cross compiling
|
311 | 334 | ''
|
|
0 commit comments