https://github.com/bazelbuild/bazel/issues/4057 has reappeared with Bazel 7
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
Building a `cc_library` without symbols now prints a warning (due to the switch to the Unix CC toolchain in Bazel 7 on macOS).
### 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.
Same as https://github.com/bazelbuild/bazel/issues/4057: create a trivial workspace with an empty `empty.c` and a BUILD file like:
```python
cc_library(
name = "empty",
srcs = ["empty.c"],
linkstatic = 1,
)
```
Then, `bazel build //:empty` will print a warning like
```
INFO: From Linking libempty.a:
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: bazel-out/darwin_arm64-fastbuild/bin/libempty.a the table of contents is empty (no object file members in the library define global symbols)
```
This doesn't happen in Bazel 6 (which uses the Xcode toolchain by default, where this issue has been fixed by https://github.com/bazelbuild/bazel/issues/4057 and/or https://github.com/bazelbuild/bazel/issues/5981).
### Which operating system are you running Bazel on?
macOS 14.2.1 (23C71)
### What is the output of `bazel info release`?
release 7.0.1
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
N/A
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
```text
N/A
```
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Technically a regression (no warning in Bazel 6), though this probably was always present in the Unix toolchain.
### Have you found anything relevant by searching the web?
Same as https://github.com/bazelbuild/bazel/issues/4057 and https://github.com/bazelbuild/bazel/issues/5981, just for the Unix toolchain instead of the Xcode one.
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with the Unix CC toolchain and reproduce the issue using the empty.c and BUILD example with Bazel 7.0.1 on macOS. Compare the archive-linking behavior with Bazel 6 and the earlier Xcode-toolchain issues 4057 and 5981. Done means building the empty cc_library no longer prints the empty-table-of-contents warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, macos
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100