Skip to content

Fix support for building with --static-swift-stdlib for armv7 #194

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

xtremekforever
Copy link
Contributor

The atomic library is used in the Swift stdlib for 32-bit architectures. As such, when attempting to compile a binary containing the static Swift stdlib using a Swift SDK for armv7, -latomic must be linked. This is not needed for regular cross-compilation, just when passing --static-swift-stdlib.

I've added -latomic for "armv7" and added a test case in LinuxRecipeTests to ensure that it is included in the toolset.json file.

Now, I can build my binary that contains the statically linked Swift stdlib with this command:

swift build --swift-sdk 6.0.3-RELEASE_debian_bookworm_armv7 --static-swift-stdlib

This generates a rather large binary when also linking other things such as Foundation and Dispatch, as is to be expected:

$ pwd
~/tmp/hummingbird-examples/hello
$ du -hs .build/debug/App
123M	.build/debug/App

But that's fine, because it works perfectly on the target (Raspberry Pi 2) and provides yet another option for compiling binaries using the Swift SDK.

 - This is required to statically link the Swift stdlib when cross-compiling to armv7
Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the i686 nit

@MaxDesiatov MaxDesiatov requested a review from euanh March 3, 2025 09:07
@MaxDesiatov MaxDesiatov added the bug Something isn't working label Mar 3, 2025
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) March 3, 2025 12:48
@MaxDesiatov MaxDesiatov merged commit b9d611f into swiftlang:main Mar 3, 2025
2 of 3 checks passed
@xtremekforever xtremekforever deleted the feature/static-swift-sdk-armv7 branch March 3, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants