Skip to content

Commit 1941aaa

Browse files
committed
Build and install 'clang' and 'clangd' in the macOS & linux toolchains
- Build script now builds clang_tools_extra as part of LLVM's build. - Build script now has a new libc++ build step to allow libc++ headers to be installed in the resulting toolchain. - 'clang', 'clangd', 'clang-headers' & 'compiler-rt' targets are now installed for the package build configurations for macOS and linux. - 'clang-resource-dir-symlink' is used in the package build configuration for macOS and linux to avoid duplication of Clang's headers and compiler-rt archives. rdar://24912710
1 parent fe9376d commit 1941aaa

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

utils/build-presets.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ install-swiftpm
728728
install-xctest
729729
install-libicu
730730
install-prefix=/usr
731-
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;license;sourcekit-inproc
732-
llvm-install-components=llvm-cov;llvm-profdata;IndexStore
731+
swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;license;sourcekit-inproc
732+
llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt;clangd
733733
build-swift-static-stdlib
734734
build-swift-static-sdk-overlay
735735
build-swift-stdlib-unittest-extra
@@ -1080,8 +1080,8 @@ test-installable-package
10801080
# If someone uses this for incremental builds, force reconfiguration.
10811081
reconfigure
10821082

1083-
swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;parser-lib;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers
1084-
llvm-install-components=llvm-cov;llvm-profdata;IndexStore
1083+
swift-install-components=compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;parser-lib;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers
1084+
llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt;clangd
10851085

10861086
# Path to the .tar.gz package we would create.
10871087
installable-package=%(installable_package)s

utils/build-script-impl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,12 @@ if [ ! -d "${CLANG_SOURCE_DIR}" ] ; then
12181218
make_relative_symlink "${WORKSPACE}/clang" "${CLANG_SOURCE_DIR}"
12191219
fi
12201220

1221+
# Don't symlink clang-tools-extra into the tree as the 'clang' symlink prevents
1222+
# make_relative_symlink from working correctly.
1223+
if [ -e "${WORKSPACE}/clang-tools-extra" ] ; then
1224+
CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKSPACE}/clang-tools-extra"
1225+
fi
1226+
12211227
# Symlink compiler-rt into the llvm tree, if it exists.
12221228
COMPILER_RT_SOURCE_DIR="${LLVM_SOURCE_DIR}/projects/compiler-rt"
12231229
if [ -e "${WORKSPACE}/compiler-rt" ] ; then
@@ -1226,7 +1232,16 @@ if [ -e "${WORKSPACE}/compiler-rt" ] ; then
12261232
fi
12271233
fi
12281234

1235+
# Build libcxx, unless it doesn't exist.
1236+
LIBCXX_SOURCE_DIR="${WORKSPACE}/libcxx"
1237+
if [[ ! -e "${LIBCXX_SOURCE_DIR}" ]] ; then
1238+
SKIP_BUILD_LIBCXX=1
1239+
fi
1240+
12291241
PRODUCTS=(cmark llvm)
1242+
if [[ ! "${SKIP_BUILD_LIBCXX}" ]] ; then
1243+
PRODUCTS=("${PRODUCTS[@]}" libcxx)
1244+
fi
12301245
if [[ ! "${SKIP_BUILD_LIBICU}" ]] ; then
12311246
PRODUCTS=("${PRODUCTS[@]}" libicu)
12321247
fi
@@ -1572,6 +1587,10 @@ function build_directory_bin() {
15721587
llvm)
15731588
echo "${root}/${LLVM_BUILD_TYPE}/bin"
15741589
;;
1590+
libcxx)
1591+
# Reuse LLVM's build type.
1592+
echo "${root}/${LLVM_BUILD_TYPE}/bin"
1593+
;;
15751594
swift)
15761595
echo "${root}/${SWIFT_BUILD_TYPE}/bin"
15771596
;;
@@ -1719,6 +1738,10 @@ function cmake_config_opt() {
17191738
llvm)
17201739
echo "--config ${LLVM_BUILD_TYPE}"
17211740
;;
1741+
libcxx)
1742+
# Reuse LLVM's build type.
1743+
echo "--config ${LLVM_BUILD_TYPE}"
1744+
;;
17221745
swift)
17231746
echo "--config ${SWIFT_BUILD_TYPE}"
17241747
;;
@@ -2163,6 +2186,12 @@ for host in "${ALL_HOSTS[@]}"; do
21632186
"${llvm_cmake_options[@]}"
21642187
)
21652188

2189+
if [[ ! -z "${CLANG_TOOLS_EXTRA_SOURCE_DIR}" ]] ; then
2190+
cmake_options+=(
2191+
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${CLANG_TOOLS_EXTRA_SOURCE_DIR}"
2192+
)
2193+
fi
2194+
21662195
if [[ "${BUILD_TOOLCHAIN_ONLY}" ]]; then
21672196
cmake_options+=(
21682197
-DLLVM_BUILD_TOOLS=NO
@@ -2202,6 +2231,22 @@ for host in "${ALL_HOSTS[@]}"; do
22022231

22032232
;;
22042233

2234+
libcxx)
2235+
build_targets=(cxx-headers)
2236+
cmake_options=(
2237+
"${cmake_options[@]}"
2238+
-DCMAKE_C_FLAGS="$(llvm_c_flags ${host})"
2239+
-DCMAKE_CXX_FLAGS="$(llvm_c_flags ${host})"
2240+
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
2241+
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
2242+
-DCMAKE_BUILD_TYPE:STRING="${LLVM_BUILD_TYPE}"
2243+
-DLLVM_INCLUDE_DOCS:BOOL=TRUE
2244+
-DLLVM_CONFIG_PATH="$(build_directory "${LOCAL_HOST}" llvm)/bin/llvm-config"
2245+
"${llvm_cmake_options[@]}"
2246+
)
2247+
2248+
;;
2249+
22052250
swift)
22062251

22072252
if [[ ! "${SKIP_BUILD_ANDROID}" ]]; then
@@ -3028,6 +3073,9 @@ for host in "${ALL_HOSTS[@]}"; do
30283073
llvm)
30293074
continue # We don't test LLVM
30303075
;;
3076+
libcxx)
3077+
continue # We don't test libc++
3078+
;;
30313079
swift)
30323080
executable_target=
30333081
results_targets=
@@ -3524,6 +3572,9 @@ for host in "${ALL_HOSTS[@]}"; do
35243572
fi
35253573
INSTALL_TARGETS=install-$(echo ${LLVM_INSTALL_COMPONENTS} | sed -E 's/;/ install-/g')
35263574
;;
3575+
libcxx)
3576+
INSTALL_TARGETS=install-cxx-headers
3577+
;;
35273578
swift)
35283579
if [[ -z "${INSTALL_SWIFT}" ]] ; then
35293580
continue

0 commit comments

Comments
 (0)