Skip to content

Implement differently logic to strip and copy the tvos libraries #38275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,25 @@ function cmake_config_opt() {
fi
}

function copy_lib_stripping_architecture() {
local source="$1"
local dest="$2"
local arch="$3"

# An alternative approach would be to use || to first
# attempt the removal of the slice and fall back to the
# copy when failing.
# However, this would leave unneeded error messages in the logs
# that may hinder investigation; in addition, in this scenario
# the `call` function seems to not propagate correctly failure
# exit codes.
if lipo -archs "${source}" | grep -q "${arch}"; then
call lipo -remove "${arch}" "${source}" -output "${dest}"
else
call cp "${source}" "${dest}"
fi
}

function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
local clang_dest_dir="$1"

Expand All @@ -1448,7 +1467,8 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
if [[ ! -f "${DEST_LIB_PATH}" ]]; then
if [[ -f "${HOST_LIB_PATH}" ]]; then
if [[ "$OS" == "tvos" ]]; then
call lipo -remove i386 "${HOST_LIB_PATH}" -output "${DEST_LIB_PATH}" || call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
# This is to avoid strip failures when generating a toolchain
copy_lib_stripping_architecture "${HOST_LIB_PATH}" "${DEST_LIB_PATH}" i386
else
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
fi
Expand All @@ -1464,7 +1484,8 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
if [[ ! -f "${DEST_SIM_LIB_PATH}" ]]; then
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
if [[ "$OS" == "tvos" ]]; then
call lipo -remove i386 "${HOST_SIM_LIB_PATH}" -output "${DEST_SIM_LIB_PATH}" || call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
# This is to avoid strip failures when generating a toolchain
copy_lib_stripping_architecture "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}" i386
else
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
fi
Expand Down