Skip to content

[CMake] Add cross-compilation flags for when built as part of the compiler #2509

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions cmake/modules/AddSwiftHostLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ function(add_swift_syntax_library name)
$<$<COMPILE_LANGUAGE:Swift>:-color-diagnostics>
)

if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
Copy link
Contributor

Choose a reason for hiding this comment

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

As I've mentioned in the other PRs - the goal is to require a builder toolchain, fully remove BOOTSTRAPPING_MODE, and to properly run multiple CMake invocations. We are moving towards that goal, but adding more references bootstrapping everywhere is opposite to the direction we want to go.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're going to have to clarify what you mean here, as I did on that other pull of yours.

fully remove BOOTSTRAPPING_MODE

You said earlier that you want to remove two of the options for BOOTSTRAPPING_MODE, BOOTSTRAPPING and BOOTSTRAPPING-WITH-HOSTLIBS. When I responded that that was fine but that we'd still need to differentiate between the other three options listed there, you didn't respond.

properly run multiple CMake invocations

No idea what this refers to, as building a cross-compiled toolchain like this already involves dozens of CMake invocations, a couple times for each Swift repo.

adding more references bootstrapping everywhere is opposite to the direction we want to go.

This is a single reference, because this is the build variable that currently exists to do it. Whenever you replace this build variable in the future, we can easily update this to use your new scheme.

target_compile_options(${name} PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:-sdk;${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH};>
$<$<COMPILE_LANGUAGE:Swift>:-resource-dir;${SWIFTLIB_DIR};>)
if(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-tools-directory;${tools_path};>)
endif()
endif()

if(LLVM_USE_LINKER)
target_link_options(${name} PRIVATE
"-use-ld=${LLVM_USE_LINKER}"
Expand Down