Skip to content

bazel: enable additional mem safety compiler checks#10635

Draft
mikesinouye wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
mikesinouye:clang
Draft

bazel: enable additional mem safety compiler checks#10635
mikesinouye wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
mikesinouye:clang

Conversation

@mikesinouye

Copy link
Copy Markdown
Contributor

Type of Change

  • New feature

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

[Link issues here]

Signed-off-by: Mike Inouye <mikeinouye@google.com>

@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 configures several compiler warnings as errors in .bazelrc (such as dangling pointers and array bounds) and updates dbSta.cc to use std::string instead of std::string_view for pin_name. A review comment points out that adding Clang-specific warning options unconditionally to global build options will break GCC builds, and suggests moving them to a compiler-specific configuration block.

Comment thread .bazelrc
Comment on lines +54 to +61
build --copt "-Werror=array-bounds" --host_copt "-Werror=array-bounds"
build --copt "-Werror=dangling" --host_copt "-Werror=dangling"
build --copt "-Werror=dangling-assignment" --host_copt "-Werror=dangling-assignment"
build --copt "-Werror=dangling-assignment-gsl" --host_copt "-Werror=dangling-assignment-gsl"
build --copt "-Werror=dangling-field" --host_copt "-Werror=dangling-field"
build --copt "-Werror=dangling-gsl" --host_copt "-Werror=dangling-gsl"
build --copt "-Werror=fortify-source" --host_copt "-Werror=fortify-source"
build --copt "-Werror=return-stack-address" --host_copt "-Werror=return-stack-address"

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

Adding Clang-specific warning options like -Werror=dangling, -Werror=dangling-assignment, -Werror=dangling-gsl, and -Werror=fortify-source unconditionally to the global build options will break builds using the GCC compiler. GCC does not recognize these warning options and will fail the build with a hard error (e.g., error: -Werror=dangling: no option -Wdangling). To maintain compatibility with GCC, consider moving these Clang-specific flags to a compiler-specific configuration block or using Bazel's platform/toolchain-based select mechanism.

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.

1 participant