at master 2.2 kB view raw
1{ 2 lib, 3 stdenv, 4 langJit, 5}: 6 7{ 8 # Note [Cross-compiler stripping] 9 # gcc requires delicate stripping as it installs ELF files for both 10 # HOST and TARGET platforms. It requires according strip tool otherwise 11 # strip could remove sections it's not aware of. 12 # Example ARM breakage by x86_64 strip: https://bugs.gentoo.org/697428 13 # 14 # Let's recap the file layout for directories with object files for a 15 # cross-compiler: 16 # 17 # $out (host != target) 18 # `- bin: HOST 19 # lib/*.{a,o}: HOST 20 # `- gcc/<TARGET>/<VERSION>/*.{a,o}: TARGET 21 # `- plugin/: HOST 22 # `- lib{,32,64,x32}: symlink to lib or identical layout 23 # `- libexec/: HOST 24 # `- <TARGET>/: TARGET 25 # 26 # $out (host == target) has identical directory layout. 27 # 28 # $lib (host != target): 29 # `- <TARGET>/lib/*.{la,so}: TARGET 30 # 31 # $lib (host == target): 32 # `- lib/*.{la,so}: HOST 33 34 # The rest of stripDebugList{Host,Target} will be populated in 35 # postInstall to disambiguate lib/ object files. 36 stripDebugList = [ 37 "bin" 38 "libexec" 39 ]; 40 stripDebugListTarget = [ stdenv.targetPlatform.config ]; 41 42 preFixup = '' 43 # Populate most delicated lib/ part of stripDebugList{,Target} 44 updateDebugListPaths() { 45 local oldOpts 46 oldOpts="$(shopt -p nullglob)" || true 47 shopt -s nullglob 48 49 pushd $out 50 local -ar outHostFiles=( 51 lib{,32,64}/*.{a,o,so*} 52 lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/plugin 53 ) 54 local -ar outTargetFiles=( 55 lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/*.{a,o,so*} 56 ) 57 popd 58 '' 59 + lib.optionalString (!langJit) '' 60 ${ 61 # keep indentation 62 "" 63 } 64 pushd $lib 65 local -ar libHostFiles=( 66 lib{,32,64}/*.{a,o,so*} 67 ) 68 local -ar libTargetFiles=( 69 lib{,32,64}/${stdenv.targetPlatform.config}/*.{a,o,so*} 70 ) 71 popd 72 73 '' 74 + '' 75 eval "$oldOpts" 76 77 stripDebugList="$stripDebugList ''${outHostFiles[*]} ''${libHostFiles[*]}" 78 stripDebugListTarget="$stripDebugListTarget ''${outTargetFiles[*]} ''${libTargetFiles[*]}" 79 } 80 updateDebugListPaths 81 ''; 82}