Skip to content

Commit fb5b040

Browse files
authored
Merge pull request #1986 from swiftwasm/swiftwasm-release/5.3-merge
Resolve conflicts in the 5.3 branch
2 parents 98c01ef + 60b9270 commit fb5b040

File tree

2 files changed

+66
-43
lines changed

2 files changed

+66
-43
lines changed

utils/build-script-impl

+63-43
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,61 @@ function cmake_config_opt() {
13961396
fi
13971397
}
13981398

1399+
function copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain() {
1400+
local clang_dest_dir="$1"
1401+
1402+
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
1403+
HOST_LIB_CLANG_DIR="${HOST_CXX_DIR}/../lib/clang"
1404+
DEST_LIB_CLANG_DIR="${clang_dest_dir}/lib/clang"
1405+
1406+
[ -d "${HOST_LIB_CLANG_DIR}" -a -d "${DEST_LIB_CLANG_DIR}" ] || return 0
1407+
1408+
DEST_CXX_BUILTINS_VERSION=$(ls -1 "${DEST_LIB_CLANG_DIR}")
1409+
DEST_BUILTINS_DIR="${clang_dest_dir}/lib/clang/${DEST_CXX_BUILTINS_VERSION}/lib/darwin"
1410+
1411+
if [[ -d "${DEST_BUILTINS_DIR}" ]]; then
1412+
for HOST_CXX_BUILTINS_PATH in "${HOST_LIB_CLANG_DIR}"/*; do
1413+
HOST_CXX_BUILTINS_DIR="${HOST_CXX_BUILTINS_PATH}/lib/darwin"
1414+
echo "copying compiler-rt embedded builtins from ${HOST_CXX_BUILTINS_DIR} into the local clang build directory ${DEST_BUILTINS_DIR}."
1415+
1416+
for OS in ios watchos tvos; do
1417+
# Copy over the device .a when necessary
1418+
LIB_NAME="libclang_rt.$OS.a"
1419+
HOST_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$LIB_NAME"
1420+
DEST_LIB_PATH="${DEST_BUILTINS_DIR}/${LIB_NAME}"
1421+
if [[ ! -f "${DEST_LIB_PATH}" ]]; then
1422+
if [[ -f "${HOST_LIB_PATH}" ]]; then
1423+
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
1424+
elif [[ "${VERBOSE_BUILD}" ]]; then
1425+
echo "no file exists at ${HOST_LIB_PATH}"
1426+
fi
1427+
fi
1428+
1429+
# Copy over the simulator .a when necessary
1430+
SIM_LIB_NAME="libclang_rt.${OS}sim.a"
1431+
HOST_SIM_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$SIM_LIB_NAME"
1432+
DEST_SIM_LIB_PATH="${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
1433+
if [[ ! -f "${DEST_SIM_LIB_PATH}" ]]; then
1434+
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
1435+
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
1436+
elif [[ -f "${HOST_LIB_PATH}" ]]; then
1437+
# The simulator .a might not exist if the host
1438+
# Xcode is old. In that case, copy over the
1439+
# device library to the simulator location to allow
1440+
# clang to find it. The device library has the simulator
1441+
# slices in Xcode that doesn't have the simulator .a, so
1442+
# the link is still valid.
1443+
echo "copying over faux-sim library ${HOST_LIB_PATH} to ${SIM_LIB_NAME}"
1444+
call cp "${HOST_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
1445+
elif [[ "${VERBOSE_BUILD}" ]]; then
1446+
echo "no file exists at ${HOST_SIM_LIB_PATH}"
1447+
fi
1448+
fi
1449+
done
1450+
done
1451+
fi
1452+
}
1453+
13991454
#
14001455
# Configure and build each product
14011456
#
@@ -2377,49 +2432,7 @@ for host in "${ALL_HOSTS[@]}"; do
23772432
# builtins for iOS/tvOS/watchOS to ensure that Swift's
23782433
# stdlib can use compiler-rt builtins when targetting iOS/tvOS/watchOS.
23792434
if [[ "${product}" = "llvm" ]] && [[ "${BUILD_LLVM}" = "1" ]] && [[ "$(uname -s)" = "Darwin" ]]; then
2380-
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
2381-
HOST_LIB_CLANG_DIR="${HOST_CXX_DIR}/../lib/clang"
2382-
DEST_LIB_CLANG_DIR="$(build_directory_bin ${host} llvm)/../lib/clang"
2383-
2384-
if [[ -d "${HOST_LIB_CLANG_DIR}" ]] && [[ -d "${DEST_LIB_CLANG_DIR}" ]]; then
2385-
DEST_CXX_BUILTINS_VERSION=$(ls "${DEST_LIB_CLANG_DIR}" | awk '{print $0}')
2386-
DEST_BUILTINS_DIR="$(build_directory_bin ${host} llvm)/../lib/clang/$DEST_CXX_BUILTINS_VERSION/lib/darwin"
2387-
2388-
if [[ -d "${DEST_BUILTINS_DIR}" ]]; then
2389-
for HOST_CXX_BUILTINS_PATH in "${HOST_LIB_CLANG_DIR}"/*; do
2390-
HOST_CXX_BUILTINS_DIR="${HOST_CXX_BUILTINS_PATH}/lib/darwin"
2391-
echo "copying compiler-rt embedded builtins from ${HOST_CXX_BUILTINS_DIR} into the local clang build directory ${DEST_BUILTINS_DIR}."
2392-
2393-
for OS in ios watchos tvos; do
2394-
# Copy over the device .a
2395-
LIB_NAME="libclang_rt.$OS.a"
2396-
HOST_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$LIB_NAME"
2397-
if [[ -f "${HOST_LIB_PATH}" ]]; then
2398-
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${LIB_NAME}"
2399-
elif [[ "${VERBOSE_BUILD}" ]]; then
2400-
echo "no file exists at ${HOST_LIB_PATH}"
2401-
fi
2402-
# Copy over the simulator .a
2403-
SIM_LIB_NAME="libclang_rt.${OS}sim.a"
2404-
HOST_SIM_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$SIM_LIB_NAME"
2405-
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
2406-
call cp "${HOST_SIM_LIB_PATH}" "${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
2407-
elif [[ -f "${HOST_LIB_PATH}" ]]; then
2408-
# The simulator .a might not exist if the host
2409-
# Xcode is old. In that case, copy over the
2410-
# device library to the simulator location to allow
2411-
# clang to find it. The device library has the simulator
2412-
# slices in Xcode that doesn't have the simulator .a, so
2413-
# the link is still valid.
2414-
echo "copying over faux-sim library ${HOST_LIB_PATH} to ${SIM_LIB_NAME}"
2415-
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
2416-
elif [[ "${VERBOSE_BUILD}" ]]; then
2417-
echo "no file exists at ${HOST_SIM_LIB_PATH}"
2418-
fi
2419-
done
2420-
done
2421-
fi
2422-
fi
2435+
copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain "$(build_directory_bin ${host} llvm)/.."
24232436
fi
24242437
done
24252438
done
@@ -2936,6 +2949,13 @@ for host in "${ALL_HOSTS[@]}"; do
29362949
build_dir=$(build_directory ${host} ${product})
29372950

29382951
call env DESTDIR="${host_install_destdir}" "${CMAKE_BUILD[@]}" "${build_dir}" -- ${INSTALL_TARGETS}
2952+
2953+
# When we are installing LLVM copy over the compiler-rt
2954+
# builtins for iOS/tvOS/watchOS to ensure that we don't
2955+
# have linker errors when building apps for such platforms.
2956+
if [[ "${product}" = "llvm" ]] && [[ ! -z "${LLVM_INSTALL_COMPONENTS}" ]] && [[ "$(uname -s)" = "Darwin" ]]; then
2957+
copy_embedded_compiler_rt_builtins_from_darwin_host_toolchain "${host_install_destdir}${host_install_prefix}"
2958+
fi
29392959
done
29402960
done
29412961

utils/update_checkout/update-checkout-config.json

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
"yams": {
3939
"remote": { "id": "jpsim/Yams" }
4040
},
41+
"yams": {
42+
"remote": { "id": "jpsim/Yams" }
43+
},
4144
"cmake": {
4245
"remote": { "id": "KitWare/CMake" },
4346
"platforms": [ "Linux" ]

0 commit comments

Comments
 (0)