summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattijs Korpershoek <mkorpershoek@baylibre.com>2023-10-13 10:48:48 +0200
committerMattijs Korpershoek <mkorpershoek@baylibre.com>2023-10-13 16:31:13 +0200
commitf6b0e5b1de401e9dc9a5f622903c160f66c9719e (patch)
treee609d07c334033f49078a2c24d6c77bf61474f4f
parent0d5e9943e9ba845b28f958f089f02462c0ac425f (diff)
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 <mkorpershoek@baylibre.com>
-rw-r--r--meson.build15
1 files changed, 9 insertions, 6 deletions
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 += [