mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-29 06:45:54 +03:00
Merge branch 'pr-46056' into staging
* pr-46056: binutils: use shared libs binutils: fix #44936 the huge size regression
This commit is contained in:
commit
8ecd555ded
@ -1,18 +1,23 @@
|
||||
{ stdenv, buildPackages
|
||||
{ stdenv, lib, buildPackages
|
||||
, fetchurl, zlib, autoreconfHook264
|
||||
# Enabling all targets increases output size to a multiple.
|
||||
, withAllTargets ? false, libbfd, libopcodes
|
||||
, enableShared ? true
|
||||
, noSysDirs, gold ? true, bison ? null
|
||||
}:
|
||||
|
||||
let
|
||||
reuseLibs = enableShared && withAllTargets;
|
||||
|
||||
# Remove gold-symbol-visibility patch when updating, the proper fix
|
||||
# is now upstream.
|
||||
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=330b90b5ffbbc20c5de6ae6c7f60c40fab2e7a4f;hp=99181ccac0fc7d82e7dabb05dc7466e91f1645d3
|
||||
version = "2.30";
|
||||
basename = "binutils-${version}";
|
||||
inherit (stdenv.lib) optionals optionalString;
|
||||
# The targetPrefix prepended to binary names to allow multiple binuntils on the
|
||||
# PATH to both be usable.
|
||||
targetPrefix = optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "${stdenv.targetPlatform.config}-";
|
||||
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
"${stdenv.targetPlatform.config}-";
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
@ -64,14 +69,14 @@ stdenv.mkDerivation rec {
|
||||
# be satisfied on aarch64 platform. Add backported fix from bugzilla.
|
||||
# https://sourceware.org/bugzilla/show_bug.cgi?id=22764
|
||||
./relax-R_AARCH64_ABS32-R_AARCH64_ABS16-absolute.patch
|
||||
] ++ stdenv.lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch;
|
||||
] ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch;
|
||||
|
||||
outputs = [ "out" "info" "man" ];
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
nativeBuildInputs = [
|
||||
bison
|
||||
] ++ stdenv.lib.optionals stdenv.targetPlatform.isiOS [
|
||||
] ++ lib.optionals stdenv.targetPlatform.isiOS [
|
||||
autoreconfHook264
|
||||
];
|
||||
buildInputs = [ zlib ];
|
||||
@ -100,12 +105,14 @@ stdenv.mkDerivation rec {
|
||||
hardeningDisable = [ "format" "pie" ];
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
|
||||
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
|
||||
configurePlatforms = [ "build" "host" ] ++ lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
|
||||
|
||||
configureFlags = [
|
||||
"--enable-targets=all" "--enable-64-bit-bfd"
|
||||
"--disable-install-libbfd"
|
||||
"--disable-shared" "--enable-static"
|
||||
configureFlags =
|
||||
(if enableShared then [ "--enable-shared" "--disable-static" ]
|
||||
else [ "--disable-shared" "--enable-static" ])
|
||||
++ lib.optional withAllTargets "--enable-targets=all"
|
||||
++ [
|
||||
"--enable-64-bit-bfd"
|
||||
"--with-system-zlib"
|
||||
|
||||
"--enable-deterministic-archives"
|
||||
@ -116,10 +123,16 @@ stdenv.mkDerivation rec {
|
||||
# RUNPATH instead of RPATH on binaries. This is important because
|
||||
# RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
|
||||
"--enable-new-dtags"
|
||||
] ++ optionals gold [ "--enable-gold" "--enable-plugins" ];
|
||||
] ++ lib.optionals gold [ "--enable-gold" "--enable-plugins" ];
|
||||
|
||||
doCheck = false; # fails
|
||||
|
||||
postFixup = lib.optionalString reuseLibs ''
|
||||
rm "$out"/lib/lib{bfd,opcodes}-${version}.so
|
||||
ln -s '${lib.getLib libbfd}/lib/libbfd-${version}.so' "$out/lib/"
|
||||
ln -s '${lib.getLib libopcodes}/lib/libopcodes-${version}.so' "$out/lib/"
|
||||
'';
|
||||
|
||||
# else fails with "./sanity.sh: line 36: $out/bin/size: not found"
|
||||
doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform;
|
||||
|
||||
@ -129,7 +142,7 @@ stdenv.mkDerivation rec {
|
||||
inherit targetPrefix version;
|
||||
};
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
meta = with lib; {
|
||||
description = "Tools for manipulating binaries (linker, assembler, etc.)";
|
||||
longDescription = ''
|
||||
The GNU Binutils are a collection of binary tools. The main
|
||||
|
@ -188,7 +188,9 @@ in
|
||||
|
||||
# Rebuild binutils to use from stage2 onwards.
|
||||
overrides = self: super: {
|
||||
binutils = super.binutils_nogold;
|
||||
binutils-unwrapped = super.binutils-unwrapped.override {
|
||||
gold = false;
|
||||
};
|
||||
inherit (prevStage)
|
||||
ccWrapperStdenv
|
||||
gcc-unwrapped coreutils gnugrep;
|
||||
|
@ -150,6 +150,7 @@ in with pkgs; rec {
|
||||
for i in as ld ar ranlib nm strip readelf objdump; do
|
||||
cp ${binutils.bintools.out}/bin/$i $out/bin
|
||||
done
|
||||
cp '${lib.getLib binutils.bintools}'/lib/* "$out/lib/"
|
||||
|
||||
chmod -R u+w $out
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user