diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-01-23 23:19:51 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-01-26 09:16:48 +0530 |
commit | fbbfbfac7e13ad2fb594f52678652afc262c1005 (patch) | |
tree | a5971c7123f8ddace2ea241cda6cb30df25870ad /mesonbuild/compilers.py | |
parent | 7e1654bf083a78080ce92f0f2fe0310aae41e0d3 (diff) | |
download | meson-fbbfbfac7e13ad2fb594f52678652afc262c1005.zip meson-fbbfbfac7e13ad2fb594f52678652afc262c1005.tar.gz meson-fbbfbfac7e13ad2fb594f52678652afc262c1005.tar.bz2 |
compilers: Fix builtin checks with clang on Linux
Our "43 has function" test should also work with clang and icc on Linux,
so enable them. Also detect builtins with __has_builtin if available,
which is much faster on clang.
There is a feature request for the same with GCC too:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 23e7bbe..43d3356 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1057,7 +1057,16 @@ int main(int argc, char **argv) { # posix_memalign in the headers to point to that builtin which results # in an invalid detection. if '#include' not in prefix: - code = 'int main() {{ {0}; }}' + code = ''' + int main() {{ + #ifdef __has_builtin + #if !__has_builtin({0}) + #error "built-in {0} not found" + #endif + #else + {0}; + #endif + }}''' return self.links(code.format('__builtin_' + funcname), env, extra_args, dependencies) else: |