Skip to content

bazel: embed git version via workspace stamping#9586

Merged
maliberty merged 4 commits intoThe-OpenROAD-Project:masterfrom
Pinata-Consulting:fix-7140
Mar 2, 2026
Merged

bazel: embed git version via workspace stamping#9586
maliberty merged 4 commits intoThe-OpenROAD-Project:masterfrom
Pinata-Consulting:fix-7140

Conversation

@oharboe
Copy link
Collaborator

@oharboe oharboe commented Mar 1, 2026

Use Bazel's --workspace_status_command mechanism to populate OPENROAD_VERSION and OPENROAD_GIT_DESCRIBE in the Version.hh header.

With the default --nostamp (dev builds) STABLE_GIT_VERSION is empty, so the genrule output is deterministic and the Bazel cache is never invalidated on commits. With --stamp (or --config=release) the script runs git describe and embeds the real version string, e.g. 26Q1-1485-g51d4ea27c3, without requiring a full rebuild.

Usage:

Development build (cache-safe, version shows "bazel-nostamp"):

bazel build //...

Release build (real git version embedded, e.g. "26Q1-1485-g51d4ea27c3"):

bazel build --config=release //:openroad

Check the embedded version at runtime:

./bazel-bin/openroad -version

Fixes #7140.

Use Bazel's --workspace_status_command mechanism to populate
OPENROAD_VERSION and OPENROAD_GIT_DESCRIBE in the Version.hh header.

With the default --nostamp (dev builds) STABLE_GIT_VERSION is empty,
so the genrule output is deterministic and the Bazel cache is never
invalidated on commits. With --stamp (or --config=release) the script
runs `git describe` and embeds the real version string, e.g.
26Q1-1485-g51d4ea27c3, without requiring a full rebuild.

Usage:
  # Development build (cache-safe, version shows "bazel-nostamp"):
  bazel build //...

  # Release build (real git version embedded, e.g. "26Q1-1485-g51d4ea27c3"):
  bazel build --config=release //:openroad

  # Check the embedded version at runtime:
  ./bazel-bin/openroad -version

Fixes The-OpenROAD-Project#7140.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a good mechanism for embedding Git version information into the build using Bazel's workspace stamping feature. The implementation is sound and addresses the goal of having cache-safe development builds while embedding real version info for release builds. I have a couple of suggestions to improve the shell scripts for better readability and maintainability.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

clang-tidy review says "All clean, LGTM! 👍"

@gadfort
Copy link
Collaborator

gadfort commented Mar 1, 2026

@oharboe seems to work when I tried it.
I get:

OpenROAD 26Q1-1486-g0c5482a1a0 26Q1-1486-g0c5482a1a0

Seems like the version tag gets duplicated. Otherwise it works

- Change stamp = True to stamp = -1 so the genrule only stamps
  with --config=release (--stamp), not on every build. This keeps
  dev builds deterministic and cache-safe.
- Set OPENROAD_GIT_DESCRIBE to empty string instead of duplicating
  OPENROAD_VERSION (which caused "26Q1-... 26Q1-..." in the banner).
- Remove OPENROAD_GIT_DESCRIBE from OPENROAD_DEFINES to avoid macro
  redefinition with the genrule-generated Version.hh.
- Document version stamping in Bazel.md and Build.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe oharboe requested a review from gadfort March 1, 2026 17:55
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
Copy link
Collaborator Author

oharboe commented Mar 1, 2026

@gadfort Reviewing & testing is now the bottleneck, but Claude thinks this is line with what @hzeller pointed to.

I imagine that this code, if it works, will be fine as is and that we're unlikely to look at it ever again...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

clang-tidy review says "All clean, LGTM! 👍"

@gadfort
Copy link
Collaborator

gadfort commented Mar 1, 2026

@oharboe gave it a spin, it seems to work when I try it:

OpenROAD 26Q1-1488-ge294555cc7 

@oharboe oharboe requested a review from hzeller March 1, 2026 18:34
@oharboe
Copy link
Collaborator Author

oharboe commented Mar 1, 2026

I tried it with and without --config=release and it output a git describe version number and bazel-nostamp respectively, so 👍

Copy link
Collaborator

@hzeller hzeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@oharboe oharboe requested a review from maliberty March 1, 2026 18:43
@oharboe
Copy link
Collaborator Author

oharboe commented Mar 1, 2026

@maliberty pr-merge works, pr-head fails(CI problem, I presume). manual merge?

@gadfort
Copy link
Collaborator

gadfort commented Mar 1, 2026

@oharboe it seems it's an rmp test that is failing, so unrelated to these changes, I would think a manual merge would be needed and that test reviewed (@maliberty ) log copied in here:

[2026-03-01T18:22:49.485Z] Command: /home/user/.cache/bazel/_bazel_user/e33d6bfca40b1ba5f35626859005105a/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/openroad -no_splash -no_init -exit aes_genetic.tcl
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13156, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13189, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13222, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13255, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13288, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13321, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 13354, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 14748, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 14781, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_SS_nldm_211120.lib.gz line 14814, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13178, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13211, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13244, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13277, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13310, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13343, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 13376, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 14772, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 14805, timing group from output port.
[2026-03-01T18:22:49.485Z] [WARNING STA-1212] ./asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz line 14838, timing group from output port.
[2026-03-01T18:22:49.485Z] [INFO ODB-0227] LEF file: ./asap7/asap7_tech_1x_201209.lef, created 30 layers, 9 vias
[2026-03-01T18:22:49.485Z] [INFO ODB-0227] LEF file: ./asap7/asap7sc7p5t_28_R_1x_220121a.lef, created 212 library cells
[2026-03-01T18:22:49.485Z] [WARNING STA-0441] set_input_delay relative to a clock defined on the same port/pin not allowed.
[2026-03-01T18:22:49.485Z] -- Before --
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z] Cell type report:                       Count       Area
[2026-03-01T18:22:49.485Z]   Buffer                                 1081      78.80
[2026-03-01T18:22:49.485Z]   Inverter                                458      20.03
[2026-03-01T18:22:49.485Z]   Sequential cell                         562     163.88
[2026-03-01T18:22:49.485Z]   Multi-Input combinational cell         9806    1050.62
[2026-03-01T18:22:49.485Z]   Total                                 11907    1313.34
[2026-03-01T18:22:49.485Z] [-30.917,  54.906): ***** (21)
[2026-03-01T18:22:49.485Z] [ 54.906, 140.728): ********************** (92)
[2026-03-01T18:22:49.485Z] [140.728, 226.551): *********** (47)
[2026-03-01T18:22:49.485Z] [226.551, 312.373): ************************************************** (212)
[2026-03-01T18:22:49.485Z] [312.373, 398.196): ******* (29)
[2026-03-01T18:22:49.485Z] [398.196, 484.018): **** (19)
[2026-03-01T18:22:49.485Z] [484.018, 569.841): ** (10)
[2026-03-01T18:22:49.485Z] [569.841, 655.664): * (3)
[2026-03-01T18:22:49.485Z] [655.664, 741.486): ****************************** (129)
[2026-03-01T18:22:49.485Z] [741.486, 827.309]: ****************************** (129)
[2026-03-01T18:22:49.485Z] Startpoint: ld (input port clocked by core_clock)
[2026-03-01T18:22:49.485Z] Endpoint: u0/subword[19]$_DFF_P_
[2026-03-01T18:22:49.485Z]           (rising edge-triggered flip-flop clocked by core_clock)
[2026-03-01T18:22:49.485Z] Path Group: core_clock
[2026-03-01T18:22:49.485Z] Path Type: max
[2026-03-01T18:22:49.485Z] Corner: slow
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z]   Delay    Time   Description
[2026-03-01T18:22:49.485Z] ---------------------------------------------------------
[2026-03-01T18:22:49.485Z]    0.00    0.00   clock core_clock (rise edge)
[2026-03-01T18:22:49.485Z]    0.00    0.00   clock network delay (ideal)
[2026-03-01T18:22:49.485Z]  200.00  200.00 ^ input external delay
[2026-03-01T18:22:49.485Z]    0.00  200.00 ^ ld (in)
[2026-03-01T18:22:49.485Z]   43.55  243.55 ^ _12054_/Y (BUFx2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   61.28  304.83 ^ _12066_/Y (BUFx2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   61.08  365.91 ^ _12067_/Y (BUFx2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   48.16  414.07 ^ _12197_/Y (OA21x2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   65.83  479.90 ^ _12198_/Y (BUFx2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   78.77  558.68 v _13022_/Y (INVx1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   85.51  644.19 ^ _23139_/CON (HAxp5_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   39.37  683.56 v _23139_/SN (HAxp5_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   56.95  740.51 v _13045_/Y (BUFx2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   53.72  794.23 v _13111_/Y (OA21x2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   46.41  840.64 v _13289_/Y (AO221x1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   52.20  892.84 v _13290_/Y (OA211x2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   42.82  935.66 v _13295_/Y (OR3x1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   52.15  987.81 v _13296_/Y (OA211x2_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   33.57 1021.38 v _13297_/Y (AO21x1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]    0.00 1021.38 v u0/subword[19]$_DFF_P_/D (DFFHQNx1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]         1021.38   data arrival time
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z] 1000.00 1000.00   clock core_clock (rise edge)
[2026-03-01T18:22:49.485Z]    0.00 1000.00   clock network delay (ideal)
[2026-03-01T18:22:49.485Z]    0.00 1000.00   clock reconvergence pessimism
[2026-03-01T18:22:49.485Z]         1000.00 ^ u0/subword[19]$_DFF_P_/CLK (DFFHQNx1_ASAP7_75t_R)
[2026-03-01T18:22:49.485Z]   -9.54  990.46   library setup time
[2026-03-01T18:22:49.485Z]          990.46   data required time
[2026-03-01T18:22:49.485Z] ---------------------------------------------------------
[2026-03-01T18:22:49.485Z]          990.46   data required time
[2026-03-01T18:22:49.485Z]         -1021.38   data arrival time
[2026-03-01T18:22:49.485Z] ---------------------------------------------------------
[2026-03-01T18:22:49.485Z]          -30.92   slack (VIOLATED)
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z] wns max -30.92
[2026-03-01T18:22:49.485Z] tns max -191.30
[2026-03-01T18:22:49.485Z] -- After --
[2026-03-01T18:22:49.485Z] 
[2026-03-01T18:22:49.485Z] [INFO RMP-0059] Resynthesis: starting tuning algorithm, Worst slack is -3.0917047e-11
[2026-03-01T18:22:49.485Z] Derived GENLIB library "asap7sc7p5t_AO_RVT_SS_nldm_211120" with 169 gates.
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 0 of genetic algorithm
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 1 of genetic algorithm
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 2 of genetic algorithm
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 3 of genetic algorithm
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 4 of genetic algorithm
[2026-03-01T18:22:49.485Z] [INFO RMP-0065] Resynthesis: Iteration 5 of genetic algorithm
[2026-03-01T18:22:49.485Z] -- Test timed out at 2026-03-01 18:22:49 UTC --
[2026-03-01T18:22:49.485Z] external/bazel_tools/tools/test/test-setup.sh: line 405: file: command not found

@maliberty
Copy link
Member

Question for the Bazel pros: will a .o built without stamping still generate a cache hit in a build with stamping or are they considered too different? I'm wondering if a single cache can be mostly shared between the modes (aside from the stamp itself and the final binary).

@maliberty maliberty merged commit 6dc750a into The-OpenROAD-Project:master Mar 2, 2026
12 of 13 checks passed
@oharboe
Copy link
Collaborator Author

oharboe commented Mar 2, 2026

Question for the Bazel pros: will a .o built without stamping still generate a cache hit in a build with stamping or are they considered too different? I'm wondering if a single cache can be mostly shared between the modes (aside from the stamp itself and the final binary).

Claude thinks this is what is needed:

#9591

@oharboe oharboe deleted the fix-7140 branch March 2, 2026 10:20
@maliberty
Copy link
Member

This appears to include #9591 so you think this will allow sharing? This looks a bit different than what Verible does. @hzeller do you concur?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bazel - needs to show git describe in splash

4 participants