From 4ae75eef16ce821e8d551fd8f0eb70ab6e194553 Mon Sep 17 00:00:00 2001 From: Mattijs Korpershoek Date: Wed, 11 Oct 2023 15:04:38 +0200 Subject: cpp: use -nostlib++ instead of -nostlib for custom cpp_stdlib The _stdlib can be used in cross files to use a custom standard library for a given language. When cpp_stdlib is used in a cross file, meson passes * -nostdinc++ to the compiler * -nostlib to the linker According to [1] (gcc) and [2] (clang), we should pass -nostlib++ to the linker when we don't want to link to the standard C++ library. Currently, we pass -nostlib. Fix this by implementing a C++ specific get_no_stdlib_link_args() function. [1] https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-nostdlib_002b_002b [2] https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-nostdlib Signed-off-by: Mattijs Korpershoek --- mesonbuild/compilers/cpp.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/compilers/cpp.py') diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index dc733dd9e..43a5492f0 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -93,6 +93,9 @@ class CPPCompiler(CLikeCompiler, Compiler): def get_no_stdinc_args(self) -> T.List[str]: return ['-nostdinc++'] + def get_no_stdlib_link_args(self) -> T.List[str]: + return ['-nostdlib++'] + def sanity_check(self, work_dir: str, environment: 'Environment') -> None: code = 'class breakCCompiler;int main(void) { return 0; }\n' return self._sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code) -- cgit v1.2.3