Merge pull request #33186 from obsidiansystems/cross-binutils

binutils: Fix cross, again
This commit is contained in:
John Ericson 2017-12-29 17:42:38 -05:00 committed by GitHub
commit eb27be0731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 10 deletions

View File

@ -164,6 +164,20 @@ stdenv.mkDerivation {
set +u
'';
emulation = let
fmt =
/**/ if targetPlatform.isDarwin then "mach-o"
else if targetPlatform.isWindows then "pe"
else "elf" + toString targetPlatform.parsed.cpu.bits;
endianPrefix = if targetPlatform.isBigEndian then "big" else "little";
arch =
/**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64"
else if targetPlatform.isArm then endianPrefix + "arm"
else if targetPlatform.isx86_64 then "x86-64"
else if targetPlatform.isi686 then "i386"
else throw "unknown emulation for platform: " + targetPlatform.config;
in targetPlatform.platform.bfdEmulation or (fmt + "-" + arch);
propagatedBuildInputs = extraPackages;
setupHook = ./setup-hook.sh;

View File

@ -67,6 +67,11 @@ fi
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
# Specify the target emulation if nothing is passed in ("-m" overrides this
# environment variable). Ensures we never blindly fallback on targeting the host
# platform.
: ${LDEMULATION:=@emulation@}
# Three tasks:
#
# 1. Find all -L... switches for rpath

View File

@ -0,0 +1,14 @@
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index b6940d376d..0feb1adfd0 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -125,6 +125,9 @@ if test "x$NATIVE" = "xyes" ; then
USE_LIBPATH=yes
fi
+# TODO: why is this needed?
+USE_LIBPATH=yes
+
# Set the library search path, for libraries named by -lfoo.
# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
# Otherwise, the default is set here.

View File

@ -53,6 +53,14 @@ stdenv.mkDerivation rec {
# elf32-littlearm-vxworks in favor of the first.
# https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
./disambiguate-arm-targets.patch
# For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
# not clear why this behavior was decided upon but it has the unfortunate
# consequence that the linker will fail to find transitive dependencies of
# shared objects when cross-compiling. Consequently, we are forced to
# override this behavior, forcing ld to search DT_RPATH even when
# cross-compiling.
./always-search-rpath.patch
];
outputs = [ "out" "info" "man" ];

View File

@ -74,8 +74,7 @@ rec {
};
in stdenv // {
mkDerivation =
{ buildInputs ? [], nativeBuildInputs ? []
, propagatedBuildInputs ? [], propagatedNativeBuildInputs ? []
{ nativeBuildInputs ? []
, selfNativeBuildInput ? args.crossAttrs.selfNativeBuildInput or false
, ...
} @ args:
@ -98,14 +97,6 @@ rec {
++ stdenv.lib.optional hostPlatform.isAarch64 pkgs.updateAutotoolsGnuConfigScriptsHook
;
# Cross-linking dynamic libraries, every buildInput should
# be propagated because ld needs the -rpath-link to find
# any library needed to link the program dynamically at
# loader time. ld(1) explains it.
buildInputs = [];
propagatedBuildInputs = propagatedBuildInputs ++ buildInputs;
propagatedNativeBuildInputs = propagatedNativeBuildInputs;
crossConfig = hostPlatform.config;
} // args.crossAttrs or {});
};