Skip to content

Commit 2cf0711

Browse files
committed
[darwin][build] Copy the libclang_rt.{ios/tvos/watchos}.a from toolchain to the build dir so that swift-clang can use them when building for ios/tvos/watchos
(cherry picked from commit e11e127)
1 parent 356890b commit 2cf0711

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

utils/build-script-impl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,31 @@ for host in "${ALL_HOSTS[@]}"; do
29222922
fi
29232923

29242924
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
2925+
2926+
# When we are building LLVM copy over the compiler-rt
2927+
# builtins for iOS/tvOS/watchOS to ensure that Swift's
2928+
# stdlib can use compiler-rt builtins when targetting iOS/tvOS/watchOS.
2929+
if [[ "${product}" == "llvm" ]]; then
2930+
if [[ "$(uname -s)" == "Darwin" ]] ; then
2931+
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
2932+
HOST_CXX_BUILTINS_VERSION=$(ls "$HOST_CXX_DIR/../lib/clang" | awk '{print $0}')
2933+
HOST_CXX_BUILTINS_DIR="$HOST_CXX_DIR/../lib/clang/$HOST_CXX_BUILTINS_VERSION/lib/darwin"
2934+
DEST_CXX_BUILTINS_VERSION=$(ls "$llvm_build_dir/lib/clang" | awk '{print $0}')
2935+
DEST_BUILTINS_DIR="$llvm_build_dir/lib/clang/$DEST_CXX_BUILTINS_VERSION/lib/darwin"
2936+
2937+
echo "copying compiler-rt embedded builtins into the local clang build directory $DEST_BUILTINS_DIR."
2938+
2939+
if [ -f "$HOST_CXX_BUILTINS_DIR/libclang_rt.ios.a" ]; then
2940+
call cp "$HOST_CXX_BUILTINS_DIR/libclang_rt.ios.a" "$DEST_BUILTINS_DIR/libclang_rt.ios.a"
2941+
fi
2942+
if [ -f "$HOST_CXX_BUILTINS_DIR/libclang_rt.watchos.a" ]; then
2943+
call cp "$HOST_CXX_BUILTINS_DIR/libclang_rt.watchos.a" "$DEST_BUILTINS_DIR/libclang_rt.watchos.a"
2944+
fi
2945+
if [ -f "$HOST_CXX_BUILTINS_DIR/libclang_rt.tvos.a" ]; then
2946+
call cp "$HOST_CXX_BUILTINS_DIR/libclang_rt.tvos.a" "$DEST_BUILTINS_DIR/libclang_rt.tvos.a"
2947+
fi
2948+
fi
2949+
fi
29252950
fi
29262951
done
29272952
done

0 commit comments

Comments
 (0)