From e72523ae410d780c3a703f0e3296105408fcc122 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 11 Apr 2016 04:29:09 +0530 Subject: [PATCH] compilers: Use compiler-specific no-optimization flags MSVC doesn't understand -O0. It uses -Od (or /Od) instead. --- mesonbuild/compilers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 1c672660e..9e90bccde 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -350,6 +350,9 @@ class CCompiler(Compiler): def get_compile_only_args(self): return ['-c'] + def get_no_optimization_args(self): + return ['-O0'] + def get_output_args(self, target): return ['-o', target] @@ -468,7 +471,8 @@ int someSymbolHereJustForFun; #include <{0}> int main () {{ {1}; }}''' # Pass -O0 to ensure that the symbol isn't optimized away - return self.compiles(templ.format(hname, symbol, prefix), extra_args + ['-O0']) + extra_args += self.get_no_optimization_args() + return self.compiles(templ.format(hname, symbol, prefix), extra_args) def compile(self, code, srcname, extra_args=[]): commands = self.get_exelist() @@ -697,7 +701,8 @@ int main(int argc, char **argv) { # special functions that ignore all includes and defines, so we just # directly try to link via main(). # Add -O0 to ensure that the symbol isn't optimized away by the compiler - return self.links('int main() {{ {0}; }}'.format('__builtin_' + funcname), extra_args + ['-O0']) + extra_args += self.get_no_optimization_args() + return self.links('int main() {{ {0}; }}'.format('__builtin_' + funcname), extra_args) def has_member(self, typename, membername, prefix, extra_args=[]): templ = '''%s @@ -1298,6 +1303,9 @@ class VisualStudioCCompiler(CCompiler): def get_compile_only_args(self): return ['/c'] + def get_no_optimization_args(self): + return ['/Od'] + def get_output_args(self, target): if target.endswith('.exe'): return ['/Fe' + target]