glibc: Enable separate debug symbols
The importance of glibc makes it worthwhile to provide debug symbols. However, this revealed an issue with separateDebugInfo: it was indiscriminately adding --build-id to all ld invocations, while in fact it should only do that for final links. Glibc also uses non-final ("relocatable") links, leading to subsequent failure to apply a build ID ("Cannot create .note.gnu.build-id section, --build-id ignored"). So now ld-wrapper.sh only passes --build-id for final links.
This commit is contained in:
parent
69a337edae
commit
d5bb6a1f9c
@ -146,11 +146,26 @@ if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
|
|||||||
|
|
||||||
# Finally, add `-rpath' switches.
|
# Finally, add `-rpath' switches.
|
||||||
for i in $rpath; do
|
for i in $rpath; do
|
||||||
extra=(${extra[@]} -rpath $i)
|
extra+=(-rpath $i)
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Only add --build-id if this is a final link. FIXME: should build gcc
|
||||||
|
# with --enable-linker-build-id instead?
|
||||||
|
if [ "$NIX_SET_BUILD_ID" = 1 ]; then
|
||||||
|
for p in "${params[@]}"; do
|
||||||
|
if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then
|
||||||
|
relocatable=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$relocatable" ]; then
|
||||||
|
extra+=(--build-id)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Optionally print debug info.
|
# Optionally print debug info.
|
||||||
if [ -n "$NIX_DEBUG" ]; then
|
if [ -n "$NIX_DEBUG" ]; then
|
||||||
echo "original flags to @prog@:" >&2
|
echo "original flags to @prog@:" >&2
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export NIX_LDFLAGS+=" --build-id --compress-debug-sections"
|
export NIX_SET_BUILD_ID=1
|
||||||
|
export NIX_LDFLAGS+=" --compress-debug-sections=zlib"
|
||||||
export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections"
|
export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections"
|
||||||
dontStrip=1
|
dontStrip=1
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ postInstall() {
|
|||||||
|
|
||||||
# Get rid of more unnecessary stuff.
|
# Get rid of more unnecessary stuff.
|
||||||
rm -rf $out/var $out/sbin/sln
|
rm -rf $out/var $out/sbin/sln
|
||||||
|
|
||||||
|
for i in $out/lib/*.a; do
|
||||||
|
strip -S "$i"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
genericBuild
|
genericBuild
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
, installLocales ? true
|
, installLocales ? true
|
||||||
, profilingLibraries ? false
|
, profilingLibraries ? false
|
||||||
, gccCross ? null
|
, gccCross ? null
|
||||||
, debugSymbols ? false
|
|
||||||
, withGd ? false, gd ? null, libpng ? null
|
, withGd ? false, gd ? null, libpng ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -13,9 +12,7 @@ let
|
|||||||
cross = if gccCross != null then gccCross.target else null;
|
cross = if gccCross != null then gccCross.target else null;
|
||||||
in
|
in
|
||||||
build cross ({
|
build cross ({
|
||||||
name = "glibc"
|
name = "glibc" + lib.optionalString withGd "-gd";
|
||||||
+ lib.optionalString debugSymbols "-debug"
|
|
||||||
+ lib.optionalString withGd "-gd";
|
|
||||||
|
|
||||||
inherit lib stdenv fetchurl linuxHeaders installLocales
|
inherit lib stdenv fetchurl linuxHeaders installLocales
|
||||||
profilingLibraries gccCross withGd gd libpng;
|
profilingLibraries gccCross withGd gd libpng;
|
||||||
@ -38,23 +35,13 @@ in
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
separateDebugInfo = true;
|
||||||
|
|
||||||
meta.description = "The GNU C Library";
|
meta.description = "The GNU C Library";
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
(if debugSymbols
|
|
||||||
then {
|
|
||||||
# Build with debugging symbols, but leave optimizations on and don't
|
|
||||||
# attempt to keep the build tree.
|
|
||||||
dontStrip = true;
|
|
||||||
dontCrossStrip = true;
|
|
||||||
NIX_STRIP_DEBUG = 0;
|
|
||||||
}
|
|
||||||
else {})
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
(if cross != null
|
(if cross != null
|
||||||
then {
|
then {
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user