cc_import ignored by Objective-C linking logic #13596
Labels
P4
This is either out of scope or we don't have bandwidth to review a PR. (No assignee)
stale
Issues or PRs that are stale (no activity for 30 days)
team-Rules-CPP
Issues for C++ rules
type: bug
If you have a
cc_import
that's depended on by a binary that goes through theapple_common.link_multi_arch_binary
codepath, it appears that the necessaryrpath
is ignored, unlike when you link something withcc_common.link
and one is added.Here's a repro case dylibrepro.zip
The gist is that we have this setup:
Where the
swift_binary
rule goes through thecc_common.link
API and themacos_command_line_application
rule goes through theapple_common.link_multi_arch_binary
API. If you runbazel run binary
, it works correctly, and you can see the binary has the expected rpaths:If you run
bazel run macos_binary
, it crashes on launch because it's missing the expected library:and you can see it has the load command but not the rpath:
In the case of Apple bundles, theoretically users can use a workaround such as the one in this PR to include the dylib as a framework instead, which will then be bundled with the executable, and by default have the right rpath, but this doesn't work for
macos_command_line_application
specifically since it isn't a bundle.I believe the core issue here is that the Objective-C linking logic ignores CcInfo providers, there was some discussion on this here #11225 and there's a comment about it here https://github.com/bazelbuild/rules_swift/blob/618151af28d1aaf04612e75c142f4b48961d5012/swift/internal/compiling.bzl#L2585-L2588
So maybe this entire issue is just dependent on migrating entirely to the CcInfo API for Objective-C binaries.
The text was updated successfully, but these errors were encountered: