Skip to content

[build-script] When building compiler-rt, follow LLVM's lead by speci… #2690

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
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
46 changes: 26 additions & 20 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ function set_deployment_target_based_options() {
-DLLVM_HOST_TRIPLE:STRING="${llvm_host_triple}"
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_COMPILER_RT})"
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_COMPILER_RT})"
-DCOMPILER_RT_ENABLE_IOS:BOOL=FALSE
-DCOMPILER_RT_ENABLE_WATCHOS:BOOL=FALSE
-DCOMPILER_RT_ENABLE_TVOS:BOOL=FALSE
Expand Down Expand Up @@ -1891,6 +1892,31 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_COMPILE_TOOLS_DEPLOYMENT_TARG
{ set +x; } 2>/dev/null
fi

# 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 configure's work here.
if [[ "${product}" == "llvm" ]]; then
# Find the location of the c++ header dir.
if [[ "$(uname -s)" == "Darwin" ]] ; then
HOST_CXX_DIR=$(dirname ${HOST_CXX})
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
else # Linux
HOST_CXX_HEADERS_DIR="/usr/include/c++"
fi

# Find the path in which the local clang build is expecting to find
# the c++ header files.
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"

echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
set -x
ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
{ set +x; } 2>/dev/null
fi

# Build.
if [[ ! "${skip_build}" ]]; then
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
Expand All @@ -1910,26 +1936,6 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_COMPILE_TOOLS_DEPLOYMENT_TARG
${DISTCC_PUMP} "${CMAKE}" --build "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
{ set +x; } 2>/dev/null
fi

# When we are building LLVM create symlinks to the c++ headers.
if [[ "${product}" == "llvm" ]]; then
# Find the location of the c++ header dir.
if [[ "$(uname -s)" == "Darwin" ]] ; then
HOST_CXX_DIR=$(dirname ${HOST_CXX})
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
else # Linux
HOST_CXX_HEADERS_DIR="/usr/include/c++"
fi

# Find the path in which the local clang build is expecting to find
# the c++ header files.
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"

echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
set -x
ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR"
{ set +x; } 2>/dev/null
fi
done
done
# END OF BUILD PHASE
Expand Down