2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
langJit,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
# Note [Cross-compiler stripping]
|
|
|
|
# gcc requires delicate stripping as it installs ELF files for both
|
|
|
|
# HOST and TARGET platforms. It requires according strip tool otherwise
|
|
|
|
# strip could remove sections it's not aware of.
|
|
|
|
# Example ARM breakage by x86_64 strip: https://bugs.gentoo.org/697428
|
|
|
|
#
|
|
|
|
# Let's recap the file layout for directories with object files for a
|
|
|
|
# cross-compiler:
|
|
|
|
#
|
|
|
|
# $out (host != target)
|
|
|
|
# `- bin: HOST
|
|
|
|
# lib/*.{a,o}: HOST
|
|
|
|
# `- gcc/<TARGET>/<VERSION>/*.{a,o}: TARGET
|
|
|
|
# `- plugin/: HOST
|
|
|
|
# `- lib{,32,64,x32}: symlink to lib or identical layout
|
|
|
|
# `- libexec/: HOST
|
|
|
|
# `- <TARGET>/: TARGET
|
|
|
|
#
|
|
|
|
# $out (host == target) has identical directory layout.
|
|
|
|
#
|
|
|
|
# $lib (host != target):
|
|
|
|
# `- <TARGET>/lib/*.{la,so}: TARGET
|
|
|
|
#
|
|
|
|
# $lib (host == target):
|
|
|
|
# `- lib/*.{la,so}: HOST
|
|
|
|
|
|
|
|
# The rest of stripDebugList{Host,Target} will be populated in
|
|
|
|
# postInstall to disambiguate lib/ object files.
|
2024-06-30 08:16:52 +00:00
|
|
|
stripDebugList = [
|
|
|
|
"bin"
|
|
|
|
"libexec"
|
|
|
|
];
|
2024-05-02 00:46:19 +00:00
|
|
|
stripDebugListTarget = [ stdenv.targetPlatform.config ];
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
preFixup =
|
|
|
|
''
|
|
|
|
# Populate most delicated lib/ part of stripDebugList{,Target}
|
|
|
|
updateDebugListPaths() {
|
|
|
|
local oldOpts
|
|
|
|
oldOpts="$(shopt -p nullglob)" || true
|
|
|
|
shopt -s nullglob
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
pushd $out
|
|
|
|
local -ar outHostFiles=(
|
|
|
|
lib{,32,64}/*.{a,o,so*}
|
|
|
|
lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/plugin
|
|
|
|
)
|
|
|
|
local -ar outTargetFiles=(
|
|
|
|
lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/*.{a,o,so*}
|
|
|
|
)
|
|
|
|
popd
|
|
|
|
''
|
|
|
|
+ lib.optionalString (!langJit) ''
|
|
|
|
${
|
|
|
|
# keep indentation
|
|
|
|
""
|
|
|
|
}
|
|
|
|
pushd $lib
|
|
|
|
local -ar libHostFiles=(
|
|
|
|
lib{,32,64}/*.{a,o,so*}
|
|
|
|
)
|
|
|
|
local -ar libTargetFiles=(
|
|
|
|
lib{,32,64}/${stdenv.targetPlatform.config}/*.{a,o,so*}
|
|
|
|
)
|
|
|
|
popd
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
eval "$oldOpts"
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
stripDebugList="$stripDebugList ''${outHostFiles[*]} ''${libHostFiles[*]}"
|
|
|
|
stripDebugListTarget="$stripDebugListTarget ''${outTargetFiles[*]} ''${libTargetFiles[*]}"
|
|
|
|
}
|
|
|
|
updateDebugListPaths
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|