Made has_function survive optimization flags. Closes #1053.

pull/1068/head
Jussi Pakkanen 8 years ago
parent 8f41154827
commit 82bb24b264
  1. 8
      mesonbuild/compilers.py

@ -927,9 +927,11 @@ int main(int argc, char **argv) {
""" """
# Add the 'prefix', aka defines, includes, etc that the user provides # Add the 'prefix', aka defines, includes, etc that the user provides
head = '#include <limits.h>\n{0}\n' head = '#include <limits.h>\n{0}\n'
# We don't know what the function takes or returns, so try to use it as # We don't know what the function takes or returns, so return it as an int.
# a function pointer # Just taking the address or comparing it to void is not enough because
main = '\nint main() {{ void *a = (void*) &{1}; }}' # 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 return head, main
def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None): def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):

Loading…
Cancel
Save