scripts: Allow stripping target toolchain libraries
This commit adds an option to strip the target toolchain libraries (e.g. libc, libstdc++) of any unneeded or debugging information. Stripping is enabled by default as it is often desirable to reduce the overall toolchain size when producing a release. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
8fa98eeeff
commit
b29c14814e
|
@ -137,3 +137,11 @@ config STRIP_TARGET_TOOLCHAIN_EXECUTABLES
|
|||
An install-strip make target is provided that installs stripped
|
||||
executables, and may install libraries with unneeded or debugging
|
||||
sections stripped.
|
||||
|
||||
config STRIP_TARGET_TOOLCHAIN_LIBRARIES
|
||||
bool
|
||||
prompt "Strip target toolchain libraries"
|
||||
default y
|
||||
help
|
||||
Ensures that the target toolchain libraries are stripped of any unneeded
|
||||
or debugging information.
|
||||
|
|
|
@ -92,6 +92,19 @@ do_finish() {
|
|||
CT_Popd
|
||||
fi
|
||||
|
||||
# Strip target toolchain libraries
|
||||
if [ "${CT_STRIP_TARGET_TOOLCHAIN_LIBRARIES}" = "y" ]; then
|
||||
CT_DoLog INFO "Stripping all target toolchain libraries"
|
||||
CT_Pushd "${CT_PREFIX_DIR}"
|
||||
|
||||
strip_target_lib "${CT_PREFIX_DIR}/${CT_TARGET}/lib" "*.a"
|
||||
strip_target_lib "${CT_PREFIX_DIR}/${CT_TARGET}/lib" "*.o"
|
||||
strip_target_lib "${CT_PREFIX_DIR}/lib/gcc/${CT_TARGET}/${gcc_version}" "*.a"
|
||||
strip_target_lib "${CT_PREFIX_DIR}/lib/gcc/${CT_TARGET}/${gcc_version}" "*.o"
|
||||
|
||||
CT_Popd
|
||||
fi
|
||||
|
||||
if [ "${CT_BARE_METAL}" != "y" ]; then
|
||||
CT_DoLog EXTRA "Installing the populate helper"
|
||||
sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
|
||||
|
@ -140,3 +153,17 @@ do_finish() {
|
|||
|
||||
CT_EndStep
|
||||
}
|
||||
|
||||
strip_target_lib()
|
||||
{
|
||||
local strip_args
|
||||
|
||||
strip_args="-R .comment -R .note -R .debug_info -R .debug_aranges
|
||||
-R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line
|
||||
-R .debug_str -R .debug_ranges -R .debug_loc
|
||||
"
|
||||
|
||||
find "$1" -name "$2" | while read target_lib; do
|
||||
CT_DoExecLog ALL ${CT_TARGET}-objcopy ${strip_args} "${target_lib}"
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue