@@ -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
@@ -1470,7 +1489,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1470
1489
if [[ -f " ${HOST_LIB_PATH} " ]]; then
1471
1490
if [[ " $OS " == " tvos" ]]; then
1472
1491
# 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
1474
1493
else
1475
1494
call cp " ${HOST_LIB_PATH} " " ${DEST_LIB_PATH} "
1476
1495
fi
@@ -1487,7 +1506,7 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1487
1506
if [[ -f " ${HOST_SIM_LIB_PATH} " ]]; then
1488
1507
if [[ " $OS " == " tvos" ]]; then
1489
1508
# 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
1491
1510
else
1492
1511
call cp " ${HOST_SIM_LIB_PATH} " " ${DEST_SIM_LIB_PATH} "
1493
1512
fi
0 commit comments