Skip to content

Commit 56eb498

Browse files
committed
Build the Swift runtime using the locally built clang compliler.
This commit makes the swift build scripts use the clang that we build as part of the build process in order to build the Swift runtime, and not the host compiler. This change is necessary for using new clang features immediately after they are introduced. One example for such feature is new function calling conventions, or new c-level attributes.
1 parent 884155c commit 56eb498

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

stdlib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Create convenience targets for the Swift standard library.
2+
3+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
4+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
5+
26
add_custom_target(swift-stdlib-all)
37
foreach(SDK ${SWIFT_SDKS})
48
add_custom_target("swift-stdlib-${SWIFT_SDK_${SDK}_LIB_SUBDIR}")

utils/build-script-impl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,25 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
20652065
${DISTCC_PUMP} "${CMAKE}" --build "${build_dir}" $(cmake_config_opt ${product}) -- ${BUILD_ARGS} ${build_targets[@]}
20662066
{ set +x; } 2>/dev/null
20672067
fi
2068+
2069+
# When we are building LLVM create symlinks to the c++ headers.
2070+
if [[ "${product}" == "llvm" ]]; then
2071+
2072+
# Find the location of the c++ header dir.
2073+
if [[ "$(uname -s)" == "Darwin" ]] ; then
2074+
HOST_CXX_DIR=$(dirname ${HOST_CXX})
2075+
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
2076+
else # Linux
2077+
HOST_CXX_HEADERS_DIR="/usr/include/c++"
2078+
fi
2079+
2080+
# Find the path in which the local clang build is expecting to find
2081+
# the c++ header files.
2082+
BUILT_CXX_INCLUDE_DIR="$llvm_build_dir/include"
2083+
2084+
echo "symlinking the system headers ($HOST_CXX_HEADERS_DIR) into the local clang build directory ($BUILT_CXX_INCLUDE_DIR)."
2085+
ln -s -f "$HOST_CXX_HEADERS_DIR" "$BUILT_CXX_INCLUDE_DIR/c++"
2086+
fi
20682087
done
20692088
done
20702089
# END OF BUILD PHASE
@@ -2568,3 +2587,4 @@ if [[ "${INSTALLABLE_PACKAGE}" ]] ; then
25682587
{ set +x; } 2>/dev/null
25692588
fi
25702589
fi
2590+

0 commit comments

Comments
 (0)