Skip to content

Commit d0805ef

Browse files
authored
Merge pull request #34049 from apple/eng/copy-over-only-when-needed
[build-script] copy over the compiler-rt .a archives from the toolchi…
2 parents 846f522 + a4c3963 commit d0805ef

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

utils/build-script-impl

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,30 +2431,36 @@ for host in "${ALL_HOSTS[@]}"; do
24312431
echo "copying compiler-rt embedded builtins from ${HOST_CXX_BUILTINS_DIR} into the local clang build directory ${DEST_BUILTINS_DIR}."
24322432

24332433
for OS in ios watchos tvos; do
2434-
# Copy over the device .a
2434+
# Copy over the device .a when necessary
24352435
LIB_NAME="libclang_rt.$OS.a"
24362436
HOST_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$LIB_NAME"
2437-
if [[ -f "${HOST_LIB_PATH}" ]]; then
2438-
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${LIB_NAME}"
2439-
elif [[ "${VERBOSE_BUILD}" ]]; then
2440-
echo "no file exists at ${HOST_LIB_PATH}"
2437+
DEST_LIB_PATH="${DEST_BUILTINS_DIR}/${LIB_NAME}"
2438+
if [[ ! -f "${DEST_LIB_PATH}" ]]; then
2439+
if [[ -f "${HOST_LIB_PATH}" ]]; then
2440+
call cp "${HOST_LIB_PATH}" "${DEST_LIB_PATH}"
2441+
elif [[ "${VERBOSE_BUILD}" ]]; then
2442+
echo "no file exists at ${HOST_LIB_PATH}"
2443+
fi
24412444
fi
2442-
# Copy over the simulator .a
2445+
# Copy over the simulator .a when necessary
24432446
SIM_LIB_NAME="libclang_rt.${OS}sim.a"
24442447
HOST_SIM_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$SIM_LIB_NAME"
2445-
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
2446-
call cp "${HOST_SIM_LIB_PATH}" "${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
2447-
elif [[ -f "${HOST_LIB_PATH}" ]]; then
2448-
# The simulator .a might not exist if the host
2449-
# Xcode is old. In that case, copy over the
2450-
# device library to the simulator location to allow
2451-
# clang to find it. The device library has the simulator
2452-
# slices in Xcode that doesn't have the simulator .a, so
2453-
# the link is still valid.
2454-
echo "copying over faux-sim library ${HOST_LIB_PATH} to ${SIM_LIB_NAME}"
2455-
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
2456-
elif [[ "${VERBOSE_BUILD}" ]]; then
2457-
echo "no file exists at ${HOST_SIM_LIB_PATH}"
2448+
DEST_SIM_LIB_PATH="${DEST_BUILTINS_DIR}/${SIM_LIB_NAME}"
2449+
if [[ ! -f "${DEST_SIM_LIB_PATH}" ]]; then
2450+
if [[ -f "${HOST_SIM_LIB_PATH}" ]]; then
2451+
call cp "${HOST_SIM_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
2452+
elif [[ -f "${HOST_LIB_PATH}" ]]; then
2453+
# The simulator .a might not exist if the host
2454+
# Xcode is old. In that case, copy over the
2455+
# device library to the simulator location to allow
2456+
# clang to find it. The device library has the simulator
2457+
# slices in Xcode that doesn't have the simulator .a, so
2458+
# the link is still valid.
2459+
echo "copying over faux-sim library ${HOST_LIB_PATH} to ${SIM_LIB_NAME}"
2460+
call cp "${HOST_LIB_PATH}" "${DEST_SIM_LIB_PATH}"
2461+
elif [[ "${VERBOSE_BUILD}" ]]; then
2462+
echo "no file exists at ${HOST_SIM_LIB_PATH}"
2463+
fi
24582464
fi
24592465
done
24602466
done

0 commit comments

Comments
 (0)