build: enable libc++ and libstdc++ hardening
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_DEBUG1
|
_LIBCPP_HARDENING_MODE_FAST1
|
| 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.
Inspired by https://github.com/bitcoin/bitcoin/issues/31272#issuecomment-2518700939