aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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]