From 72cbc3b005b45b6e1ef8a5f4d026ef06e05c4392 Mon Sep 17 00:00:00 2001 From: "Schmitz Manuel (LBC)" Date: Wed, 9 Jun 2021 15:35:12 +0100 Subject: [PATCH] Fixed issue #8412: '-nostdinc'/'-nostdinc++' become '/X' and '-nostdlib' becomes '/NODEFAULTLIB' in MSVC --- mesonbuild/compilers/c.py | 5 ++++- mesonbuild/compilers/cpp.py | 5 ++++- mesonbuild/compilers/mixins/clike.py | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 8f6218195..50cbe56f3 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -73,7 +73,10 @@ class CCompiler(CLikeCompiler, Compiler): CLikeCompiler.__init__(self, exe_wrapper) def get_no_stdinc_args(self) -> T.List[str]: - return ['-nostdinc'] + if self.get_id() == 'msvc': + return ['/X'] + else: + return ['-nostdinc'] def sanity_check(self, work_dir: str, environment: 'Environment') -> None: code = 'int main(void) { int class=0; return class; }\n' diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index c267c0fed..130ec7df5 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -85,7 +85,10 @@ class CPPCompiler(CLikeCompiler, Compiler): return 'C++' def get_no_stdinc_args(self) -> T.List[str]: - return ['-nostdinc++'] + if self.get_id() == 'msvc': + return ['/X'] + else: + return ['-nostdinc++'] def sanity_check(self, work_dir: str, environment: 'Environment') -> None: code = 'class breakCCompiler;int main(void) { return 0; }\n' diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 3210dd7f3..63516da0a 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -159,10 +159,16 @@ class CLikeCompiler(Compiler): return self.get_largefile_args() def get_no_stdinc_args(self) -> T.List[str]: - return ['-nostdinc'] + if self.get_id() == 'msvc': + return ['/X'] + else: + return ['-nostdinc'] def get_no_stdlib_link_args(self) -> T.List[str]: - return ['-nostdlib'] + if self.get_id() == 'msvc': + return ['/NODEFAULTLIB'] + else: + return ['-nostdlib'] def get_warn_args(self, level: str) -> T.List[str]: # TODO: this should be an enum