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

Introduce static library product #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

s1ddok
Copy link

@s1ddok s1ddok commented Jan 8, 2019

This is particularly useful when creating standalone executables. Generated Xcode project doesn't support this AFAICS, but swift build handles it just right.

@CodaFi
Copy link
Member

CodaFi commented Jan 8, 2019

Do you have a hard requirement for this to be a static library? If not, we can just switch the existing product to automatic instead of adding another.

@s1ddok
Copy link
Author

s1ddok commented Jan 8, 2019

I just saw this pattern in SwiftPM docs:

let package = Package(
    name: "Paper",
    products: [
        .executable(name: "tool", targets: ["tool"]),
        .library(name: "Paper", targets: ["Paper"]),
        .library(name: "PaperStatic", type: .static, targets: ["Paper"]),
        .library(name: "PaperDynamic", type: .dynamic, targets: ["Paper"]),
    ],

...

I just want to explicitly cite in my Package.swift that ClangSwift is statically linked hence llvm doesn't need to be installed on the host machine

@CodaFi
Copy link
Member

CodaFi commented Jan 8, 2019

The package manager is going to build a copy of this library if it’s cited as a dependency at least once, no matter if it’s static or dynamic. The way around this would be distributing a static archive, but that’s inherently dangerous and unsupported.

@s1ddok
Copy link
Author

s1ddok commented Jan 8, 2019

Does introducing additional explicit products for Static/Dynamic linkage actually create any problems?

I guess SwiftPM will only build the products that are used as a dependency, so adding those additional ones looks like giving a bit more control to library users, no?

@CodaFi
Copy link
Member

CodaFi commented Jan 8, 2019

It’s not that it creates problems, just that it’s simpler to let the package manager sort these things out if we can help it. FWIW, the current package manager tries to statically link automatic targets as much as possible.

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.

2 participants