Skip to content

Commit 9483c13

Browse files
committed
Merge branch 'master' of github.com:The-OpenROAD-Project-private/OpenROAD
2 parents 1fe9ed6 + fb6bde3 commit 9483c13

23 files changed

Lines changed: 1055 additions & 82 deletions

.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,21 @@ build:ci --disk_cache=
120120
build:ci --config=opt
121121

122122
# Setup remote cache
123+
# Anon: HTTPS read-only cache
123124
build --remote_cache=https://bazel.precisioninno.com
124125
build --remote_cache_compression=true
125126
build --remote_upload_local_results=false
127+
# CI: gRPC + Remote Asset API, requires --remote_header
128+
build:ci --remote_cache=grpcs://bazel.precisioninno.com:443
129+
build:ci --experimental_remote_downloader=grpcs://bazel.precisioninno.com:443
126130

127131
# Without this, bazelisk build ... builds the bazel-orfs tests
128132
build --build_tag_filters=-orfs
129133

134+
# clang-tidy via aspect_rules_lint, using clang-tidy from the LLVM toolchain.
135+
# Usage: bazel build --config=lint //src/utl/...
136+
build:lint --aspects=//tools/lint:linters.bzl%clang_tidy
137+
build:lint --output_groups=rules_lint_report
138+
build:lint --remote_download_outputs=all
139+
130140
try-import %workspace%/user.bazelrc

.github/workflows/github-actions-macos-bazel.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,31 @@ jobs:
3434
run: brew install bazelisk
3535

3636
- name: Build OpenROAD
37+
env:
38+
BAZEL_CACHE_PASSWORD: ${{ secrets.BAZEL_CACHE_PASSWORD }}
3739
run: |
40+
# When the secret is present (push / dispatch / private repo PR)
41+
# add authed gRPC + Remote Asset API + uploads on top of the
42+
# .bazelrc anon HTTPS read-only cache. Fork PRs have no secret
43+
# and just use the anon read path.
44+
REMOTE_FLAGS=()
45+
if [ -n "${BAZEL_CACHE_PASSWORD}" ]; then
46+
TOKEN_B64=$(printf 'ci:%s' "${BAZEL_CACHE_PASSWORD}" | base64 | tr -d '\n')
47+
# Mask the derived token so it cannot leak in build logs.
48+
# GH auto-masks the raw secret but not base64-of-secret.
49+
echo "::add-mask::${TOKEN_B64}"
50+
REMOTE_FLAGS=(
51+
--remote_cache=grpcs://bazel.precisioninno.com:443
52+
--experimental_remote_downloader=grpcs://bazel.precisioninno.com:443
53+
--remote_upload_local_results=true
54+
--remote_header="Authorization=Basic ${TOKEN_B64}"
55+
)
56+
fi
57+
# Trace the bazelisk invocation so we can confirm remote flags are
58+
# present. TOKEN_B64 is already masked above, so it prints as ***.
59+
set -x
3860
bazelisk build \
61+
"${REMOTE_FLAGS[@]}" \
3962
--disk_cache=~/.cache/bazel-disk-cache \
4063
--experimental_disk_cache_gc_max_size=5G \
4164
--//:platform=gui //:openroad

BUILD.bazel

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config_setting(
3838
)
3939

4040
exports_files([
41+
".clang-tidy",
4142
"BUILD.bazel",
4243
"LICENSE",
4344
"MODULE.bazel",
@@ -252,11 +253,9 @@ cc_library(
252253
"include/ord/OpenRoad.hh",
253254
"include/ord/Tech.h",
254255
"include/ord/Timing.h",
255-
"include/ord/Version.hh",
256256
],
257257
includes = [
258258
"include",
259-
"include/ord",
260259
],
261260
visibility = ["//:__subpackages__"],
262261
deps = [
@@ -270,6 +269,9 @@ cc_library(
270269
hdrs = [
271270
":OpenRoadVersion",
272271
],
272+
includes = [
273+
"include",
274+
],
273275
)
274276

275277
genrule(

Jenkinsfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@Library('utils@main') _
2-
node() {
3-
pipelineOR()
2+
3+
k8sPodTemplate(coordinator: true, cloud: utilPickCloud()) {
4+
pipelineOR(k8s: true)
45
}

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)
8989

9090
# --- Dev dependencies (not propagated to downstream consumers) ---
9191

92+
bazel_dep(name = "aspect_rules_lint", version = "2.5.2", dev_dependency = True)
9293
bazel_dep(name = "bant", version = "0.2.8", dev_dependency = True)
9394
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True)
9495
bazel_dep(name = "rules_verilator", version = "0.1.0", dev_dependency = True)
@@ -164,8 +165,7 @@ llvm = use_extension(
164165
llvm.toolchain(
165166
llvm_version = "20.1.8",
166167
)
167-
use_repo(llvm, "llvm_toolchain")
168-
# use_repo(llvm, "llvm_toolchain_llvm") # if you depend on specific tools in scripts
168+
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")
169169

170170
# FYI: Comment out @llvm_toolchain//:all on NixOS and use the local clang toolchain instead.
171171
register_toolchains(

MODULE.bazel.lock

Lines changed: 309 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/agents/ci.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ Exit code 8 means some checks are still pending -- not an error.
1414
### Clang-Tidy CI
1515
Clang-Tidy CI can fail not only for code issues but also for **unresolved review comments** on the PR. Review threads cannot be resolved via API on public repos -- must be done on the GitHub web UI.
1616

17+
### Running clang-tidy locally via Bazel
18+
Run clang-tidy hermetically using the toolchain Bazel already uses to compile:
19+
```bash
20+
# Single module:
21+
bazel build --config=lint //src/utl/...
22+
23+
# Full lint scope (excludes submodules):
24+
bazel build --config=lint -- //src/... //third-party/... -//src/sta/... -//third-party/abc/...
25+
```
26+
- Uses `clang-tidy` from `@llvm_toolchain` (the same binary `etc/run-clang-tidy.sh` uses).
27+
- Reports land at `$(bazel info bazel-bin)/<pkg>/<target>_rules_lint/<src>.AspectRulesLintClangTidy.out`.
28+
- Generated files (SWIG, bison, flex) are auto-skipped. Targets tagged `no-lint` are skipped.
29+
- Aspect + config defined in `tools/lint/` and `//:.bazelrc` (`--config=lint`).
30+
1731
## CI Artifacts
1832

1933
- Use distinct filenames for public vs private artifacts (never overwrite one with the other)

docs/contrib/DeveloperGuide.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,23 @@ ln -sf build/compile_commands.json . # make compilation db visible
305305
/bin/sh etc/run-clang-tidy-cached.cc
306306
```
307307

308+
Alternatively, you can run `clang-tidy` hermetically through Bazel — no
309+
cmake configuration or Clang Tooling setup is required, and the toolchain
310+
matches what CI will use:
311+
312+
```shell
313+
# Single module:
314+
bazel build --config=lint //src/<module>/...
315+
316+
# Full lint scope (excludes upstream submodules):
317+
bazel build --config=lint -- //src/... //third-party/... \
318+
-//src/sta/... -//third-party/abc/...
319+
```
320+
321+
Reports land under `bazel-bin/<pkg>/<target>_rules_lint/` as
322+
`*.AspectRulesLintClangTidy.out` files. Generated files (SWIG, bison, flex)
323+
and targets tagged `no-lint` are skipped automatically.
324+
308325
## Doxygen
309326

310327
OpenROAD uses Doxygen style comments to generate documentation.

docs/contrib/LintTargets.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ To add a new linter (e.g., C++ tidy):
103103
The following linters and formatters are planned for `//:lint_test` and
104104
`//:fix_lint`, replacing their ad-hoc CI equivalents:
105105

106-
- **C++ clang-tidy** — static analysis for C++ sources
107106
- **C++ clang-format** — formatting check/fix for C++ and header files
108107
- **Python ruff** — lint + format for Python scripts in `etc/`, `docs/`, tests
109108
- **ShellCheck** — lint for bash scripts in `test/`, `bazel/`, `etc/`
@@ -121,3 +120,9 @@ The GitHub Actions workflow (`.github/workflows/github-actions-lint-tcl.yml`)
121120
runs the same `tclint` and `tclfmt` checks. Once Bazel lint targets are
122121
validated in CI, the GitHub Actions workflow can be retired. The same applies
123122
to the Jenkins documentation and duplicate ID check stages.
123+
124+
C++ clang-tidy is provided via a separate Bazel aspect (`--config=lint`)
125+
rather than the `//:lint_test` umbrella. Aspects participate in Bazel's
126+
per-action cache, which the `sh_test`-based umbrella does not, so incremental
127+
C++ lint scales better that way. See the "Code Linting and Formatting"
128+
section of `docs/contrib/DeveloperGuide.md` for usage.

src/rmp/src/Restructure.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <utility>
2020
#include <vector>
2121

22+
// Establish abc namespace, must include before abcapis.h
23+
#include "misc/util/abc_namespaces.h" // IWYU pragma: keep
24+
25+
// other includes
2226
#include "annealing_strategy.h"
2327
#include "base/main/abcapis.h"
2428
#include "cut/abc_init.h"

0 commit comments

Comments
 (0)