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-10314] The linker fails when the package depends on another package with a specific name. #4719

Open
YOCKOW opened this issue Apr 5, 2019 · 2 comments
Labels

Comments

@YOCKOW
Copy link
Contributor

YOCKOW commented Apr 5, 2019

Previous ID SR-10314
Radar None
Original Reporter @YOCKOW
Type Bug
Environment

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)

Apple Swift Package Manager - Swift 5.0.0 (swiftpm-14490.60.2)

macOS Mojave 10.14.4

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 40c0280556a7f72372155cc3ab22649e

Issue Description:

A linker error occurs under very limited conditions.

[How to reproduce (on macOS)]

$ git clone https://github.com/YOCKOW/SwiftPMLinkerFailureDemonstration
$ cd ./SwiftPMLinkerFailureDemonstration/NetworkUser
$ swift test

Then, you can see errors like below:

Completed resolution in 0.61s
Undefined symbols for architecture x86_64:
  "_$s7Network1SVACycfC", referenced from:
      _$s11NetworkUserAAV1s0A01SVvpfi in NetworkUser.swift.o
      _$s11NetworkUserAAVABycfC in NetworkUser.swift.o
ld: symbol(s) not found for architecture x86_64
link command failed with exit code 1 (use -v to see invocation)

[Explanation]

  • There are two packages in the repository, "NetworkUser" and "PseudoNetworkModule".

  • "NetworkUser" depends on "PseudoNetworkModule".

  • As you can see in Package.swift of "PseudoNetworkModule", its package name is "Network" and library name is "SwiftNetwork". (Yes, "Network" is the same name with a new module introduced from macOS >= 10.14.)

  • Both product target and test target of "NetworkUser" import "Network".

[Discussion]

  • `swift test` in "NetworkUser" induces the linker error, however, tests with Xcode(10.2) are successful without any errors.

  • There are no errors on Linux.

  • The workaround is, of course, to change the names of "PseudoNetworkModule" 🙂

@belkadan
Copy link

belkadan commented Apr 8, 2019

Hm. I think the target name is the one that matters, which makes sense because not every target is a project, but then I wonder why we allow the target name to be different from the library name. @aciidb0mb3r?

@ankitspd
Copy link
Member

Hmm, looks like the linker is not resolving the symbols from SwiftNetwork dylib (maybe its auto linking to system Network?). It works fine if I rename the product to just "Network".

@belkadan A library can contain multiple top-level targets in the SwiftPM model.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants