-
Notifications
You must be signed in to change notification settings - Fork 32
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
Overlapping dependencies from proto compiler and rules_swift_package_manager #1214
Comments
Another note - in case other folks happen across this issue with the same problem. I was able to overcome this issue by creating separate
|
@AttilaTheFun Didn't you recently perform some work refactoring addressing this type of overlap from third-party dependencies? |
@ed-irl I created the new swift_proto_library rule with customizable swift_proto_compiler targets specifically to address this issue. Previously, the old swift_proto_library implementation could only use the SwiftProtobuf and grpc-swift dependencies defined in the rules_swift repository. As a result, I would get duplicate symbol errors if there were differing versions of SwiftProtobuf and grpc-swift included by rules_swift and rules_swift_package_manager. The new implementation allows you to define your own swift_proto_compiler targets using whatever plugins or dependencies you want -- they don't even need to be protoc based. I also updated this repository to add a directive to specify which compiler targets to add to the generated swift_proto_library targets. @cgrindel I actually have an old PR that never merged demonstrating this feature: I was not able to merge that previously, because on Ubuntu the Swift Atomics library crashes without the always link flag. In order to merge that PR, we need to add the alwayslink flag to the generated swift_library targets. I'm not sure if there is a good heuristic for when it is necessary. If there is a way to patch the generated build file with RSPM, I could fix it that way too. |
A good heuristic does not come to mind. Perhaps we can add a bzlmod tag class that allows a client to configure attributes for Swift products. That having been said, I am trying to understand why this case requires the flag. 🤔 |
@cgrindel It was specifically the ManagedAtomic type in swift atomics that was failing on ubuntu. I think the flag was not necessary on apple platforms because their linker has different default behavior. The flag controls whether the linker should ignore object files that are unreferenced elsewhere in the program. In Swift, you can extend types to conform to a protocol outside of their defining file / module. I believe in this case an extension was "falling off" and the program was crashing at runtime. There was some discussion around whether this should just be the default for swift_library. As for RSPM, I think a tag class that allows this to be configured on a per-dependency basis sounds good. If you add that, I'm happy to rebase the PR and get it working again. https://stackoverflow.com/questions/48653517/what-does-bazel-alwayslink-true-mean |
It is probably worth capturing the build options from SPM to see how it builds the packages in question. Usually issues with missing symbols have to do with the deployment of shared libraries. That does not seem relevant here. 🤔 |
@cgrindel I did actually diff the flags when going down that rabbit hole. IIRC the flags weren't meaningfully different (before I added the alwayslink flag), but Apple ships a modified LLVM toolchain with Xcode, so their linker has different default behavior. On ubuntu we were using the vanilla LLVM and swiftc, so we needed the flag. |
Hello,
I have a project where I rely on Swift NIO directly within my library. I also have some code that uses swift GRPC.
The swift_proto_library rule contributes a bunch of dependencies (collectively called
non_module_deps
) that overlap with myrules_swift_package_manager
dependencies. I've attached bazel query png's that show an example of where this happens in my project with the Swift Atomics dependency.The result is a bunch of compilation errors about overlapping module names. For example:
rules_jvm_external
has an Override generated targets feature where some external dependencies can be mapped to different labels. It would be helpful to have such an override mechanism available inrules_swift_package_manager
.The text was updated successfully, but these errors were encountered: