@@ -66,8 +66,43 @@ 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+ # Clang only, and that is not incidental. -Wno-unknown-warning-option makes an
83+ # unknown name harmless on clang, including clang 16 (Xcode 16.2, still on part
84+ # of the macOS fleet), which knows none of these. GCC gives no such guarantee:
85+ # it swallows an unknown -Wno-foo silently but rejects -Wno-error=foo with a
86+ # hard "no option '-Wfoo'" error, so emitting these unconditionally broke every
87+ # GCC build. Three of the four are clang-only spellings anyway.
88+ #
89+ # Introduced 2026-09-04, when the macOS builders moved to Apple clang 21
90+ # (Xcode 26.6) and every O2 PR check on them began failing on a different new
91+ # diagnostic each time the previous one was fixed. Fixing the source is still
92+ # preferable where the code is actually wrong -- three such fixes went in that
93+ # day -- but some of these fire on intentional constructs: FlatObject relocates
94+ # flat objects bitwise BY DESIGN, and its types delete their copy constructors
95+ # precisely so nobody copies them the C++ way, which is what
96+ # -Wnontrivial-memcall objects to.
97+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
98+ set (O2_NEW_COMPILER_WARNINGS_NO_ERROR "nontrivial-memcall;deprecated-literal-operator;final-dtor-non-final-class;nonnull" )
99+ o2_build_warning_flags (PREFIX "-Wno-error="
100+ OUTPUTVARNAME O2_NEW_COMPILER_NO_ERROR_FLAGS
101+ WARNINGS ${O2_NEW_COMPILER_WARNINGS_NO_ERROR} )
102+ endif ()
103+
104+ 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} )
105+ 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} )
71106
72107string (REGEX MATCH "-O[0-9]+" CMAKE_FLAGS_OPT_VALUE "${CMAKE_CXX_FLAGS } " )
73108if (NOT CMAKE_FLAGS_OPT_VALUE OR CMAKE_FLAGS_OPT_VALUE STREQUAL "-O0" OR CMAKE_FLAGS_OPT_VALUE STREQUAL "-O1" )
0 commit comments