Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

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.

(cherry picked from commit d5bb6a1f9c0c099738a37ce2e923cd71d85b5145)

+25 -18
+16 -1
pkgs/build-support/cc-wrapper/ld-wrapper.sh
··· 146 146 147 147 # Finally, add `-rpath' switches. 148 148 for i in $rpath; do 149 - extra=(${extra[@]} -rpath $i) 149 + extra+=(-rpath $i) 150 + done 151 + fi 152 + 153 + 154 + # Only add --build-id if this is a final link. FIXME: should build gcc 155 + # with --enable-linker-build-id instead? 156 + if [ "$NIX_SET_BUILD_ID" = 1 ]; then 157 + for p in "${params[@]}"; do 158 + if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then 159 + relocatable=1 160 + break 161 + fi 150 162 done 163 + if [ -z "$relocatable" ]; then 164 + extra+=(--build-id) 165 + fi 151 166 fi 152 167 153 168
+2 -1
pkgs/build-support/setup-hooks/separate-debug-info.sh
··· 1 - export NIX_LDFLAGS+=" --build-id --compress-debug-sections" 1 + export NIX_SET_BUILD_ID=1 2 + export NIX_LDFLAGS+=" --compress-debug-sections=zlib" 2 3 export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections" 3 4 dontStrip=1 4 5
+4
pkgs/development/libraries/glibc/builder.sh
··· 37 37 38 38 # Get rid of more unnecessary stuff. 39 39 rm -rf $out/var $out/sbin/sln 40 + 41 + for i in $out/lib/*.a; do 42 + strip -S "$i" 43 + done 40 44 } 41 45 42 46 genericBuild
+3 -16
pkgs/development/libraries/glibc/default.nix
··· 2 2 , installLocales ? true 3 3 , profilingLibraries ? false 4 4 , gccCross ? null 5 - , debugSymbols ? false 6 5 , withGd ? false, gd ? null, libpng ? null 7 6 }: 8 7 ··· 13 12 cross = if gccCross != null then gccCross.target else null; 14 13 in 15 14 build cross ({ 16 - name = "glibc" 17 - + lib.optionalString debugSymbols "-debug" 18 - + lib.optionalString withGd "-gd"; 15 + name = "glibc" + lib.optionalString withGd "-gd"; 19 16 20 17 inherit lib stdenv fetchurl linuxHeaders installLocales 21 18 profilingLibraries gccCross withGd gd libpng; ··· 38 35 fi 39 36 ''; 40 37 38 + separateDebugInfo = true; 39 + 41 40 meta.description = "The GNU C Library"; 42 41 } 43 - 44 - // 45 - 46 - (if debugSymbols 47 - then { 48 - # Build with debugging symbols, but leave optimizations on and don't 49 - # attempt to keep the build tree. 50 - dontStrip = true; 51 - dontCrossStrip = true; 52 - NIX_STRIP_DEBUG = 0; 53 - } 54 - else {}) 55 42 56 43 // 57 44