-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CMake] Allow *only* static stdlib to be built #2431
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
Conversation
06b8047
to
b2f7d5f
Compare
@swift-ci test |
@modocache On Linux we get this failure:
|
b2f7d5f
to
aea3c01
Compare
@swift-ci please test |
option(SWIFT_BUILD_STDLIB | ||
"Build the Swift standard library (independent of the SDK headers)" | ||
TRUE) | ||
|
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.
Sorry, the names are confusing here. This option controls the build of the core standard library (stdlib/public/CMakeLists.txt
):
if(SWIFT_BUILD_STDLIB)
# These must be kept in dependency order so that any referenced targets
# exist at the time we look for them in add_swift_*.
add_subdirectory(SwiftShims)
add_subdirectory(runtime)
add_subdirectory(stubs)
add_subdirectory(core)
add_subdirectory(SwiftOnoneSupport)
add_subdirectory(Reflection)
add_subdirectory(SwiftRemoteMirror)
endif()
The variables allow building just the compiler, or the compiler + core library, or just the SDK overlay using an existing compiler.
Shouldn't the SDK overlay also come in both static and non-static variants? |
Aha, I see... I'll take another look at this. I hadn't looked too closely at the SDK overlay parts. I'll try to address:
Does that sound reasonable? |
@modocache Absolutely! I think it would be best if we had orthogonal options for:
|
aea3c01
to
2827d1c
Compare
Sorry for the lack of updates here. I'm still working on this, but things get tricky since different sets of options work or fail based on whether it's a "clean" build or not. On
With this pull request:
The major difference being that these changes don't allow building just the SDK overlay, whereas on I understand that it's desirable to build just the SDK overlay, so I'm working on that. (I'm still trying to figure out how |
Sorry, I didn't give you the full information. The way we use this mode is by disabling the compiler build as well, and using the compiler that was built during the time when the standard library was built. Basically, we build in two steps, first is compiler+stdlib, and then SDK overlay that uses the build products from the previous step that are already installed into Xcode.app. For the second step we have a preset that goes like this:
|
2827d1c
to
3919f10
Compare
Prior to these changes, it was only possible to build static libraries for the standard library and SDK overlays if *also* building dynamic libraries. This is problematic if, for example, you wanted to defer the linking of the standard library build products until later. These changes allow you to build *only* static libraries, using something like the following command: ``` $ utils/build-script -R --skip-build-benchmarks \ -- --build-swift-static-stdlib=1 --build-swift-dynamic-stdlib=0 ```
3919f10
to
6a1c981
Compare
set(all_library_targets) | ||
|
||
# First up, we conditionally add a dynamic library target. | ||
if(SWIFTLIB_IS_STDLIB OR SWIFTLIB_IS_SDK_OVERLAY) |
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.
Should this be SWIFTLIB_SINGLE_IS_STDLIB OR SWIFTLIB_SINGLE_IS_SDK_OVERLAY
?
@modocache Just wanted to say that I'm interested in getting this feature 👍 While reviewing the patch, I found some idiosyncrasies in our handling of shared/static libraries, which I have started to fix in #2809. I'm also thinking about changing the |
Oh good! Thanks, this is always good to hear. :)
Do you think it'd be simpler to update this pull request after this change is made? You wouldn't happen to have this work on a branch somewhere? |
Yes, I think it would be cleaner. The primary issue is that currently the CMake code is not set up around static/shared libraries; it builds a "primary" one (which is usually static for compiler components and shared for the standard library), and then it can build a secondary one, which is static for the standard library. I have started that work with #2809 but we're not done yet. I'm currently swamped with other things unfortunately, so if you want to pick up the refactoring to clean up shared/static/global default library marking, go for it! Just let me know so that we are not duplicating work. |
@gribozavr I think I'll try my hand at this beginning today. I created https://bugs.swift.org/browse/SR-1738 to track progress. If you have any tips, I'd really appreciate them! |
[pull] swiftwasm from main
What's in this pull request?
Prior to these changes, it was only possible to build static libraries for the standard library and SDK overlays if also building dynamic libraries. This is problematic if, for example, you wanted to defer the linking of the standard library build products until later.
These changes allow you to build only static libraries, using something like the following command:
Resolved bug number: None
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Note: Only members of the Apple organization can trigger swift-ci.