Skip to content

Build and install 'clang' and 'clangd' in the macOS & linux toolchains #22184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ install-swiftpm
install-xctest
install-libicu
install-prefix=/usr
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;license;sourcekit-inproc
llvm-install-components=llvm-cov;llvm-profdata;IndexStore
swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;license;sourcekit-inproc
llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt;clangd
build-swift-static-stdlib
build-swift-static-sdk-overlay
build-swift-stdlib-unittest-extra
Expand Down Expand Up @@ -1080,8 +1080,8 @@ test-installable-package
# If someone uses this for incremental builds, force reconfiguration.
reconfigure

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

# Path to the .tar.gz package we would create.
installable-package=%(installable_package)s
Expand Down
51 changes: 51 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,12 @@ if [ ! -d "${CLANG_SOURCE_DIR}" ] ; then
make_relative_symlink "${WORKSPACE}/clang" "${CLANG_SOURCE_DIR}"
fi

# Don't symlink clang-tools-extra into the tree as the 'clang' symlink prevents
# make_relative_symlink from working correctly.
if [ -e "${WORKSPACE}/clang-tools-extra" ] ; then
CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKSPACE}/clang-tools-extra"
fi

# Symlink compiler-rt into the llvm tree, if it exists.
COMPILER_RT_SOURCE_DIR="${LLVM_SOURCE_DIR}/projects/compiler-rt"
if [ -e "${WORKSPACE}/compiler-rt" ] ; then
Expand All @@ -1226,7 +1232,16 @@ if [ -e "${WORKSPACE}/compiler-rt" ] ; then
fi
fi

# Build libcxx, unless it doesn't exist.
LIBCXX_SOURCE_DIR="${WORKSPACE}/libcxx"
if [[ ! -e "${LIBCXX_SOURCE_DIR}" ]] ; then
SKIP_BUILD_LIBCXX=1
fi

PRODUCTS=(cmark llvm)
if [[ ! "${SKIP_BUILD_LIBCXX}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" libcxx)
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I turned on --no-legacy-impl by default, this won't be enough. You need to add a Product for libcxx in build-script (the python code) so that this will be triggered. Right now it will be skipped by the check for $(should_execute_host_actions_for_phase ${host} build) below.

if [[ ! "${SKIP_BUILD_LIBICU}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" libicu)
fi
Expand Down Expand Up @@ -1572,6 +1587,10 @@ function build_directory_bin() {
llvm)
echo "${root}/${LLVM_BUILD_TYPE}/bin"
;;
libcxx)
# Reuse LLVM's build type.
echo "${root}/${LLVM_BUILD_TYPE}/bin"
;;
swift)
echo "${root}/${SWIFT_BUILD_TYPE}/bin"
;;
Expand Down Expand Up @@ -1719,6 +1738,10 @@ function cmake_config_opt() {
llvm)
echo "--config ${LLVM_BUILD_TYPE}"
;;
libcxx)
# Reuse LLVM's build type.
echo "--config ${LLVM_BUILD_TYPE}"
;;
swift)
echo "--config ${SWIFT_BUILD_TYPE}"
;;
Expand Down Expand Up @@ -2163,6 +2186,12 @@ for host in "${ALL_HOSTS[@]}"; do
"${llvm_cmake_options[@]}"
)

if [[ ! -z "${CLANG_TOOLS_EXTRA_SOURCE_DIR}" ]] ; then
cmake_options+=(
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${CLANG_TOOLS_EXTRA_SOURCE_DIR}"
)
fi

if [[ "${BUILD_TOOLCHAIN_ONLY}" ]]; then
cmake_options+=(
-DLLVM_BUILD_TOOLS=NO
Expand Down Expand Up @@ -2202,6 +2231,22 @@ for host in "${ALL_HOSTS[@]}"; do

;;

libcxx)
build_targets=(cxx-headers)
cmake_options=(
"${cmake_options[@]}"
-DCMAKE_C_FLAGS="$(llvm_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(llvm_c_flags ${host})"
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
-DCMAKE_BUILD_TYPE:STRING="${LLVM_BUILD_TYPE}"
-DLLVM_INCLUDE_DOCS:BOOL=TRUE
-DLLVM_CONFIG_PATH="$(build_directory "${LOCAL_HOST}" llvm)/bin/llvm-config"
"${llvm_cmake_options[@]}"
)

;;

swift)

if [[ ! "${SKIP_BUILD_ANDROID}" ]]; then
Expand Down Expand Up @@ -3028,6 +3073,9 @@ for host in "${ALL_HOSTS[@]}"; do
llvm)
continue # We don't test LLVM
;;
libcxx)
continue # We don't test libc++
;;
swift)
executable_target=
results_targets=
Expand Down Expand Up @@ -3524,6 +3572,9 @@ for host in "${ALL_HOSTS[@]}"; do
fi
INSTALL_TARGETS=install-$(echo ${LLVM_INSTALL_COMPONENTS} | sed -E 's/;/ install-/g')
;;
libcxx)
INSTALL_TARGETS=install-cxx-headers
;;
swift)
if [[ -z "${INSTALL_SWIFT}" ]] ; then
continue
Expand Down