cc.has_function: Don't forget to check for stubs in the fallback test

The fallback test was making the stub check on Linux/glibc completely useless.

Fixes #535
pull/537/head
Nirbheek Chauhan 9 years ago
parent 7da51f3756
commit c9f16a4ab1
  1. 8
      mesonbuild/compilers.py

@ -709,11 +709,12 @@ int main(int argc, char **argv) {
# glibc defines functions that are not available on Linux as stubs that # glibc defines functions that are not available on Linux as stubs that
# fail with ENOSYS (such as e.g. lchmod). In this case we want to fail # fail with ENOSYS (such as e.g. lchmod). In this case we want to fail
# instead of detecting the stub as a valid symbol. # instead of detecting the stub as a valid symbol.
templ += ''' stubs_fail = '''
#if defined __stub_{1} || defined __stub___{1} #if defined __stub_{1} || defined __stub___{1}
fail fail fail this function is not going to work fail fail fail this function is not going to work
#endif #endif
''' '''
templ += stubs_fail
# And finally the actual function call # And finally the actual function call
templ += ''' templ += '''
@ -736,8 +737,9 @@ int main(int argc, char **argv) {
extra_args += self.get_no_optimization_args() extra_args += self.get_no_optimization_args()
# Sometimes the implementation is provided by the header, or the header # Sometimes the implementation is provided by the header, or the header
# redefines the symbol to be something else. In that case, we want to # redefines the symbol to be something else. In that case, we want to
# still detect the function. # still detect the function. We still want to fail if __stub_foo or
if self.links('{0}\nint main() {{ {1}; }}'.format(prefix, funcname), extra_args): # _stub_foo are defined, of course.
if self.links('{0}\n' + stubs_fail + '\nint main() {{ {1}; }}'.format(prefix, funcname), extra_args):
return True return True
# Some functions like alloca() are defined as compiler built-ins which # Some functions like alloca() are defined as compiler built-ins which
# are inlined by the compiler, so test for that instead. Built-ins are # are inlined by the compiler, so test for that instead. Built-ins are

Loading…
Cancel
Save