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-6091] Module linked multiple times if dylib is importing same module that main executable does #4939

Closed
swift-ci opened this issue Oct 8, 2017 · 3 comments
Labels

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Oct 8, 2017

Previous ID SR-6091
Radar rdar://problem/23270646
Original Reporter Lope (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

macos, swift 4.0

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

md5: 1039833999745eed5a7ff22b2c7d505f

duplicates:

  • SR-674 swiftpm should expose a way to set rpath

Issue Description:

I noticed I am getting Class X.Y is implemented in both A and B when loading dylib importing module X while main module (the one that loads dylib) is importing same module X.

I created PluginInterface module that is supposed dynamically linked to PluginImplementation package which will create dylib. Then I created PluginConsumer package that loads libPluginImplementation.dylib and imports PluginInterface to be able to comunicate with the plugin. When I run PluginConsumer, I get mentioned error when I load dylib:

objc[66212]: Class _TtC15PluginInterface15PluginInterface is implemented in both /Users/Lope/Dev/swift/SwiftPlugins/PluginConsumer/.build/x86_64-apple-macosx10.10/debug/libPluginInterface.dylib (0x10fc7b668) and /Users/Lope/Dev/swift/SwiftPlugins/PluginImplementation/.build/x86_64-apple-macosx10.10/debug/libPluginInterface.dylib (0x1107dd668). One of the two will be used. Which one is undefined.

You can find all three packages in following repositories:

https://github.com/Lopdo/SwiftPlugins-PluginInterface

https://github.com/Lopdo/SwiftPlugins-PluginImplementation

https://github.com/Lopdo/SwiftPlugins-PluginConsumer

@belkadan
Copy link

belkadan commented Oct 9, 2017

In Xcode you would resolve this by not embedding the dylib in the implementation plugin, but I'm not sure how to do this in the package manager.

@aciidb0mb3r
Copy link
Member

aciidb0mb3r commented Oct 13, 2017

@swift-ci create

@aciidb0mb3r
Copy link
Member

aciidb0mb3r commented Oct 13, 2017

The problem is, SwiftPM does not support rpath right now. You can fix the rpath of your plugin with a command like this:

$ install_name_tool -change /private/tmp/SwiftPlugins-PluginImplementation/.build/x86_64-apple-macosx10.10/debug/libPluginInterface.dylib "@executable_path/libPluginInterface.dylib" .build/x86_64-apple-macosx10.10/debug/libPluginImplementation.dylib

@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
This issue was closed.
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

3 participants