Skip to content

Commit 4b039d3

Browse files
committed
[cmake] Link in the toolchain c++ headers after running LLVM cmake but before the LLVM build.
When we are building LLVM create symlinks to the c++ headers. We need to do this before building LLVM since compiler-rt depends on being built with the just built clang compiler. These are normally put into place during the cmake step of LLVM's build when libcxx is in tree... but we are not building llvm with libcxx in tree when we build swift. So we need to do cmake's work here. rdar://26284108
1 parent 29fa5e4 commit 4b039d3

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

utils/build-script-impl

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,31 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_COMPILE_TOOLS_DEPLOYMENT_TARG
18911891
{ set +x; } 2>/dev/null
18921892
fi
18931893

1894+
# When we are building LLVM create symlinks to the c++ headers. We need
1895+
# to do this before building LLVM since compiler-rt depends on being
1896+
# built with the just built clang compiler. These are normally put into
1897+
# place during the cmake step of LLVM's build when libcxx is in
1898+
# tree... but we are not building llvm with libcxx in tree when we build
1899+
# swift. So we need to do configure's work here.
1900+
if [[ "${product}" == "llvm" ]]; then
1901+
# Find the location of the c++ header dir.
1902+
if [[ "$(uname -s)" == "Darwin" ]] ; then
1903+
HOST_CXX_DIR=$(dirname ${HOST_CXX})
1904+
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
1905+
else # Linux
1906+
HOST_CXX_HEADERS_DIR="/usr/include/c++"
1907+
fi
1908+
1909+
# Find the path in which the local clang build is expecting to find
1910+
# the c++ header files.
1911+
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"
1912+
1913+
echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
1914+
set -x
1915+
ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
1916+
{ set +x; } 2>/dev/null
1917+
fi
1918+
18941919
# Build.
18951920
if [[ ! "${skip_build}" ]]; then
18961921
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
@@ -1910,26 +1935,6 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_COMPILE_TOOLS_DEPLOYMENT_TARG
19101935
${DISTCC_PUMP} "${CMAKE}" --build "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
19111936
{ set +x; } 2>/dev/null
19121937
fi
1913-
1914-
# When we are building LLVM create symlinks to the c++ headers.
1915-
if [[ "${product}" == "llvm" ]]; then
1916-
# Find the location of the c++ header dir.
1917-
if [[ "$(uname -s)" == "Darwin" ]] ; then
1918-
HOST_CXX_DIR=$(dirname ${HOST_CXX})
1919-
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
1920-
else # Linux
1921-
HOST_CXX_HEADERS_DIR="/usr/include/c++"
1922-
fi
1923-
1924-
# Find the path in which the local clang build is expecting to find
1925-
# the c++ header files.
1926-
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"
1927-
1928-
echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
1929-
set -x
1930-
ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
1931-
{ set +x; } 2>/dev/null
1932-
fi
19331938
done
19341939
done
19351940
# END OF BUILD PHASE

0 commit comments

Comments
 (0)