Skip to content

[cmake] Allow overriding SwiftCompilerSources arguments from CMake. #70134

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

Conversation

drodriguez
Copy link
Contributor

The calculated arguments for compiling the SwiftCompilerSources works in the cases where the sysroot of the machine building the code is / or can be provided as a single directory in SWIFT_SDK_<HOST>_<ARCH>_PATH. For some cases in which a sysroot is split into multiple directories or in some cross-compiling scenarios where the SDK layout is beyond our control, we can provide more flexibility in the build system.

The changes in this commit moves the calculations around the SDK and libc++ outside the add_swift_compiler_modules_library, since they do not depend on the inputs. Some calculations relative to -resource-dir depend on the Swift compiler path, which cannot be moved outside the function.

The calculations outside the function are stored in a cached variable, which is later used in the function. If the need arise, anyone can provide a custom value for that variable in their CMake invocation or cache files adapted for their specific case and override the automatically calculated default.

I also rewrote a couple of set(list ${list} …) into list(APPEND list …).

This should be NFC for the Swift CI, because no value of SWIFT_COMPILER_SOURCES_SDK_FLAGS is provided, and the default should be the same value as before.

The calculated arguments for compiling the SwiftCompilerSources works in
the cases where the sysroot of the machine building the code is `/` or
can be provided as a single directory in `SWIFT_SDK_<HOST>_<ARCH>_PATH`.
For some cases in which a sysroot is split into multiple directories or
in some cross-compiling scenarios where the SDK layout is beyond our
control, we can provide more flexibility in the build system.

The changes in this commit moves the calculations around the SDK and
libc++ outside the `add_swift_compiler_modules_library`, since they do
not depend on the inputs. Some calculations relative to `-resource-dir`
depend on the Swift compiler path, which cannot be moved outside the
function.

The calculations outside the function are stored in a cached variable,
which is later used in the function. If the need arise, anyone can
provide a custom value for that variable in their CMake invocation or
cache files adapted for their specific case and override the
automatically calculated default.

I also rewrote a couple of `set(list ${list} …)` into `list(APPEND
list …)`.

This should be NFC for the Swift CI, because no value of
`SWIFT_COMPILER_SOURCES_SDK_FLAGS` is provided, and the default should
be the same value as before.
@drodriguez
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants