Skip to content

bazel: fix hermetic ASan builds#10911

Open
naveenvenk17 wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-bazel-hermetic-asan
Open

bazel: fix hermetic ASan builds#10911
naveenvenk17 wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-bazel-hermetic-asan

Conversation

@naveenvenk17

@naveenvenk17 naveenvenk17 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #7754.

Address sanitizer builds stopped linking after the hermetic LLVM migration because the raw compiler flags did not stage compiler-rt in the toolchain resource directory.

Use the hermetic toolchain ASan setting so it builds and stages the runtime libraries. Disable external_include_paths for this config because that feature prevents compiler-rt from finding its internal LLVM headers.

Tests run on Linux:

  • bazel build --config=asan -c dbg :openroad
  • bazel test --config=asan //src/cts/test:cts_unittest
  • bazel test --config=asan --test_env=ASAN_OPTIONS=detect_leaks=0 //src/cts/test:cts_unittest //src/cts/test:simple_test-tcl_test //src/rsz/test:TestBufRem1 //src/rsz/test:TestBufferRemoval2 //src/rsz/test:TestBufferRemoval3 //src/rsz/test:TestInsertBuffer //src/rsz/test:TestNestedJournal //src/rsz/test:TestResizer //src/rsz/test:TestResizerMt
  • bazel test //src/cts/test:cts_unittest //src/cts/test:simple_test-tcl_test

Leak detection was disabled in the broader run to exclude the existing process-lifetime allocations created by sta::TimingArcSet::init().

@naveenvenk17
naveenvenk17 requested a review from a team as a code owner July 14, 2026 20:32

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

Copy link
Copy Markdown
Contributor

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 updates the .bazelrc configuration for the ASan build to use hermetic LLVM's sanitizer setting and disables external_include_paths. The feedback highlights that disabling external_include_paths could cause compilation warnings in third-party headers to be treated as errors, potentially breaking the ASan build, and suggests adding -Wno-error to prevent this.

Comment thread .bazelrc
# the toolchain resource directory. external_include_paths is incompatible
# with compiler-rt's internal LLVM header dependencies.
build:asan --@llvm//config:asan=true
build:asan --features=-external_include_paths

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Disabling external_include_paths globally for the asan configuration means that third-party headers (such as Boost, Eigen, etc.) will no longer be treated as system headers (-isystem). Consequently, any warnings within these external headers will be emitted during compilation. Since the project treats several specific warnings as errors (lines 48-55), this is highly likely to break the ASan build. To prevent warning-induced build failures, consider adding -Wno-error to the ASan compiler options.

build:asan --features=-external_include_paths
build:asan --copt=-Wno-error
build:asan --host_copt=-Wno-error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I ran the full debug build with this configuration: bazel build --config=asan -c dbg :openroad. It completed successfully after compiling the Boost, Eigen, and generated SWIG sources. The external headers do emit warnings, but none of them hit the projects warning-as-error set. I would rather keep the existing warning checks active than disable all of them for ASan.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you saying it won't compile without this option or just that you prefer to see the warnings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It will not compile without disabling external_include_paths. With the feature enabled, compiler-rt fails while compiling its own sources because headers such as llvm/DebugInfo/Symbolize/DIPrinter.h are not found. The warnings from Boost and Eigen are a side effect of disabling the feature. I mentioned them only to confirm that the full build still passes without adding -Wno-error.

@maliberty

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 392ff26e4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17
naveenvenk17 force-pushed the nv-bazel-hermetic-asan branch from 392ff26 to c17c515 Compare July 15, 2026 05:22
@naveenvenk17
naveenvenk17 requested a review from a team as a code owner July 15, 2026 05:22
@naveenvenk17

Copy link
Copy Markdown
Contributor Author

I found one more issue while expanding the ASan test coverage. Python tests could build the instrumented extension modules, but importing them failed because the Python interpreter itself does not load compiler-rt. The branch now adds the hermetic libc++abi, libc++, and ASan libraries as test runfiles and preloads them only when the ASan config is active. There are no system library paths in the test setup.\n\nI tested all 18 OpenDB Python binding tests under ASan with leak detection disabled, and all 18 pass. I also ran the same 18 tests without ASan, and all 18 pass.

@github-actions github-actions Bot added size/S and removed size/XS labels Jul 15, 2026
Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17
naveenvenk17 force-pushed the nv-bazel-hermetic-asan branch from c17c515 to f4643d9 Compare July 15, 2026 05:23
Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17

Copy link
Copy Markdown
Contributor Author

I found another gap while testing a full Python regression under ASan. The runtime preload was exported by the shell harness, so helper programs inherited the hermetic C++ libraries and could fail before Python started. The runtime set was also missing libunwind.\n\nThe latest commit resolves the runfiles to absolute paths, preloads them only for the Python command, and adds hermetic libunwind. I tested nine OpenDB Python binding targets plus the DRT ispd18 Python regression under ASan with leak detection disabled. All 10 pass. The same 10 targets also pass in the normal configuration.

@osamahammad21

Copy link
Copy Markdown
Member

leaving this to @maliberty

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bazel: make bazelisk build --config=asan -c dbg :openroad work

3 participants