Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ src/sta/debug/
# we use abc from MODULE.bazel
third-party/abc/
tmp
# standalone workspace for downstream consumer tests
# standalone workspaces for downstream consumer tests
test/downstream/
test/visibility/
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ cc_library(
includes = [
"include",
],
visibility = ["//:__subpackages__"],
visibility = ["//visibility:public"],
deps = [
"//src/sta:opensta_lib",
"@abseil-cpp//absl/base:core_headers",
Expand All @@ -251,7 +251,7 @@ cc_library(
"include",
"include/ord",
],
visibility = ["//:__subpackages__"],
visibility = ["//visibility:public"],
deps = ["@abseil-cpp//absl/synchronization"],
)

Expand Down
1 change: 1 addition & 0 deletions test/visibility/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.6.0
15 changes: 15 additions & 0 deletions test/visibility/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Downstream visibility smoke test.
#
# Each alias references an OpenROAD target that downstream consumers
# need. If any target has visibility restricted to //:__subpackages__,
# Bazel analysis will fail with a visibility error — proving the bug.
#
# Run: bazelisk build --nobuild :all

[alias(
name = t,
actual = "@openroad//:" + t,
) for t in [
"openroad_lib",
"ord",
]]
12 changes: 12 additions & 0 deletions test/visibility/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Minimal downstream consumer that tests Bazel visibility of OpenROAD targets."""

module(
name = "visibility-test",
version = "0.0.0",
)

bazel_dep(name = "openroad")
local_path_override(
module_name = "openroad",
path = "../..",
)
34 changes: 34 additions & 0 deletions test/visibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Bazel visibility test for downstream consumers

## Why each target is public

### `openroad_lib` (cc_library) and `ord` (cc_library — headers)

These are the core C++ library and public headers. A downstream
Bazel consumer that wants to build a custom binary linking against
the OpenROAD library (rather than just running the prebuilt
`openroad` binary) must be able to depend on these targets.

### Why NOT the SWIG filegroups

`error_swig`, `error_swig-py`, and `options_swig` stay at
`//:__subpackages__`. They are referenced by internal subpackages
(e.g. `//src/gpl:swig` depends on `//:error_swig`), which already
satisfies the `__subpackages__` visibility check. No downstream
consumer references them directly.

## How to test

```bash
cd test/visibility
bazelisk build --nobuild :all
```

If any target is not publicly visible, Bazel fails at analysis time:

```
ERROR: target '@openroad//:openroad_lib' is not visible from
target '@@visibility-test//:openroad_lib'.
```

After the fix, the command succeeds (exit 0).
Loading