Skip to content
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

[SR-10701] Can't link statically (swift_static not found) #53098

Open
swift-ci opened this issue May 16, 2019 · 4 comments
Open

[SR-10701] Can't link statically (swift_static not found) #53098

swift-ci opened this issue May 16, 2019 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10701
Radar None
Original Reporter albertvaka (JIRA User)
Type Bug
Environment

Swift 5.0.1

XCode 10.2.1

macOS 10.14.5

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: fb8916176c6f61465b8d52e8215e4d2c

Issue Description:

$ echo 'print("hello")' > /tmp/test.swift
$ swiftc -o /tmp/test -static-stdlib /tmp/test.swift
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find auto-linked library 'swiftCore'
[...]

The directory `swift_static` doesn't exist. Is Swift 5 not shipping it anymore?

@swift-ci
Copy link
Collaborator Author

Comment by Albert Vaca (JIRA)

I found an explanation while running this:

$ swift build  --static-swift-stdlib
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/

So is it not possible to build a statically linked app so it runs on old systems?

@belkadan
Copy link
Contributor

Correct. Swift on Apple platforms no longer supports static linking because the standard library is shipped as part of the OS. There's a forum thread going into some more details.

I'm surprised you didn't get that message from regular swiftc though. @bob-wilson, did we not add it there?

@compnerd
Copy link
Collaborator

Hmm, should other targets be following suit? In particular, Im wondering about Windows since I never configured things to work well with static linking.

@belkadan
Copy link
Contributor

I think it's a little different because static linking cannot work when Swift is in the OS (without heroics and also behavior Apple doesn't want to provide). But if it doesn't really work on Windows, we could reject it now and see if anyone complains. I know people are using it on Linux, though.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants