From 88ea6463a342c2084266395b210d57b1218bad62 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 24 Apr 2017 16:00:11 -0400 Subject: binutils on darwin: Clean up the rats nest - No more *Cross duplication for binutils on darwin either. `cctools_cross` is merged into plain `cctools`, so `buildPackages` chains alone are used to disambiguate. - Always use a mashup of cctools and actual GNU Binutils as `binutils`. Previously, this was only done in the native case as nobody had bothered to implement the masher in the cross case. Implemented it basically consisted of extending the wrapper to deal with prefixed binaries. --- pkgs/os-specific/darwin/binutils/default.nix | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'pkgs/os-specific/darwin/binutils') diff --git a/pkgs/os-specific/darwin/binutils/default.nix b/pkgs/os-specific/darwin/binutils/default.nix index c4ccdb94b8123..bde42e45e9c23 100644 --- a/pkgs/os-specific/darwin/binutils/default.nix +++ b/pkgs/os-specific/darwin/binutils/default.nix @@ -1,11 +1,25 @@ -{ stdenv, binutils-raw, cctools }: +{ stdenv, binutils-raw, cctools +, hostPlatform, targetPlatform +}: +let + prefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + cmds = [ + "ar" "ranlib" "as" "dsymutil" "install_name_tool" + "ld" "strip" "otool" "lipo" "nm" "strings" "size" + ]; +in + +# TODO loop over prefixed binaries too stdenv.mkDerivation { name = "cctools-binutils-darwin"; buildCommand = '' mkdir -p $out/bin $out/include - ln -s ${binutils-raw.out}/bin/c++filt $out/bin/c++filt + ln -s ${binutils-raw.out}/bin/${prefix}c++filt $out/bin/${prefix}c++filt # We specifically need: # - ld: binutils doesn't provide it on darwin @@ -18,11 +32,11 @@ stdenv.mkDerivation { # - strip: the binutils one seems to break mach-o files # - lipo: gcc build assumes it exists # - nm: the gnu one doesn't understand many new load commands - for i in ar ranlib as dsymutil install_name_tool ld strip otool lipo nm strings size; do + for i in ${stdenv.lib.concatStringsSep " " (builtins.map (e: prefix + e) cmds)}; do ln -sf "${cctools}/bin/$i" "$out/bin/$i" done - for i in ${binutils-raw.dev}/include/*.h; do + for i in ${binutils-raw.dev or binutils-raw.out}/include/*.h; do ln -s "$i" "$out/include/$(basename $i)" done -- cgit 1.4.1