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