build: Make sure ifuncs exist when using fp16
authorBenjamin Otte <otte@redhat.com>
Fri, 22 Oct 2021 14:31:40 +0000 (16:31 +0200)
committerBenjamin Otte <otte@redhat.com>
Fri, 22 Oct 2021 15:50:42 +0000 (17:50 +0200)
Fixes msys compiles on Windows (and everywhere else hopefully).

Fixes #4285

meson.build

index 897de137661b66bc55c370d0ab6a0248dbd472dc..02a2786c5c456c470d82bebdab6a163fbb1e19f6 100644 (file)
@@ -712,12 +712,24 @@ if get_option('f16c').enabled()
 # if !defined(__amd64__) && !defined(__x86_64__)
 #   error "F16C intrinsics are only available on x86_64"
 # endif
+#if !defined __has_attribute
+# error "No __has_attribute() support"
+#endif
+#if !__has_attribute(ifunc)
+# error "ifunc not supported"
+#endif
+static int resolved_ifunc (void) { return 0; }
+static void *resolve_ifunc (void) { return resolved_ifunc; }
+int ifunc_test (void) __attribute__((ifunc ("resolve_ifunc")));
+#else
+int ifunc_test (void) { return 0; }
 #endif
 #if defined(__SSE__) || defined(_MSC_VER)
 # include <immintrin.h>
 #else
 # error "No F16C intrinsics available"
 #endif
+
 int main () {
   float f[4] = { 0, };
   unsigned short h[4] = { 0, };
@@ -730,7 +742,7 @@ int main () {
   __builtin_cpu_supports ("f16c");
 #endif
 
-    return 0;
+    return ifunc_test ();
 }'''
   if cc.get_id() != 'msvc'
     test_f16c_cflags = [ '-mf16c' ]