Skip to content

Fix _LIBCPP_ENABLE_ASSERTIONS warning on Apple Clang - #14548

Merged
jpakkane merged 1 commit into
mesonbuild:masterfrom
mortie:fix-libcpp-enable-assertions-deprecation
May 2, 2025
Merged

jpakkane merged 1 commit into
mesonbuild:masterfrom
mortie:fix-libcpp-enable-assertions-deprecation

Conversation

@mortie

@mortie mortie commented May 2, 2025 •

Copy link
Copy Markdown
Contributor

libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS from version 18. However, the libc++ shipped with Apple Clang backported that deprecation in version 17 already, which is the version which Apple currently ships for macOS. This PR changes the _LIBCPP_ENABLE_ASSERTIONS deprecation check to use version ">=17" on Apple Clang.

I decided to do this by adding a is_libcpp_enable_assertions_deprecated method to ClangCPPCompiler, whose default behavior is to compare the version against ">=18", but which gets overridden by AppleClangCPPCompiler to check against ">=17". This felt fairly clean to me and avoided hard-coding macOS/Apple specific quirks into the general ClangCPPCompiler class.

Fixes #14440.

libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS from version 18.
However, the libc++ shipped with Apple Clang backported that
deprecation in version 17 already,
which is the version which Apple currently ships for macOS.
This PR changes the _LIBCPP_ENABLE_ASSERTIONS deprecation check
to use version ">=17" on Apple Clang.
@mortie
mortie requested a review from dcbaker as a code owner May 2, 2025 09:02
@mortie

mortie commented May 2, 2025 •

Copy link
Copy Markdown
Contributor Author

Before this PR:

Log showing compiler output when building one of my projects with Meson 1.8.0
~/src/project-swan main* $ meson setup build
The Meson build system
Version: 1.8.0
Source dir: /Users/martin/src/project-swan
Build dir: /Users/martin/src/project-swan/build
Build type: native build
Project name: swan
Project version: undefined
C++ compiler for the host machine: c++ (clang 17.0.0 "Apple clang version 17.0.0 (clang-1700.0.13.3)")
C++ linker for the host machine: c++ ld64 1167.4.1
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program ./scripts/shaderpp.py found: YES (/Users/martin/src/project-swan/./scripts/shaderpp.py)
Program capnp found: YES (/opt/homebrew/bin/capnp)
Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 2.4.3
Run-time dependency glfw3 found: YES 3.4.0
Run-time dependency libavcodec found: YES 61.19.101
Run-time dependency libavutil found: YES 59.39.100
Run-time dependency libswscale found: YES 8.3.100
Run-time dependency libavformat found: YES 61.7.100
Run-time dependency portaudio-2.0 found: YES 19
Run-time dependency capnp found: YES 1.1.0
Library dl found: YES
Library z found: YES
Run-time dependency opengl found: YES (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework)
Found CMake: /opt/homebrew/bin/cmake (4.0.1)
Run-time dependency libdw found: NO (tried pkgconfig, framework and cmake)
Run-time dependency threads found: YES
Build targets in project: 12

Found ninja-1.12.1 at /opt/homebrew/bin/ninja
~/src/project-swan main* $ ninja -C build
ninja: Entering directory `build'
[11/95] Compiling C++ object third-party/libimgui.a.p/imgui_backends_imgui_impl_opengl3.cpp.o
In file included from ../third-party/imgui/backends/imgui_impl_opengl3.cpp:116:
In file included from ../third-party/imgui/imgui.h:73:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/float.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[12/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Blend.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Blend.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Blend.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[13/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Chunk.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Chunk.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Chunk.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[14/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_ChunkShadow.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/ChunkShadow.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/ChunkShadow.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[15/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_ChunkFluid.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/ChunkFluid.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/ChunkFluid.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[16/95] Compiling C++ object third-party/libstb_truetype.a.p/stb-support_stb_truetype.cc.o
In file included from ../third-party/stb-support/stb_truetype.cc:2:
In file included from ../third-party/stb/stb_truetype.h:441:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:294:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[17/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Particle.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Particle.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Particle.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[18/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Rect.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Rect.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Rect.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[19/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Sprite.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Sprite.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Sprite.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[20/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Text.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Text.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Text.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[21/95] Compiling C++ object libcygnet/libcygnet.dylib.p/meson-generated_Tile.glsl.cc.o
In file included from libcygnet/libcygnet.dylib.p/Tile.glsl.cc:3:
In file included from libcygnet/libcygnet.dylib.p/Tile.glsl.h:5:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[23/95] Compiling C++ object libcygnet/libcygnet.dylib.p/src_gl.cc.o
In file included from ../libcygnet/src/gl.cc:1:
In file included from ../libcygnet/include/cygnet/gl.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/CGLDevice.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdint.h:106:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[24/95] Compiling C++ object third-party/libstb_vorbis.a.p/stb-support_stb_vorbis.cc.o
In file included from ../third-party/stb-support/stb_vorbis.cc:1:
In file included from ../third-party/stb/stb_vorbis.c:82:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h:101:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[25/95] Compiling C++ object third-party/libstb_image.a.p/stb-support_stb_image.cc.o
In file included from ../third-party/stb-support/stb_image.cc:2:
In file included from ../third-party/stb/stb_image.h:371:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h:101:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[26/95] Compiling C++ object third-party/libimgui.a.p/imgui_imgui_tables.cpp.o
In file included from ../third-party/imgui/imgui_tables.cpp:198:
In file included from ../third-party/imgui/imgui.h:73:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/float.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[28/95] Compiling C++ object third-party/libimgui.a.p/imgui_backends_imgui_impl_glfw.cpp.o
In file included from ../third-party/imgui/backends/imgui_impl_glfw.cpp:85:
In file included from ../third-party/imgui/imgui.h:73:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/float.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[30/95] Compiling C++ object third-party/libimgui.a.p/imgui_imgui_draw.cpp.o
In file included from ../third-party/imgui/imgui_draw.cpp:34:
In file included from ../third-party/imgui/imgui.h:73:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/float.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[31/95] Compiling C++ object third-party/libimgui.a.p/imgui_imgui_demo.cpp.o
In file included from ../third-party/imgui/imgui_demo.cpp:106:
In file included from ../third-party/imgui/imgui.h:73:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/float.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 warning generated.
[32/95] Compiling C++ object libswan/libswan.dylib.p/meson-generated_.._swan.capnp.c++.o
In file included from libswan/swan.capnp.c++:4:
In file included from libswan/swan.capnp.h:6:
In file included from /opt/homebrew/Cellar/capnp/1.1.0/include/capnp/generated-header-support.h:26:
In file included from /opt/homebrew/Cellar/capnp/1.1.0/include/capnp/raw-schema.h:24:
In file included from /opt/homebrew/Cellar/capnp/1.1.0/include/capnp/common.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/inttypes.h:238:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:48:6: warning: "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" [-W#warnings]
   48 | #    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
[... etc]

After this PR:

Log showing compiler output when building the same project with this fix
~/src/project-swan main* $ ../meson/meson.py setup build
The Meson build system
Version: 1.8.99
Source dir: /Users/martin/src/project-swan
Build dir: /Users/martin/src/project-swan/build
Build type: native build
Project name: swan
Project version: undefined
C++ compiler for the host machine: c++ (clang 17.0.0 "Apple clang version 17.0.0 (clang-1700.0.13.3)")
C++ linker for the host machine: c++ ld64 1167.4.1
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program ./scripts/shaderpp.py found: YES (/Users/martin/src/project-swan/./scripts/shaderpp.py)
Program capnp found: YES (/opt/homebrew/bin/capnp)
Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 2.4.3
Run-time dependency glfw3 found: YES 3.4.0
Run-time dependency libavcodec found: YES 61.19.101
Run-time dependency libavutil found: YES 59.39.100
Run-time dependency libswscale found: YES 8.3.100
Run-time dependency libavformat found: YES 61.7.100
Run-time dependency portaudio-2.0 found: YES 19
Run-time dependency capnp found: YES 1.1.0
Library dl found: YES
Library z found: YES
Run-time dependency opengl found: YES (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework)
Found CMake: /opt/homebrew/bin/cmake (4.0.1)
Run-time dependency libdw found: NO (tried pkgconfig, framework and cmake)
Run-time dependency threads found: YES
Build targets in project: 12

Found ninja-1.12.1 at /opt/homebrew/bin/ninja
~/src/project-swan main* $ ninja -C build
ninja: Entering directory `build'
[95/95] Linking target swan

return []

def is_libcpp_enable_assertions_deprecated(self) -> bool:
return version_compare(self.version, ">=18")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks clang version and not libc++ version, right? They might mismatch so this check is technically incorrect, especially on systems with more than one version of clang installed.

(This is the previous behavior so it's probably fine to keep it here, just noting)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I noticed that too. In principle, we would want the check to be: "if libc++ >= 18 is used, or Apple's libc++ >=17 is used, use _LIBCPP_HARDENING_MODE instead of _LIBCPP_ENABLE_ASSERTIONS".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That merits a comment, but it's already handled in my pending refactoring of it.

@jpakkane
jpakkane merged commit a16ec8b into mesonbuild:master May 2, 2025
@thesamesam

Copy link
Copy Markdown
Member

@jpakkane In future, please at least CC me on a PR if I'm assigned to the issue it fixes.

@BertalanD

Copy link
Copy Markdown

Hey @eli-schwartz. Sorry for the ping, but Apple started shipping a newer compiler with Xcode 26 beta, which includes a change that makes defining _LIBCPP_ENABLE_ASSERTIONS a hard error. Could a release which includes this change be cut by any chance?

@eli-schwartz

Copy link
Copy Markdown
Member

Ten minutes before your comment, we released a maintenance 1.8.2 :(

I could queue it for the next maintenance release but it's not gonna be out today...

@srl295

srl295 commented Jun 13, 2025

Copy link
Copy Markdown

I think this is a good time to sponsor @eli-schwartz (as @codehivetx) — thanks for your work 💟

@eli-schwartz

Copy link
Copy Markdown
Member

Note 1.8.3 is out with this fix. :)

novas0x2a added a commit to bazel-contrib/rules_foreign_cc that referenced this pull request Mar 8, 2026
meson versions < 1.9.0 are broken with apple-clang 17 (fix is in
mesonbuild/meson#14548; apple made this an error
with xcode 26)

This also changes the default meson to 1.10.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clang 17 warnings: _LIBCPP_ENABLE_ASSERTIONS is deprecated

7 participants