Open sammyj85 opened 10 months ago
I think for clang++, you'd want to pass -stdlib=c++
, as in https://libcxx.llvm.org/UsingLibcxx.html#using-libc-when-it-is-not-the-system-default
Isn't that the job of Meson to add that flag when I use cpp_stdlib = 'c++'
?
What is the purpose of Meson's cpp_stdlib
if not?
Isn't that the job of Meson to add that flag when I use
cpp_stdlib = 'c++'
?
It is, but it doesn't work. I needed to set CXXFLAGS="-stdlib=libc++"
.
Isn't that the job of Meson to add that flag when I use
cpp_stdlib = 'c++'
?It is, but it doesn't work. I needed to set
CXXFLAGS="-stdlib=libc++"
.
That is the whole point of this issue - cpp_stdlib exists but doesn't work (at least according to how the documentation suggests it should).
The options are:
cpp_stdlib
, and probably add an example in the documentation of how to use it with libc++.<lang>_stdlib
, and remove the documentation, and just specify it yourself on a per-compiler basis (-stdlib=libc++
).The documentation is pretty straightforward that this variable is not expected to contain the name of a -stdlib= value, but rather that it should contain the name of a subproject dependency which builds a (most likely embedded) stdlib.
Meson would then also compile with -nostdlib++
to avoid linking in multiple stdlibs.
Thanks for the reply, and that's a relief that it's pretty straightforward.
So to answer the original question, how would an example of using the system-provided libc++ look?
I am running Fedora Linux, and I'm interested in using libc++ as the stdlib with Clang. I have installed the system package for libc++ (not built it myself).
I see there's other issue bugs about automatically selecting libc++ when there is no libstdc++ provided by default (such as FreeBSD). But I would like to manually choose libc++ over the default libstdc++.
I cannot find an example of how to do this. The documentation seems to infer the native/cross file should have:
https://mesonbuild.com/Cross-compilation.html#using-a-custom-standard-library
Where
cxx_dep
is to be defined elsewhere, such ascxx_dep = dependency('c++')
in the main meson.build (which duplicates the library name to search for).When trying do meson setup with the native file for clang/lld/libc++, it gives the error:
The meson.build
dependency('c++')
command didn't find the built in system package of libc++.So perhaps it's popular enough that there's a wrap for it? I searched the WrapDB, and there was no libc++/c++/libcxx.
https://mesonbuild.com/Wrapdb-projects.html
How do I achieve this? Could the documentation be expanded to include this libc++ example when it documents [lang]_stdlib (first link above)? Surely this is a more popular standard library option than the near zero level of documentation I can find suggests it is.