Add opt-out from merging cc_lib object files in bindgen #2959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a ~rollback of
#2590, as it turns out the current behavior is incomatible with
https://bazel.build/docs/user-manual#dynamic-mode (which is very hard to use in the OSS because of
bazelbuild/bazel#4135).
In short, the dynamic mode works as follows:
--start-lib
/--end-lib
to the linker),The motivation for this is to avoid lengthy linking actions when all that has changed between previous build is the method body (therefore Bazel produces the same interface library, so we don't need to reexecute linking action).
We do not support dynamic mode in rules_rust yet.
The current bindgen behavior works by taking object from
cc_lib
, and merging them into therlib
output. When dynamic_mode is on, we now have a linking action that has the rlib early on the command line, and then interface libraries of dependencies of thecc_lib
, and then the interface library of thecc_lib
. For reasons, lld prefers statically defined symbols, it sees that therlib
defines the same symbols ascc_lib
but statically, and errors out withbackward reference detected
, even thoughcc_lib
is positioned correctly.The fix for us is to not merge objects.