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 147 # Finally, add `-rpath' switches. 148 for i in $rpath; do 149 - extra=(${extra[@]} -rpath $i) 150 done 151 fi 152 153
··· 146 147 # Finally, add `-rpath' switches. 148 for i in $rpath; do 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 162 done 163 + if [ -z "$relocatable" ]; then 164 + extra+=(--build-id) 165 + fi 166 fi 167 168
+2 -1
pkgs/build-support/setup-hooks/separate-debug-info.sh
··· 1 - export NIX_LDFLAGS+=" --build-id --compress-debug-sections" 2 export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections" 3 dontStrip=1 4
··· 1 + export NIX_SET_BUILD_ID=1 2 + export NIX_LDFLAGS+=" --compress-debug-sections=zlib" 3 export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections" 4 dontStrip=1 5
+4
pkgs/development/libraries/glibc/builder.sh
··· 37 38 # Get rid of more unnecessary stuff. 39 rm -rf $out/var $out/sbin/sln 40 } 41 42 genericBuild
··· 37 38 # Get rid of more unnecessary stuff. 39 rm -rf $out/var $out/sbin/sln 40 + 41 + for i in $out/lib/*.a; do 42 + strip -S "$i" 43 + done 44 } 45 46 genericBuild
+3 -16
pkgs/development/libraries/glibc/default.nix
··· 2 , installLocales ? true 3 , profilingLibraries ? false 4 , gccCross ? null 5 - , debugSymbols ? false 6 , withGd ? false, gd ? null, libpng ? null 7 }: 8 ··· 13 cross = if gccCross != null then gccCross.target else null; 14 in 15 build cross ({ 16 - name = "glibc" 17 - + lib.optionalString debugSymbols "-debug" 18 - + lib.optionalString withGd "-gd"; 19 20 inherit lib stdenv fetchurl linuxHeaders installLocales 21 profilingLibraries gccCross withGd gd libpng; ··· 38 fi 39 ''; 40 41 meta.description = "The GNU C Library"; 42 } 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 56 // 57
··· 2 , installLocales ? true 3 , profilingLibraries ? false 4 , gccCross ? null 5 , withGd ? false, gd ? null, libpng ? null 6 }: 7 ··· 12 cross = if gccCross != null then gccCross.target else null; 13 in 14 build cross ({ 15 + name = "glibc" + lib.optionalString withGd "-gd"; 16 17 inherit lib stdenv fetchurl linuxHeaders installLocales 18 profilingLibraries gccCross withGd gd libpng; ··· 35 fi 36 ''; 37 38 + separateDebugInfo = true; 39 + 40 meta.description = "The GNU C Library"; 41 } 42 43 // 44