@@ -1444,6 +1444,25 @@ function cmake_config_opt() {
1444
1444
fi
1445
1445
}
1446
1446
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
+
1447
1466
function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1448
1467
local clang_dest_dir=" $1 "
1449
1468
@@ -1468,7 +1487,12 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1468
1487
DEST_LIB_PATH=" ${DEST_BUILTINS_DIR} /${LIB_NAME} "
1469
1488
if [[ ! -f " ${DEST_LIB_PATH} " ]]; then
1470
1489
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
1472
1496
elif [[ " ${VERBOSE_BUILD} " ]]; then
1473
1497
echo " no file exists at ${HOST_LIB_PATH} "
1474
1498
fi
@@ -1480,7 +1504,12 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1480
1504
DEST_SIM_LIB_PATH=" ${DEST_BUILTINS_DIR} /${SIM_LIB_NAME} "
1481
1505
if [[ ! -f " ${DEST_SIM_LIB_PATH} " ]]; then
1482
1506
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
1484
1513
elif [[ -f " ${HOST_LIB_PATH} " ]]; then
1485
1514
# The simulator .a might not exist if the host
1486
1515
# Xcode is old. In that case, copy over the
0 commit comments