Description of the bug:
If a library (without alwayslink = True) is exported by a cc_shared_library but unused, the linker drops the library. This is problematic since if a shared library (A) depends on a shared library (B), it expects any of its dependencies that are exported by B to be fulfilled by B, and therefore does not link them into A. The only way of avoiding this is to specify this dropped library in deps.
I would expect libraries that match the exports filter to be treated as if they were alwayslink, i.e. not put them inside -Wl,--start-lib and -Wl,--end-lib.
There is a slack thread about this here: https://bazelbuild.slack.com/archives/CGA9QFQ8H/p1701702759075819
Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I have created a reproducer of this issue here: https://github.com/cameron-martin/bazel-7-cc-shared-library-dropping-exported
Running bazel build //:bin reproduces this error, getting a linker error due to the dropped library.
Which operating system are you running Bazel on?
Ubuntu 20.04
What is the output of bazel info release?
release 7.0.0rc5
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
Description of the bug:
If a library (without
alwayslink = True) is exported by a cc_shared_library but unused, the linker drops the library. This is problematic since if a shared library (A) depends on a shared library (B), it expects any of its dependencies that are exported byBto be fulfilled byB, and therefore does not link them intoA. The only way of avoiding this is to specify this dropped library indeps.I would expect libraries that match the exports filter to be treated as if they were alwayslink, i.e. not put them inside
-Wl,--start-liband-Wl,--end-lib.There is a slack thread about this here: https://bazelbuild.slack.com/archives/CGA9QFQ8H/p1701702759075819
Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I have created a reproducer of this issue here: https://github.com/cameron-martin/bazel-7-cc-shared-library-dropping-exported
Running
bazel build //:binreproduces this error, getting a linker error due to the dropped library.Which operating system are you running Bazel on?
Ubuntu 20.04
What is the output of
bazel info release?release 7.0.0rc5
If
bazel info releasereturnsdevelopment versionor(@non-git), tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response