Skip to content

7.0.0rc2 regression from 6.4.0 (new throw_linked_but_not_exported_errors) #19920

@peakschris

Description

@peakschris

Description of the bug:

I have a number of header-file-only libraries, and link these into a number of our shared libraries:

Since upgrading from bazel 6.4.0 to bazel 7.0.0rc2, I am getting this error:

ERROR: D:/units/cb_bazel/src/path/to/BUILD.bazel:3:21: in cc_shared_library rule //src/path/to/z:libz:
Traceback (most recent call last):
        File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 661, column 114, in _cc_shared_library_impl
        File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 527, column 42, in _filter_inputs
        File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 545, column 9, in _throw_linked_but_not_exported_errors
Error in fail: The following libraries were linked statically by different cc_shared_libraries but not exported:
cc_shared_library @@//src/path/to/lib:lib:
  "@@//src/path/to:include_root",
  "@@x//:libx_headers",
  "@@cpputils//:cpputils",
If you are sure that the previous libraries are exported by the cc_shared_libraries because:
  1. You have visibility declarations in the source code
  2. Or you are passing a visibility script to the linker to export symbols from them
then add those libraries to roots or exports_filter for each cc_shared_library.

what these dependent libraries have in common is that they are include-only:

cc_library(
    name = "cpputils",
    hdrs = glob(["include/cpputils/fmt/*.h", "include/cpputils/*.hxx"]),
    includes = ["include"],
)

Which category does this issue belong to?

C++/Objective-C Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 7.0.0rc2

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.

Yes, 6.4.0 did not have this issue

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions