Skip to content

Commit 8a18bff

Browse files
hzhouraffenet
andcommitted
configure: use AC_LINK_IFELSE to check __fp16
Clang can compile __fp16 even when it doesn't support it. When we try link, it will report: /usr/bin/ld: lib/.libs/libmpi.so: undefined reference to `__gnu_h2f_ieee' Co-authored-by: Ken Raffenetti <[email protected]>
1 parent 5526b25 commit 8a18bff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

configure.ac

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,8 +2890,12 @@ if test "$MPID_NO_INT128" != "yes" ; then
28902890
fi
28912891

28922892
if test "$MPID_NO_FLOAT16" != "yes" ; then
2893-
AC_CHECK_SIZEOF(_Float16)
2894-
AC_CHECK_SIZEOF(__fp16)
2893+
# some compilers (e.g. clang) can compile but not link come types.
2894+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[_Float16 a = 0.1;]], [[return (int) a;]])],
2895+
[AC_CHECK_SIZEOF(_Float16)])
2896+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[__fp16 a = 0.1;]], [[return (int) a;]])],
2897+
[AC_CHECK_SIZEOF(__fp16)])
2898+
28952899
if test "$ac_cv_sizeof__Float16" -eq 2 ; then
28962900
AC_DEFINE_UNQUOTED([MPIR_FLOAT16_CTYPE],[_Float16], [The C type for MPIR_FLOAT16])
28972901
AC_CHECK_ALIGNOF(_Float16)

0 commit comments

Comments
 (0)