Skip to content

Commit 376b6f2

Browse files
committed
Implement differently logic to strip and copy the tvos libraries
1 parent 245db53 commit 376b6f2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

utils/build-script-impl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,25 @@ function cmake_config_opt() {
14441444
fi
14451445
}
14461446

1447+
function copy_lib_stripping_architecture() {
1448+
local source="$1"
1449+
local dest="$2"
1450+
local arch="$3"
1451+
1452+
# An alternative approach would be to use || to first
1453+
# attempt the removal of the slice and fall back to the
1454+
# copy when failing.
1455+
# However, this would leave unneeded error messages in the logs
1456+
# that may hinder investigation; in addition, in this scenario
1457+
# the `call` function seems to not propagate correctly failure
1458+
# exit codes.
1459+
if lipo -archs "${source}" | grep -q "${arch}"; then
1460+
call lipo -remove "${arch}" "${source}" -output "${dest}"
1461+
else
1462+
call cp "${source}" "${dest}"
1463+
fi
1464+
}
1465+
14471466
function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
14481467
local clang_dest_dir="$1"
14491468

@@ -1470,7 +1489,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
14701489
if [[ -f "${HOST_LIB_PATH}" ]]; then
14711490
if [[ "$OS" == "tvos" ]]; then
14721491
# This is to avoid strip failures when generating a toolchain
1473-
call lipo -remove i386 "${HOST_LIB_PATH}" -output "${DEST_LIB_PATH}" || call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
1492+
copy_lib_stripping_architecture "${HOST_LIB_PATH}" "${DEST_LIB_PATH}" i386
14741493
else
14751494
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
14761495
fi
@@ -1487,7 +1506,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
14871506
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
14881507
if [[ "$OS" == "tvos" ]]; then
14891508
# This is to avoid strip failures when generating a toolchain
1490-
call lipo -remove i386 "${HOST_SIM_LIB_PATH}" -output "${DEST_SIM_LIB_PATH}" || call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
1509+
copy_lib_stripping_architecture "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}" i386
14911510
else
14921511
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
14931512
fi

0 commit comments

Comments
 (0)