From 8b74f795e89a9ac6454428745a75a56e7361f91c Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 28 Oct 2025 10:41:04 +0000 Subject: compilers: cpp: unset LIBCPP_HARDENING_MODE first for debugstl libc++ uses the same macro name, just with different values, for debugstl. If the distro or similar predefines a hardening mode lower than the mode debugstl wants (or in any other way not equal), we get an annoying redefinition warning. Closes: https://github.com/mesonbuild/meson/issues/13812 --- mesonbuild/compilers/cpp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 47087b694..91a1f04ab 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -286,6 +286,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCPPStds, ClangCompiler, CPPCompiler # https://discourse.llvm.org/t/building-a-program-with-d-libcpp-debug-1-against-a-libc-that-is-not-itself-built-with-that-define/59176/3 # Note that unlike _GLIBCXX_DEBUG, _MODE_DEBUG doesn't break ABI. It's just slow. if version_compare(self.version, '>=18'): + args.append('-U_LIBCPP_HARDENING_MODE') args.append('-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG') if not rtti: @@ -494,6 +495,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCPPStds, GnuCompiler, CPPCompiler): if not rtti: args.append('-fno-rtti') + # We may want to handle libc++'s debugstl mode here too if debugstl: args.append('-D_GLIBCXX_DEBUG=1') return args -- cgit v1.2.3