Avoid deduplicating linkopts of cc_shared_library dependencies.

Linker inputs for dependencies of `cc_shared_library` are currently passing their `linkopts` as a `depset`, which leads to deduplication of the flags thereby passed. Consequently, a sequence of well-formed flags like `-framework Security -framework IOKit` gets collapsed to `-framework Security IOKit`; the linker then interprets `IOKit` as an object file that it's unable to locate, which yields a malformed link line.

Passing `linkopts` directly rather than wrapping it in `depset` appears to resolve the issue. I've added a test that replicates the original issue; since `-framework` isn't meaningful on all platforms, I've only enabled it for MacOS.

Note that the tests in this repository utilize the `rules_cc` repository rather than the built-in rules; therefore, I don't think the new test can be expected to pass until the change has been propagated there, and the controlling [`MODULE.bazel.lock` entry](https://github.com/bazelbuild/bazel/blob/HEAD/src/test/tools/bzlmod/MODULE.bazel.lock#L113) has been updated. I've tested it locally by `cat`ing a `local_path_override` directive to the `MODULE.bazel` file that [gets synthesized](https://github.com/bazelbuild/bazel/blob/e887cfbfd641f57a3cdd950249daf9b568ebaeb5/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh#L49) for these tests, in order to point the tests towards a local fork of `rules_cc` with this same change applied; under these conditions, the test passes.

Closes #27735.

Closes #27755.

PiperOrigin-RevId: 845984933
Change-Id: I5606b9f6f61e699f829d19bd34cb672026d50e50
4 files changed
tree: 529178958ba7cae65845d20d72f73c96410dfc24
  1. .bazelci/
  2. .devcontainer/
  3. .gemini/
  4. .github/
  5. docs/
  6. examples/
  7. scripts/
  8. site/
  9. src/
  10. third_party/
  11. tools/
  12. .bazelrc
  13. .bazelversion
  14. .gitattributes
  15. .gitignore
  16. AUTHORS
  17. bazel_downloader.cfg
  18. BUILD
  19. CHANGELOG.md
  20. CODE_OF_CONDUCT.md
  21. CODEOWNERS
  22. combine_distfiles.py
  23. combine_distfiles_to_tar.sh
  24. compile.sh
  25. CONTRIBUTING.md
  26. CONTRIBUTORS
  27. distdir.bzl
  28. extensions.bzl
  29. LICENSE
  30. maven_install.json
  31. MODULE.bazel
  32. MODULE.bazel.lock
  33. pyproject.toml
  34. README.md
  35. repositories.bzl
  36. requirements.txt
  37. SECURITY.md
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Reporting a Vulnerability

To report a security issue, please email security@bazel.build with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.

Contributing to Bazel

See CONTRIBUTING.md

Build status