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