@@ -1423,6 +1423,25 @@ function cmake_config_opt() {
1423
1423
fi
1424
1424
}
1425
1425
1426
+ function copy_lib_stripping_architecture() {
1427
+ local source=" $1 "
1428
+ local dest=" $2 "
1429
+ local arch=" $3 "
1430
+
1431
+ # An alternative approach would be to use || to first
1432
+ # attempt the removal of the slice and fall back to the
1433
+ # copy when failing.
1434
+ # However, this would leave unneeded error messages in the logs
1435
+ # that may hinder investigation; in addition, in this scenario
1436
+ # the `call` function seems to not propagate correctly failure
1437
+ # exit codes.
1438
+ if lipo -archs " ${source} " | grep -q " ${arch} " ; then
1439
+ call lipo -remove " ${arch} " " ${source} " -output " ${dest} "
1440
+ else
1441
+ call cp " ${source} " " ${dest} "
1442
+ fi
1443
+ }
1444
+
1426
1445
function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1427
1446
local clang_dest_dir=" $1 "
1428
1447
@@ -1448,7 +1467,8 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1448
1467
if [[ ! -f " ${DEST_LIB_PATH} " ]]; then
1449
1468
if [[ -f " ${HOST_LIB_PATH} " ]]; then
1450
1469
if [[ " $OS " == " tvos" ]]; then
1451
- call lipo -remove i386 " ${HOST_LIB_PATH} " -output " ${DEST_LIB_PATH} " || call cp " ${HOST_LIB_PATH} " " ${DEST_LIB_PATH} "
1470
+ # This is to avoid strip failures when generating a toolchain
1471
+ copy_lib_stripping_architecture " ${HOST_LIB_PATH} " " ${DEST_LIB_PATH} " i386
1452
1472
else
1453
1473
call cp " ${HOST_LIB_PATH} " " ${DEST_LIB_PATH} "
1454
1474
fi
@@ -1464,7 +1484,8 @@ function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1464
1484
if [[ ! -f " ${DEST_SIM_LIB_PATH} " ]]; then
1465
1485
if [[ -f " ${HOST_SIM_LIB_PATH} " ]]; then
1466
1486
if [[ " $OS " == " tvos" ]]; then
1467
- call lipo -remove i386 " ${HOST_SIM_LIB_PATH} " -output " ${DEST_SIM_LIB_PATH} " || call cp " ${HOST_SIM_LIB_PATH} " " ${DEST_SIM_LIB_PATH} "
1487
+ # This is to avoid strip failures when generating a toolchain
1488
+ copy_lib_stripping_architecture " ${HOST_SIM_LIB_PATH} " " ${DEST_SIM_LIB_PATH} " i386
1468
1489
else
1469
1490
call cp " ${HOST_SIM_LIB_PATH} " " ${DEST_SIM_LIB_PATH} "
1470
1491
fi
0 commit comments