Skip to content

Commit d0e8e60

Browse files
roblablaBusyJay
authored andcommitted
Fix compilation with MSVC 2022
On MSVC, log is an intrinsic that doesn't require libm. However, AC_SEARCH_LIBS does not successfully detect this, as it will try to compile a program using the wrong signature for log. Newer versions of MSVC CL detects this and rejects the program with the following messages: conftest.c(40): warning C4391: 'char log()': incorrect return type for intrinsic function, expected 'double' conftest.c(44): error C2168: 'log': too few actual parameters for intrinsic function Since log is always available on MSVC (it's been around since the dawn of time), we simply always assume it's there if MSVC is detected. Signed-off-by: roblabla <[email protected]>
1 parent e13ca99 commit d0e8e60

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

configure.ac

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,26 @@ AC_SUBST([DUMP_SYMS])
829829
AC_SUBST([CC_MM])
830830

831831
dnl Determine whether libm must be linked to use e.g. log(3).
832-
AC_SEARCH_LIBS([log], [m], , [AC_MSG_ERROR([Missing math functions])])
833-
if test "x$ac_cv_search_log" != "xnone required" ; then
834-
LM="$ac_cv_search_log"
835-
else
832+
833+
# On MSVC, log is an intrinsic that doesn't require libm. However,
834+
# AC_SEARCH_LIBS does not successfully detect this, as it will try to compile
835+
# a program using the wrong signature for log. Newer versions of MSVC CL detects
836+
# this and rejects the program with the following messages.
837+
#
838+
# conftest.c(40): warning C4391: 'char log()': incorrect return type for intrinsic function, expected 'double'
839+
# conftest.c(44): error C2168: 'log': too few actual parameters for intrinsic function
840+
#
841+
# Since log is always available on MSVC (it's been around since the dawn of
842+
# time), we simply always assume it's there if MSVC is detected.
843+
if test "x$je_cv_msvc" = "xyes" ; then
836844
LM=
845+
else
846+
AC_SEARCH_LIBS([log], [m], , [AC_MSG_ERROR([Missing math functions])])
847+
if test "x$ac_cv_search_log" != "xnone required" ; then
848+
LM="$ac_cv_search_log"
849+
else
850+
LM=
851+
fi
837852
fi
838853
AC_SUBST(LM)
839854

0 commit comments

Comments
 (0)