Skip to content

Commit c74884c

Browse files
committed
[build] Make it possible to actually build the stdlib with a prebuilt clang
1 parent bd81fb8 commit c74884c

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,14 @@ else()
487487
set(SWIFT_CROSS_COMPILING TRUE)
488488
endif()
489489

490+
# Check if a prebuilt clang path was passed in, as this variable will be
491+
# assigned if not, in SwiftSharedCMakeConfig.
492+
if("${SWIFT_NATIVE_CLANG_TOOLS_PATH}" STREQUAL "")
493+
set(SWIFT_PREBUILT_CLANG FALSE)
494+
else()
495+
set(SWIFT_PREBUILT_CLANG TRUE)
496+
endif()
497+
490498
include(SwiftSharedCMakeConfig)
491499

492500
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,8 @@ function(add_swift_target_library name)
16691669
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides")
16701670
endif()
16711671

1672-
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE)
1672+
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND
1673+
NOT SWIFT_PREBUILT_CLANG)
16731674
list(APPEND SWIFTLIB_DEPENDS clang)
16741675
endif()
16751676

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ endif()
111111
# First extract the "version" used for Clang's resource directory.
112112
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
113113
"${LLVM_PACKAGE_VERSION}")
114-
if(NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
114+
if(NOT SWIFT_INCLUDE_TOOLS AND
115+
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
115116
if(SWIFT_COMPILER_IS_MSVC_LIKE)
116117
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
117118
OUTPUT_VARIABLE clang_headers_location

utils/build-presets.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,10 +2283,9 @@ skip-build-cmark
22832283
skip-build-benchmarks
22842284
skip-test-cmark
22852285

2286-
# This triggers the stdlib standalone build: Don't build tools (the compiler),
2287-
# assume we are working with the host compiler.
2286+
# This triggers the stdlib standalone build: don't build the native tools from
2287+
# scratch, ie the compiler.
22882288
build-swift-tools=0
2289-
build-runtime-with-host-compiler=1
22902289

22912290
# Then set the paths to our native tools. If compiling against a toolchain,
22922291
# these should all be the ./usr/bin directory.

utils/build-script-impl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,13 +1485,6 @@ for host in "${ALL_HOSTS[@]}"; do
14851485
fi
14861486
fi
14871487

1488-
if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
1489-
common_cmake_options_host+=(
1490-
-DCMAKE_C_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang"
1491-
-DCMAKE_CXX_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang++"
1492-
)
1493-
fi
1494-
14951488
llvm_cmake_options=(
14961489
"${llvm_cmake_options[@]}"
14971490
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"

0 commit comments

Comments
 (0)