-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[build] Make it possible to actually build the stdlib with a prebuilt clang #34628
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
Changes from all commits
bd81fb8
c74884c
934823a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,10 +481,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD) | |
endif() | ||
message(STATUS "") | ||
|
||
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "") | ||
set(SWIFT_CROSS_COMPILING FALSE) | ||
# Check if a prebuilt clang path was passed in, as this variable will be | ||
# assigned if not, in SwiftSharedCMakeConfig. | ||
if("${SWIFT_NATIVE_CLANG_TOOLS_PATH}" STREQUAL "") | ||
set(SWIFT_PREBUILT_CLANG FALSE) | ||
else() | ||
set(SWIFT_CROSS_COMPILING TRUE) | ||
set(SWIFT_PREBUILT_CLANG TRUE) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to prefer this over just using standard CMAKE_C{,XX}_COMPILER? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, because the compiler and stdlib are built using potentially three clang compilers: the |
||
|
||
include(SwiftSharedCMakeConfig) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1669,7 +1669,8 @@ function(add_swift_target_library name) | |
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides") | ||
endif() | ||
|
||
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE) | ||
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND | ||
NOT SWIFT_PREBUILT_CLANG) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gottesmm, I'm guessing you passed in |
||
list(APPEND SWIFTLIB_DEPENDS clang) | ||
endif() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,8 @@ endif() | |
# First extract the "version" used for Clang's resource directory. | ||
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION | ||
"${LLVM_PACKAGE_VERSION}") | ||
if(NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER) | ||
if(NOT SWIFT_INCLUDE_TOOLS AND | ||
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gottesmm and @shahmishal, should this be using the passed-in prebuilt compiler's resource directory even when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code path uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is still using it, it may help if you look at all three commits in this pull together. I agree that all the
I'm only removing that third invocation he added in this pull, |
||
if(SWIFT_COMPILER_IS_MSVC_LIKE) | ||
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir | ||
OUTPUT_VARIABLE clang_headers_location | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,8 +167,11 @@ def install_toolchain_path(self, host_target): | |
"""toolchain_path() -> string | ||
|
||
Returns the path to the toolchain that is being created as part of this | ||
build. | ||
build, or to a native prebuilt toolchain that was passed in. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebased and updated this comment. |
||
""" | ||
if self.args.native_swift_tools_path is not None: | ||
return os.path.split(self.args.native_swift_tools_path)[0] | ||
|
||
install_destdir = self.args.install_destdir | ||
if self.args.cross_compile_hosts: | ||
build_root = os.path.dirname(self.build_dir) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahmishal, I believe the only reason this was set was because
SWIFT_NATIVE_LLVM_TOOLS_PATH
was used to find clang instdlib/CMakeLists.txt
below. However, since that was a mistake that I tried to fix in #34437, I now use this clang path check andSWIFT_PREBUILT_CLANG
here and incmake/modules/SwiftSharedCMakeConfig.cmake
instead. I believe thisSWIFT_PREBUILT_CLANG
is a better variable name as the clang might not just be passed in for cross-compiling, but also for natively building the standalone stdlib, as this pull was originally meant for.