Skip to content

Pass -static-stdlib for all compiler jobs #3048

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

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Nov 13, 2020

Motivation:

--static-swift-stdlib support on Linux is introduced by #2921 but it doesn't work when linking CoreFoundation.

When CoreFoundation is used on a project and a user uses --static-swift-stdlib, SwiftPM compiled object files without
-static-stdlib and linked them with that option. This mismatch of compiler option broke swift autolink mechanism.

The object files built without -static-stdlib references /lib/swift/CoreFoundation/module.map, which is intended to be used for dynamic linking, and the modulemap doesn't have link "CoreFoundation" statement. So the autolink sections in built object files doesn't have -lCoreFoundation and it causes linking failure.

This issue was reported on SR-648

Modifications:

Pass -static-stdlib for all compiler jobs

Result:

This patch changes to pass -static-stdlib for all compiler jobs if necessary. This enables to refenrece /lib/swift_static/CoreFoundation/module.map when using --static-swift-stdlib and it resolves linking failures.

--static-swift-stdlib support on Linux is introduced by swiftlang#2921
but it doesn't work when linking CoreFoundation.

When CoreFoundation is used on a project and a user uses
--static-swift-stdlib, SwiftPM compiled object files without
-static-stdlib and linked them with that option. This mismatch of
compiler option broke swift autolink mechanism.

The object files built without -static-stdlib references
`/lib/swift/CoreFoundation/module.map`, which is intended to be
used for dynamic linking, and the modulemap doesn't have
`link "CoreFoundation"` statement. So the autolink sections in built
object files doesn't have `-lCoreFoundation` and it causes linking
failure.

This patch changes to pass `-static-stdlib` for all compiler jobs if
necessary. This enables to refenrece `/lib/swift_static/CoreFoundation/module.map`
when using `--static-swift-stdlib` and it resolves linking failures.
@MaxDesiatov
Copy link
Contributor

@swift-ci please smoke test

@MaxDesiatov MaxDesiatov merged commit 83f20b2 into swiftlang:main Nov 13, 2020
federicobucchi pushed a commit to federicobucchi/swift-package-manager that referenced this pull request Jan 6, 2021
--static-swift-stdlib support on Linux is introduced by swiftlang#2921
but it doesn't work when linking CoreFoundation.

When CoreFoundation is used on a project and a user uses
--static-swift-stdlib, SwiftPM compiled object files without
-static-stdlib and linked them with that option. This mismatch of
compiler option broke swift autolink mechanism.

The object files built without -static-stdlib references
`/lib/swift/CoreFoundation/module.map`, which is intended to be
used for dynamic linking, and the modulemap doesn't have
`link "CoreFoundation"` statement. So the autolink sections in built
object files doesn't have `-lCoreFoundation` and it causes linking
failure.

This patch changes to pass `-static-stdlib` for all compiler jobs if
necessary. This enables to refenrece `/lib/swift_static/CoreFoundation/module.map`
when using `--static-swift-stdlib` and it resolves linking failures.
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.

4 participants