aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2016-04-11 04:29:09 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2016-04-11 04:30:48 +0530
commite72523ae410d780c3a703f0e3296105408fcc122 (patch)
tree384250bb35180139643a502d96891c173376a1d1
parent4e084e7ac1339d7a48b08028b6371265ca2f2a9a (diff)
downloadmeson-e72523ae410d780c3a703f0e3296105408fcc122.zip
meson-e72523ae410d780c3a703f0e3296105408fcc122.tar.gz
meson-e72523ae410d780c3a703f0e3296105408fcc122.tar.bz2
compilers: Use compiler-specific no-optimization flags
MSVC doesn't understand -O0. It uses -Od (or /Od) instead.
-rw-r--r--mesonbuild/compilers.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 1c67266..9e90bcc 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]