Skip to content

Commit 346c47e

Browse files
authored
Merge branch 'The-OpenROAD-Project:master' into gpl_fix_max_filler_removal
2 parents 8c37ae7 + 6dadf2d commit 346c47e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1952
-273
lines changed

.bazelrc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,16 @@ build --jobs=200
7878
build --disk_cache=~/.cache/bazel-disk-cache
7979
build --repository_cache=~/.cache/bazel-repository-cache
8080

81-
# --- CI Settings (write access) ---
82-
build:ci --remote_cache=https://storage.googleapis.com/openroad-bazel-cache
83-
build:ci --remote_cache_compression=true
84-
build:ci --remote_upload_local_results=true
8581
# CI only needs to know if the build succeeded, not the artifacts themselves.
8682
build:ci --remote_download_minimal
83+
build:ci --remote_upload_local_results=true
8784
# Disable disk cache for CI builds
8885
build:ci --disk_cache=
8986

90-
# --- OpenROAD Developer Settings (read-only access) ---
91-
build:openroad-dev --remote_cache=https://storage.googleapis.com/openroad-bazel-cache
92-
build:openroad-dev --remote_cache_compression=true
93-
build:openroad-dev --remote_upload_local_results=false
94-
# Developers need the actual output files to run and use them.
95-
build:openroad-dev --remote_download_toplevel
96-
build:openroad-dev --google_default_credentials=true
97-
build:openroad-dev --disk_cache=/workspace/.cache/bazel-disk-cache
98-
build:openroad-dev --repository_cache=/workspace/.cache/bazel-repository-cache
87+
# Setup remote cache
88+
build --remote_cache=https://bazel.precisioninno.com
89+
build --remote_cache_compression=true
90+
build --remote_upload_local_results=false
9991

10092
# Without this, bazelisk build ... builds the bazel-orfs tests
10193
build --build_tag_filters=-orfs

.buildifier.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"type": "auto",
3+
"mode": "fix",
4+
"lint": "fix",
5+
"warningsList": [
6+
"attr-applicable_licenses",
7+
"attr-cfg",
8+
"attr-license",
9+
"attr-licenses",
10+
"attr-non-empty",
11+
"attr-output-default",
12+
"attr-single-file",
13+
"build-args-kwargs",
14+
"bzl-visibility",
15+
"confusing-name",
16+
"constant-glob",
17+
"ctx-actions",
18+
"ctx-args",
19+
"deprecated-function",
20+
"depset-items",
21+
"depset-iteration",
22+
"depset-union",
23+
"dict-concatenation",
24+
"dict-method-named-arg",
25+
"duplicated-name",
26+
"filetype",
27+
"function-docstring",
28+
"function-docstring-args",
29+
"function-docstring-header",
30+
"function-docstring-return",
31+
"git-repository",
32+
"http-archive",
33+
"integer-division",
34+
"keyword-positional-params",
35+
"list-append",
36+
"load",
37+
"module-docstring",
38+
"name-conventions",
39+
"native-android",
40+
"native-build",
41+
"native-cc-binary",
42+
"native-cc-common",
43+
"native-cc-debug-package-info",
44+
"native-cc-fdo-prefetch-hints",
45+
"native-cc-fdo-profile",
46+
"native-cc-import",
47+
"native-cc-info",
48+
"native-cc-library",
49+
"native-cc-memprof-profile",
50+
"native-cc-objc-import",
51+
"native-cc-objc-library",
52+
"native-cc-propeller-optimize",
53+
"native-cc-proto",
54+
"native-cc-shared-library",
55+
"native-cc-shared-library-hint-info",
56+
"native-cc-shared-library-info",
57+
"native-cc-test",
58+
"native-cc-toolchain",
59+
"native-cc-toolchain-suite",
60+
"native-java-binary",
61+
"native-java-common",
62+
"native-java-import",
63+
"native-java-info",
64+
"native-java-library",
65+
"native-java-lite-proto",
66+
"native-java-package-config",
67+
"native-java-plugin",
68+
"native-java-plugin-info",
69+
"native-java-proto",
70+
"native-java-runtime",
71+
"native-java-test",
72+
"native-java-toolchain",
73+
"native-package",
74+
"native-proto",
75+
"native-proto-common",
76+
"native-proto-info",
77+
"native-proto-lang-toolchain",
78+
"native-proto-lang-toolchain-info",
79+
"native-py",
80+
"native-sh-binary",
81+
"native-sh-library",
82+
"native-sh-test",
83+
"no-effect",
84+
"output-group",
85+
"overly-nested-depset",
86+
"package-name",
87+
"package-on-top",
88+
"positional-args",
89+
"print",
90+
"provider-params",
91+
"redefined-variable",
92+
"repository-name",
93+
"return-value",
94+
"rule-impl-return",
95+
"skylark-comment",
96+
"skylark-docstring",
97+
"string-iteration",
98+
"uninitialized",
99+
"unnamed-macro",
100+
"unreachable",
101+
"unsorted-dict-items",
102+
"unused-variable"
103+
]
104+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint Bazel (Buildifier)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
check:
10+
runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted' || 'ubuntu-latest' }}
11+
env:
12+
BUILDIFIER_VERSION: v8.2.1
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v5
17+
18+
- name: Download buildifier
19+
run: |
20+
wget https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier-linux-amd64 -O buildifier
21+
chmod +x buildifier
22+
23+
- name: Run buildifier (format check)
24+
run: ./buildifier -r -mode=check -lint=off .
25+
26+
- name: Run buildifier (lint)
27+
if: always()
28+
run: ./buildifier -r -lint=warn .

Jenkinsfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,9 @@ def bazelTest = {
219219
}
220220
withDockerContainer(args: '-u root -v /var/run/docker.sock:/var/run/docker.sock', image: 'openroad/bazel-ci:latest') {
221221
stage('bazelisk test ...') {
222-
withCredentials([file(credentialsId: 'bazel-cache-sa', variable: 'GCS_SA_KEY')]) {
222+
withCredentials([string(credentialsId: 'bazel-auth-token-b64', variable: 'BAZEL_AUTH_TOKEN_B64')]) {
223223
timeout(time: 120, unit: 'MINUTES') {
224-
def cmd = 'bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic';
225-
if (env.BRANCH_NAME != 'master') {
226-
cmd += ' --remote_upload_local_results=false';
227-
}
228-
cmd += ' --google_credentials=$GCS_SA_KEY';
224+
def cmd = 'bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic --remote_header="Authorization=Basic $BAZEL_AUTH_TOKEN_B64"'
229225
try {
230226
sh label: 'Bazel Build', script: cmd + ' ...';
231227
} catch (e) {

MODULE.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ bazel_dep(name = "or-tools", version = "9.12")
9090
bazel_dep(name = "spdlog", version = "1.15.1")
9191
bazel_dep(name = "tcmalloc", version = "0.0.0-20250331-43fcf6e")
9292
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
93+
bazel_dep(name = "yaml-cpp", version = "0.8.0")
9394

9495
# A from source build of QT that allows it to link into OpenROAD.
9596
# Building like any other bazel project. scripts in the docker folder
@@ -153,7 +154,7 @@ bazel_dep(name = "bazel-orfs")
153154
# To bump version, run: bazelisk run @bazel-orfs//:bump
154155
git_override(
155156
module_name = "bazel-orfs",
156-
commit = "2cf0198a49a220cfcabae35bba64b0034bbdbffc",
157+
commit = "264aef66bf3adebe19ea7d18dabdc24b9733c8c2",
157158
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
158159
)
159160

@@ -195,7 +196,7 @@ scala_deps.scalatest()
195196

196197
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
197198
maven.install(
198-
name = "openroad_maven",
199+
name = "maven",
199200
artifacts = [
200201
"org.chipsalliance:chisel_2.13:7.0.0",
201202
"org.chipsalliance:chisel-plugin_2.13.16:7.0.0",
@@ -206,7 +207,7 @@ maven.install(
206207
"https://s01.oss.sonatype.org/content/repositories/snapshots",
207208
],
208209
)
209-
use_repo(maven, "openroad_maven")
210+
use_repo(maven, "maven")
210211

211212
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
212213

MODULE.bazel.lock

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

bazel/tcl_encode_or.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def _tcl_encode_or_impl(ctx):
2222
# Only keep .tcl and .py files.
2323
allowed_extensions = (".tcl", ".py")
2424
filtered_sources = [
25-
f for f in ctx.files.srcs if f.basename.endswith(allowed_extensions)
25+
f
26+
for f in ctx.files.srcs
27+
if f.basename.endswith(allowed_extensions)
2628
]
2729

2830
ctx.actions.run(

docs/user/Bazel-caching.md

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,94 @@ This document provides instructions for developers on how to use Bazel's caching
66

77
Our Bazel setup uses a multi-layered caching strategy to provide optimal performance for different types of users:
88

9-
1. **Local Cache (Default):** All builds use a local on-disk cache by default. This provides a speed-up for incremental builds without requiring any special configuration or authentication.
10-
2. **Remote Cache (OpenROAD Developers & CI):** We maintain a remote cache on Google Cloud Storage. This allows team members and CI jobs to share build artifacts, dramatically reducing build times.
9+
1. **Local Cache (Default):** All builds use a local on-disk cache by default. This provides a speed-up for incremental builds without requiring any special configuration.
10+
2. **Remote Cache:** We maintain a remote cache server at `https://bazel.precisioninno.com`. The contents of the cache are generated by the CI for all branches. This allows anyone that wishes to build OpenROAD locally and CI jobs to share build artifacts, dramatically reducing build times. All non-CI builds have **read-only** access to the remote cache.
1111

1212
---
1313

1414
### 1. Local On-Disk Cache
1515

16-
By default, all builds use a local on-disk cache to speed up incremental builds. The default location is `~/.cache/bazel-disk-cache`.
16+
All builds use a local on-disk cache to speed up incremental builds. The default location is `~/.cache/bazel-disk-cache` and is set inside the repo's `.bazelrc` file.
1717

18-
You can override this location by setting the `OPENROAD_BAZEL_CACHE` environment variable:
18+
You can override this config by setting a systemwide or home `.bazelrc` file. See more at [Write bazelrc configuration files](https://bazel.build/run/bazelrc) or by passing the `--disk_cache` argument to your bazel commands.
1919

20-
```bash
21-
export OPENROAD_BAZEL_CACHE=/path/to/your/cache
22-
bazel build //...
23-
```
24-
25-
No remote cache is accessed, and no authentication is required for the local cache. This provides a seamless experience for external contributors.
26-
Secure VMs already have this set up, so no additional configuration is needed.
20+
#### Using a `user.bazelrc` file
2721

28-
---
22+
For more advanced customization, you can create a `user.bazelrc` file in the root of the repository. This file is ignored by Git and can be used to override any default settings. For example, you could use it to specify a different remote cache or to enable features for your local builds.
2923

30-
### 2. OpenROAD Developer Access (for `@openroad.tools` users)
24+
Example `user.bazelrc`:
3125

32-
Team members can enable **read-only** access to the remote cache by using the `openroad-dev` configuration. This will dramatically speed up local builds by downloading artifacts already built by CI.
26+
```
27+
build --remote_cache=https://storage.googleapis.com/my-personal-cache
28+
build --remote_upload_local_results=true
29+
build --disk_cache=~/my-disk-cache
30+
```
3331

34-
#### On Secure Development VMs
32+
For a full list of command-line options, refer to the [Bazel Command-Line Reference](https://bazel.build/reference/command-line-reference).
3533

36-
If you are working on a secure development VM provided by OpenROAD, you do **not** need to authenticate. The VM's service account already has the necessary read access to the cache.
34+
---
3735

38-
#### On a Local Environment
36+
### 2. Remote Cache Access
3937

40-
If you are working on your local machine, you must first authenticate with Google Cloud using your @openroad.tools account. All OpenROAD team members have read access to the remote cache.
38+
All builds are configured to use our remote cache for shared build artifacts. This is configured in the main `.bazelrc` file with the following settings:
4139

42-
```bash
43-
gcloud auth application-default login
40+
```
41+
build --remote_cache=https://bazel.precisioninno.com
42+
build --remote_cache_compression=true
43+
build --remote_upload_local_results=false
4444
```
4545

46-
After authenticating (if necessary), run your build with the `--config=openroad-dev` flag:
46+
This means that all developer builds will **read from** the public remote cache but **cannot write to** it. This provides significant build speed improvements without requiring any authentication.
4747

48-
```bash
49-
bazel build --config=openroad-dev //...
50-
```
48+
#### Disabling the Remote Cache
5149

52-
This configuration is **read-only** to prevent local, unverified builds from populating the shared cache.
50+
If you encounter issues with the remote cache, you can disable it by overriding the `--remote_cache` flag. You can do this in your `user.bazelrc` file or by passing the flag directly to your Bazel command:
5351

54-
### Using a `user.bazelrc` file instead of `--config=openroad-dev`
52+
**Option 1: Using `user.bazelrc`**
5553

56-
You may prefer `user.bazelrc` file instead of using the `--config=openroad-dev` option.
54+
Add the following line to your `user.bazelrc` file:
5755

58-
59-
build --remote_cache=https://storage.googleapis.com/openroad-bazel-cache
60-
build --credential_helper=*.googleapis.com=%workspace%/etc/cred_helper.py
61-
build --remote_cache_compression=true
62-
build --remote_upload_local_results=false
56+
```
57+
build --remote_cache=
58+
```
59+
60+
**Option 2: Command-Line Flag**
6361

64-
To test the setup:
62+
Pass an empty `--remote_cache` flag to your build command:
6563

66-
$ etc/cred_helper.py test
67-
Running: gcloud auth print-access-token [email protected]
68-
{
69-
"kind": "storage#testIamPermissionsResponse",
70-
"permissions": [
71-
"storage.buckets.get",
72-
"storage.objects.create"
73-
]
74-
}
64+
```bash
65+
bazel build --remote_cache= //...
66+
```
7567

68+
This will cause Bazel to fall back to using only the local on-disk cache for the build
7669
---
7770

7871
### 3. CI Access (Jenkins Pipeline)
7972

80-
The Jenkins pipeline uses a unified caching strategy for all builds. This is primarily for informational purposes, as developers will not typically use the `ci` configuration locally.
73+
The Jenkins pipeline uses a specific configuration for its builds. This is primarily for informational purposes, as developers will not typically use the `ci` configuration locally.
8174

82-
* All CI builds use the `--config=ci` profile.
83-
* Builds on the `master` branch have **read/write** access, populating the remote cache with the latest artifacts.
84-
* Builds on PR branches are set to **read-only**.
75+
* All CI builds use the `--config=ci` profile.
76+
* The `ci` config enables **read/write** access to the remote cache, populating it with the latest artifacts for **all branches**.
77+
* It also disables the local disk cache for CI builds to ensure clean builds.
8578

86-
---
87-
88-
## `.bazelrc` Configurations Summary
79+
Here are the relevant settings from `.bazelrc`:
8980

90-
The caching behavior is controlled by two new configurations in the `.bazelrc` file:
81+
```
82+
build:ci --remote_download_minimal
83+
build:ci --remote_upload_local_results=true
84+
build:ci --disk_cache=
85+
```
9186

92-
* **`build:ci` (Write Access):**
93-
* `--remote_upload_local_results=true`: **Enables writing** to the remote cache.
94-
* Uses service account credentials provided by Jenkins.
87+
---
9588

96-
* **`build:openroad-dev` (Read-Only Access):**
97-
- `--remote_upload_local_results=false`: **Disables writing**, making the cache read-only.
98-
- `--google_default_credentials=true`: Uses the developer's local `gcloud` credentials.
89+
## "Build without the Bytes" (BwoB)
9990

100-
Both configurations include performance optimizations to reduce network traffic and improve build speeds. The primary mechanism for this is the "Build without the Bytes" (BwoB) feature, which minimizes the download of build artifacts from the remote cache.
91+
Our configurations include performance optimizations to reduce network traffic and improve build speeds using the "Build without the Bytes" (BwoB) feature, which minimizes the download of build artifacts from the remote cache.
10192

10293
There are two main BwoB settings:
10394

104-
* `--remote_download_toplevel`: This is the default setting in Bazel. It downloads only the outputs of the top-level targets you specify in your build command. This is ideal for interactive development, where you need to use the final build artifacts (e.g., run a binary or inspect a generated file).
95+
* `--remote_download_toplevel`: This is the default setting in Bazel. It downloads only the outputs of the top-level targets you specify in your build command. This is ideal for interactive development, where you need to use the final build artifacts (e.g., run a binary or inspect a generated file).
10596

106-
* `--remote_download_minimal`: This is a more aggressive setting that downloads only the artifacts essential for the build to continue. It is primarily intended for CI environments, where you are only concerned with the success or failure of a build, not the artifacts themselves.
97+
* `--remote_download_minimal`: This is a more aggressive setting that downloads only the artifacts essential for the build to continue. It is primarily intended for CI environments, where you are only concerned with the success or failure of a build, not the artifacts themselves.
10798

108-
Our configurations use `--remote_download_toplevel` for developer builds (`openroad-dev`) and `--remote_download_minimal` for CI builds (`ci`) to provide the best balance of performance and usability for each environment.
99+
Our configurations use the default (`--remote_download_toplevel`) for developer builds and `--remote_download_minimal` for CI builds (`ci`) to provide the best balance of performance and usability for each environment.

0 commit comments

Comments
 (0)