Skip to content

[Build] Add the new fully-static Linux SDK. #73455

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
merged 3 commits into from
May 7, 2024

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented May 6, 2024

Declare a new LINUX_STATIC SDK and configure it.

Add options to set the build architectures for the LINUX and LINUX_STATIC SDKs, similar to what we have for Darwin, because we'll be cross-compiling.

Also add an option to point the build system at the sources for the musl C library, which we're using for LINUX_STATIC.

rdar://123503470

[Build] Add the new fully-static Linux SDK.
@al45tair al45tair added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels May 6, 2024
@al45tair al45tair requested a review from a team as a code owner May 6, 2024 16:37
@al45tair
Copy link
Contributor Author

al45tair commented May 6, 2024

Explanation: Adds the fully statically linked Linux SDK to the build system.
Original PR: #71839
Risk: Low. This adds an SDK to the CMake SDK system that is only used by the fully static configuration.
Reviewed by: @edymtt
Resolves: rdar://123503470
Tests: The Python changes do have some tests associated with them. The rest is only applicable if you explicitly ask build-script to build the standard library for the fully statically linked Linux configuration, which will have its own CI job with its own tests when we're done.

@al45tair
Copy link
Contributor Author

al45tair commented May 6, 2024

@swift-ci Please test

When SWIFT_BUILD_STATIC_STDLIB=ON, SWIFT_BUILD_DYNAMIC_STDLIB=OFF, and
the sdk being built is not a static-only (e.g. WASI), the build fails
due to duplicate custom command rules against the same output path.
In the case of WASI, the static archive should be copied into lib/swift
by the first lipo target, and then the second lipo target should copy it
into lib/swift_static.

```
CMake Error at cmake/modules/SwiftAddCustomCommandTarget.cmake:144 (add_custom_command):
  Attempt to add a custom rule to output

    /home/build-user/build/buildbot_linux/wasmstdlib-linux-x86_64/lib/swift_static/wasi/libswiftCore.a.rule

  which already has a custom rule.
Call Stack (most recent call first):
  stdlib/cmake/modules/AddSwiftStdlib.cmake:673 (add_custom_command_target)
  stdlib/cmake/modules/AddSwiftStdlib.cmake:2657 (_add_swift_lipo_target)
  stdlib/public/core/CMakeLists.txt:401 (add_swift_target_library)
```
@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

Cherry picked this fix: #73474

@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

@swift-ci Please test

In swiftlang#72061 the test was modified because LLD and Gold linker map formats
are different, so they need different CHECKs. The original method in
PR swiftlang#72061 presents problems when the output is not exactly only one
line.

These changes use the first line of the linker map file to decide if the
Gold or the LLD linker map checks should be used, since the format
differs in both for the first line.

This way of checking works in my Linux machine when using the default
linker, when forcing Gold with `-use-ld=gold` and when forcing LLD with
`-use-ld=lld`.
@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

And this one too: #73470

@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

@swift-ci Please test

@al45tair al45tair merged commit de7313d into swiftlang:release/6.0 May 7, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants