From f6b0e5b1de401e9dc9a5f622903c160f66c9719e Mon Sep 17 00:00:00 2001 From: Mattijs Korpershoek Date: Fri, 13 Oct 2023 10:48:48 +0200 Subject: meson: fix building with cpp_stlib When building with custom STLs [1], meson will pass -nostdlib++ to the compiler, which will conflict with the -stdlib=libc++ flag: clang-17: error: argument unused during compilation: '-stdlib=libc++' [-Werror,-Wunused-command-line-argument] Test the user requested a custom cpp_stlib and only configure libc++ when needed. [1] https://mesonbuild.com/Cross-compilation.html#using-a-custom-standard-library Signed-off-by: Mattijs Korpershoek --- meson.build | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index e9a1c7e3..7850454d 100644 --- a/meson.build +++ b/meson.build @@ -113,12 +113,15 @@ if cc.get_id() == 'clang' endif endif - # Use libc++ by default if available instead of libstdc++ when compiling - # with clang. - if cc.find_library('c++', required : false).found() - cpp_arguments += [ - '-stdlib=libc++', - ] + custom_stl = meson.get_external_property('cpp_stdlib', '') + if custom_stl == '' + # Use libc++ by default if available instead of libstdc++ when compiling + # with clang and no custom STL has been configured. + if cc.find_library('c++', required : false).found() + cpp_arguments += [ + '-stdlib=libc++', + ] + endif endif cpp_arguments += [ -- cgit v1.2.1