Skip to content

Commit 3a1a423

Browse files
authored
Merge pull request #38262 from edymtt/remove-i386-slice-compiler-rt-tvossim
Strip i386 arch from tvOS compiler-rt lib (if present)
2 parents 843739f + 376b6f2 commit 3a1a423

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

utils/build-script-impl

Lines changed: 31 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

@@ -1468,7 +1487,12 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
14681487
DEST_LIB_PATH="${DEST_BUILTINS_DIR}/${LIB_NAME}"
14691488
if [[ ! -f "${DEST_LIB_PATH}" ]]; then
14701489
if [[ -f "${HOST_LIB_PATH}" ]]; then
1471-
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
1490+
if [[ "$OS" == "tvos" ]]; then
1491+
# This is to avoid strip failures when generating a toolchain
1492+
copy_lib_stripping_architecture "${HOST_LIB_PATH}" "${DEST_LIB_PATH}" i386
1493+
else
1494+
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
1495+
fi
14721496
elif [[ "${VERBOSE_BUILD}" ]]; then
14731497
echo "no file exists at ${HOST_LIB_PATH}"
14741498
fi
@@ -1480,7 +1504,12 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
14801504
DEST_SIM_LIB_PATH="${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
14811505
if [[ ! -f "${DEST_SIM_LIB_PATH}" ]]; then
14821506
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
1483-
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
1507+
if [[ "$OS" == "tvos" ]]; then
1508+
# This is to avoid strip failures when generating a toolchain
1509+
copy_lib_stripping_architecture "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}" i386
1510+
else
1511+
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
1512+
fi
14841513
elif [[ -f "${HOST_LIB_PATH}" ]]; then
14851514
# The simulator .a might not exist if the host
14861515
# Xcode is old. In that case, copy over the

0 commit comments

Comments
 (0)