aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorAndrei Alexeyev <akari@taisei-project.org>2020-04-02 03:43:24 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2020-04-04 20:51:35 +0300
commit96ed64caa11f977c33ae8bf4143f8756ab3c1a36 (patch)
tree6e93a64eae35e86a72c3e395bbc1dc27c037e0ae /mesonbuild/compilers
parent1a741e0439deeef241053df04bc6e521d70aaae5 (diff)
downloadmeson-96ed64caa11f977c33ae8bf4143f8756ab3c1a36.zip
meson-96ed64caa11f977c33ae8bf4143f8756ab3c1a36.tar.gz
meson-96ed64caa11f977c33ae8bf4143f8756ab3c1a36.tar.bz2
Make cc.has_function work on GCC/Clang __builtins
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/mixins/clike.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index e043bcd..6b09b97 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -727,22 +727,23 @@ class CLikeCompiler:
# need to look for them differently. On nice compilers like clang, we
# can just directly use the __has_builtin() macro.
fargs['no_includes'] = '#include' not in prefix
+ fargs['__builtin_'] = '' if funcname.startswith('__builtin_') else '__builtin_'
t = '''{prefix}
int main(void) {{
#ifdef __has_builtin
- #if !__has_builtin(__builtin_{func})
- #error "__builtin_{func} not found"
+ #if !__has_builtin({__builtin_}{func})
+ #error "{__builtin_}{func} not found"
#endif
#elif ! defined({func})
- /* Check for __builtin_{func} only if no includes were added to the
+ /* Check for {__builtin_}{func} only if no includes were added to the
* prefix above, which means no definition of {func} can be found.
* We would always check for this, but we get false positives on
* MSYS2 if we do. Their toolchain is broken, but we can at least
* give them a workaround. */
#if {no_includes:d}
- __builtin_{func};
+ {__builtin_}{func};
#else
- #error "No definition for __builtin_{func} found in the prefix"
+ #error "No definition for {__builtin_}{func} found in the prefix"
#endif
#endif
return 0;