Skip to content

Commit 5519977

Browse files
committed
Use libcxx from Darwin SDKs when building LLVM and Swift
Those are present since Xcode 12.5, so we don't need to copy them anymore from the toolchain In this scenario, clean up any existing symlink in incremental builds to avoid masking or causing errors in the future. Addresses rdar://102387542
1 parent 1299d15 commit 5519977

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

utils/build-script-impl

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,26 +2822,37 @@ for host in "${ALL_HOSTS[@]}"; do
28222822
# tree... but we are not building llvm with libcxx in tree when we build
28232823
# swift. So we need to do configure's work here.
28242824
if [[ "${product}" == "llvm" ]]; then
2825-
# Find the location of the c++ header dir.
28262825
if [[ "$(uname -s)" == "Darwin" ]] ; then
2827-
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
2828-
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
2829-
elif [[ "$(uname -s)" == "Haiku" ]] ; then
2830-
HOST_CXX_HEADERS_DIR="/boot/system/develop/headers/c++"
2831-
elif [[ "${ANDROID_DATA}" ]] ; then
2832-
# This means we're building natively on Android in the Termux
2833-
# app, which supplies the $PREFIX variable.
2834-
HOST_CXX_HEADERS_DIR="$PREFIX/include/c++"
2835-
else # Linux
2836-
HOST_CXX_HEADERS_DIR="/usr/include/c++"
2826+
# We don't need this for Darwin since libcxx is present in SDKs present
2827+
# in Xcode 12.5 and onward (build-script requires Xcode 13.0 at a minimum),
2828+
# and clang knows how to find it there
2829+
# However, we should take care of removing the symlink
2830+
# laid down by a previous invocation, so to avoid failures
2831+
# finding c++ headers should the target folder become invalid
2832+
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include/c++"
2833+
if [ -L "$BUILT_CXX_INCLUDE_DIR" ]; then
2834+
echo "removing the symlink to system headers in the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
2835+
call unlink "$BUILT_CXX_INCLUDE_DIR"
2836+
fi
2837+
else
2838+
# Find the location of the c++ header dir.
2839+
if [[ "$(uname -s)" == "Haiku" ]] ; then
2840+
HOST_CXX_HEADERS_DIR="/boot/system/develop/headers/c++"
2841+
elif [[ "${ANDROID_DATA}" ]] ; then
2842+
# This means we're building natively on Android in the Termux
2843+
# app, which supplies the $PREFIX variable.
2844+
HOST_CXX_HEADERS_DIR="$PREFIX/include/c++"
2845+
else # Linux
2846+
HOST_CXX_HEADERS_DIR="/usr/include/c++"
2847+
fi
2848+
2849+
# Find the path in which the local clang build is expecting to find
2850+
# the c++ header files.
2851+
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"
2852+
2853+
echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
2854+
call ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
28372855
fi
2838-
2839-
# Find the path in which the local clang build is expecting to find
2840-
# the c++ header files.
2841-
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"
2842-
2843-
echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
2844-
call ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
28452856
fi
28462857

28472858
# Build.

0 commit comments

Comments
 (0)