diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-11-19 01:28:26 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-11-20 16:53:58 -0500 |
commit | 82bb24b264a1d46c7037b69f1cc10b123bbcf9b5 (patch) | |
tree | e855c84e848043e5296b0e8442157d3b5680c731 | |
parent | 8f41154827d9608234d0c0455551392d968d9e23 (diff) | |
download | meson-82bb24b264a1d46c7037b69f1cc10b123bbcf9b5.zip meson-82bb24b264a1d46c7037b69f1cc10b123bbcf9b5.tar.gz meson-82bb24b264a1d46c7037b69f1cc10b123bbcf9b5.tar.bz2 |
Made has_function survive optimization flags. Closes #1053.
-rw-r--r-- | mesonbuild/compilers.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index fef4c1d..ced2b6f 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -927,9 +927,11 @@ int main(int argc, char **argv) { """ # Add the 'prefix', aka defines, includes, etc that the user provides head = '#include <limits.h>\n{0}\n' - # We don't know what the function takes or returns, so try to use it as - # a function pointer - main = '\nint main() {{ void *a = (void*) &{1}; }}' + # We don't know what the function takes or returns, so return it as an int. + # Just taking the address or comparing it to void is not enough because + # compilers are smart enough to optimize it away. The resulting binary + # is not run so we don't care what the return value is. + main = '\nint main() {{ void *a = (void*) &{1}; long b = (long) a; return (int) b; }}' return head, main def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None): |