Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilers: cpp: wire up stdlib assertions #12683

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

thesamesam
Copy link
Collaborator

None of the options set here affect ABI and are intended for detecting constraint violations.

For GCC, we simply need to set -D_GLIBCXX_ASSERTIONS.

For Clang, the situation is far more complicated:

  • LLVM 18 uses a 'hardened mode' (https://libcxx.llvm.org/Hardening.html). There are several levels of severity available here. I've chosen _LIBCPP_HARDENING_MODE_DEBUG for now given it does the most but does not affect ABI, but we could change it to something more lightweight.

  • LLVM 17 uses a similar approach to libstdc++ called '_LIBCPP_ENABLE_ASSERTIONS'

Note that LLVM 17 while in development had fully deprecated _LIBCPP_ENABLE_ASSERTIONS in favour of hardened, but changed its mind last-minute: https://discourse.llvm.org/t/rfc-hardening-in-libc/73925/4.

docs/markdown/snippets/cpp-debug.md Outdated Show resolved Hide resolved
mesonbuild/compilers/cpp.py Outdated Show resolved Hide resolved
None of the options set here affect ABI and are intended for detecting constraint
violations.

For GCC, we simply need to set -D_GLIBCXX_ASSERTIONS.

For Clang, the situation is far more complicated:
* LLVM 18 uses a 'hardened mode' (https://libcxx.llvm.org/Hardening.html).
  There are several levels of severity available here. I've chosen
  _LIBCPP_HARDENING_MODE_EXTENSIVE as the strongest-but-one. The strongest
  one (_DEBUG) doesn't affect ABI still but is reserved for stldebug.

* LLVM 15 uses a similar approach to libstdc++ called '_LIBCPP_ENABLE_ASSERTIONS'

Note that LLVM 17 while in development had fully deprecated _LIBCPP_ENABLE_ASSERTIONS
in favour of hardened, but changed its mind last-minute: https://discourse.llvm.org/t/rfc-hardening-in-libc/73925/4.

Signed-off-by: Sam James <[email protected]>
Signed-off-by: Eli Schwartz <[email protected]>
@eli-schwartz eli-schwartz merged commit 9009847 into mesonbuild:master Jan 9, 2024
21 checks passed
@thesamesam thesamesam deleted the glibcxx-assertions branch January 9, 2024 07:18
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.

2 participants