Skip to content

bazel: support _LIBCPP_HARDENING_MODE in setup_configs for LLVM 18+ (#2018) - #2263

Open
jdymitarai wants to merge 1 commit into
google:mainfrom
jdymitarai:fix-setup-configs-libcpp-hardening-2018
Open

jdymitarai wants to merge 1 commit into
google:mainfrom
jdymitarai:fix-setup-configs-libcpp-hardening-2018

Conversation

@jdymitarai

Copy link
Copy Markdown

In LLVM 18 and newer, libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS in favor of per-TU hardening modes such as _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE. When compiling with modern Clang toolchains under -Werror, the legacy assertion macro emits a deprecation warning that turns into a compilation failure (#2018).

This updates bazel/setup_configs.sh to dynamically detect whether libc++ supports hardening modes via preprocessor probing or toolchain version check, and emits _LIBCPP_HARDENING_MODE_EXTENSIVE for LLVM 18+ while preserving _LIBCPP_ENABLE_ASSERTIONS=1 as a safe fallback on older compilers. Users can also configure an explicit override via LIBCPP_HARDENING_MODE. In addition, e2e_tests/functional_test.cc is updated so the empty optional dereference test correctly asserts under both legacy assertion and modern hardening configurations.

This branch has not been deployed

No deployments
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.

1 participant