When ENABLE_HARDENING
is ON
(which is the default), then enable light or full hardening in libc++ or libstdc++, depending on the library used and depending on the build type:
library | Bitcoin Core compiled in debug mode | Bitcoin Core compiled in non-debug mode |
---|---|---|
libc++ | _LIBCPP_HARDENING_MODE_DEBUG 1 |
_LIBCPP_HARDENING_MODE_FAST 1 |
libstdc++ | _GLIBCXX_ASSERTIONS |
_GLIBCXX_ASSERTIONS |
1 this will override the hardening mode with which libc++ is compiled, for the header-based parts of libc++ (most of it). The pre-built components of libc++ will still use whatever mode is configured when libc++ was compiled. For more info see the docs.
Remove hardening flags from depends/hosts/linux.mk
in favor of the more generic way to enable them via CMake. The same would be achieved after this change by cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_HARDENING=ON
.
For the task MSan, depends (Cirrus CI)
we build a custom libc++ for which we already use -DLIBCXX_HARDENING_MODE=debug
. Compile it also with _LIBCPP_ABI_BOUNDED_*
to enable further checks. Also enable _LIBCPP_ABI_BOUNDED_*
when compiling Bitcoin Core on that CI task.
Docs at: https://libcxx.llvm.org/Hardening.html#abi-options
The following other CI tasks:
macOS 14 native, arm64, no depends, sqlite only, gui (GitHub)
macOS 14 native, arm64, fuzz (GitHub)
no wallet, libbitcoinkernel (Cirrus CI)
use an OS-supplied libc++. For them also compile Bitcoin Core with _LIBCPP_ABI_BOUNDED_*
which will enable less checks, compared to the MSan task, because the OS-supplied libc++ is presumably compiled with less than -DLIBCXX_HARDENING_MODE=debug
.
Inspired by #31272 (comment)