@@ -66,8 +66,38 @@ else()
6666 message (STATUS "Building without compiler warnings enabled." )
6767endif ()
6868
69- string (JOIN " " CMAKE_C_WARNINGS "-Wno-unknown-warning-option" "-Wno-vla-cxx-extension" ${O2_C_ENABLED_WARNINGS} ${O2_C_ENABLED_WARNINGS_NO_ERROR} )
70- string (JOIN " " CMAKE_CXX_WARNINGS "-Wno-unknown-warning-option" "-Wno-vla-cxx-extension" ${O2_CXX_ENABLED_WARNINGS} ${O2_CXX_ENABLED_WARNINGS_NO_ERROR} )
69+ # Diagnostics that newer compilers added and that fire on existing, deliberate
70+ # code. Warn, never fail.
71+ #
72+ # DELIBERATELY OUTSIDE the if(O2_ENABLE_WARNINGS) block above. That block is OFF
73+ # unless ALIBUILD_O2_WARNINGS is set in the environment, so none of its
74+ # -Wno-error= pairs are emitted in the builds that actually matter here: the PR
75+ # checkers, where alidist o2.sh appends a bare -Werror for ALIBUILD_O2_TESTS.
76+ # That combination is why -Wnonnull was fatal on Apple clang 21 even though
77+ # `nonnull` is listed in O2_COMMON_WARNINGS.
78+ #
79+ # Appended after the externally supplied CXXFLAGS (see the
80+ # CMAKE_CXX_FLAGS_<CONFIG> assignment below), so these win over that -Werror.
81+ #
82+ # Safe on older toolchains: -Wno-unknown-warning-option is prepended, so a
83+ # compiler that does not know a name ignores it silently. clang 16 (Xcode 16.2,
84+ # still in use on part of the macOS fleet) knows none of these.
85+ #
86+ # Introduced 2026-09-04, when the macOS builders moved to Apple clang 21
87+ # (Xcode 26.6) and every O2 PR check on them began failing on a different new
88+ # diagnostic each time the previous one was fixed. Fixing the source is still
89+ # preferable where the code is actually wrong -- three such fixes went in that
90+ # day -- but some of these fire on intentional constructs: FlatObject relocates
91+ # flat objects bitwise BY DESIGN, and its types delete their copy constructors
92+ # precisely so nobody copies them the C++ way, which is what
93+ # -Wnontrivial-memcall objects to.
94+ set (O2_NEW_COMPILER_WARNINGS_NO_ERROR "nontrivial-memcall;deprecated-literal-operator;final-dtor-non-final-class;nonnull" )
95+ o2_build_warning_flags (PREFIX "-Wno-error="
96+ OUTPUTVARNAME O2_NEW_COMPILER_NO_ERROR_FLAGS
97+ WARNINGS ${O2_NEW_COMPILER_WARNINGS_NO_ERROR} )
98+
99+ string (JOIN " " CMAKE_C_WARNINGS "-Wno-unknown-warning-option" "-Wno-vla-cxx-extension" ${O2_C_ENABLED_WARNINGS} ${O2_C_ENABLED_WARNINGS_NO_ERROR} ${O2_NEW_COMPILER_NO_ERROR_FLAGS} )
100+ string (JOIN " " CMAKE_CXX_WARNINGS "-Wno-unknown-warning-option" "-Wno-vla-cxx-extension" ${O2_CXX_ENABLED_WARNINGS} ${O2_CXX_ENABLED_WARNINGS_NO_ERROR} ${O2_NEW_COMPILER_NO_ERROR_FLAGS} )
71101
72102string (REGEX MATCH "-O[0-9]+" CMAKE_FLAGS_OPT_VALUE "${CMAKE_CXX_FLAGS } " )
73103if (NOT CMAKE_FLAGS_OPT_VALUE OR CMAKE_FLAGS_OPT_VALUE STREQUAL "-O0" OR CMAKE_FLAGS_OPT_VALUE STREQUAL "-O1" )
0 commit comments