From 393868ebb6ef519bf96cee18dfd7a2c8518b213b Mon Sep 17 00:00:00 2001 From: zhao-xinyuan8 Date: Thu, 22 Feb 2024 10:01:34 +0000 Subject: [PATCH] Strip unstripped shared objects Use llvm-strip to strip shared object. To keep shared objects same as previous. Issue: I92YHF test: So in out dir are stripped Signed-off-by: zhao-xinyuan8 Change-Id: I2c5d55d9cfc1717dba7a7be4ecca5d71e450a3b3 --- third_party/musl/ndk_script/BUILD.gn | 6 ++++++ third_party/musl/ndk_script/toolchain.sh | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/third_party/musl/ndk_script/BUILD.gn b/third_party/musl/ndk_script/BUILD.gn index e3aedb0b6..ad9e795af 100644 --- a/third_party/musl/ndk_script/BUILD.gn +++ b/third_party/musl/ndk_script/BUILD.gn @@ -53,6 +53,8 @@ if (host_os == "mac") { args = [ "-i" ] + [ rebase_path("${darwin_system_toolchains_dir}/libcxx-ndk") ] args += [ "-o" ] + [ rebase_path("${ndk_darwin_toolchains_out_dir}") ] + args += + [ "-l" ] + [ rebase_path("${darwin_system_toolchains_dir}/llvm/bin") ] if (host_cpu == "arm64") { deps = [ ":darwin_arm64" ] } else { @@ -98,6 +100,8 @@ if (host_os == "mac") { args = [ "-i" ] + [ rebase_path("${linux_x86_64_toolchains_dir}/libcxx-ndk") ] args += [ "-o" ] + [ rebase_path("${ndk_linux_toolchains_out_dir}") ] + args += + [ "-l" ] + [ rebase_path("${linux_x86_64_toolchains_dir}/llvm/bin") ] deps = [ ":linux_x86_64" ] } @@ -107,6 +111,8 @@ if (host_os == "mac") { args = [ "-i" ] + [ rebase_path("${windows_x86_64_toolchain_dir}/libcxx-ndk") ] args += [ "-o" ] + [ rebase_path("${ndk_windows_toolchains_out_dir}") ] + args += + [ "-l" ] + [ rebase_path("${linux_x86_64_toolchains_dir}/llvm/bin") ] deps = [ ":windows_x86_64" ] } } diff --git a/third_party/musl/ndk_script/toolchain.sh b/third_party/musl/ndk_script/toolchain.sh index 7e9acb9de..7f90ff69d 100755 --- a/third_party/musl/ndk_script/toolchain.sh +++ b/third_party/musl/ndk_script/toolchain.sh @@ -2,7 +2,7 @@ # Copyright (c) Huawei Technologies Co., Ltd. 2020-2030. All rights reserved. set -e -while getopts "o:i:t:h" arg +while getopts "o:i:l:t:h" arg do case "${arg}" in "o") @@ -11,6 +11,9 @@ do "i") SOURCE_DIR=${OPTARG} ;; + "l") + TOOL_DIR=${OPTARG} + ;; "h") echo "help" ;; @@ -33,3 +36,17 @@ done cp -rfp ${SOURCE_DIR}/lib ${OUT_DIR} cp -rfp ${SOURCE_DIR}/include ${OUT_DIR} +function strip_dir() { + for file in `ls $1` + do + if [ -f $1"/"$file ] && [[ $(file -b $1"/"$file) =~ "shared object" ]] + then + echo $1"/"$file + ${TOOL_DIR}/llvm-strip $1"/"$file + elif [ -d $1"/"$file ] + then + strip_dir $1"/"$file + fi + done +} +strip_dir ${OUT_DIR}/lib -- Gitee