[Git][ghc/ghc][wip/romes/24815] configure: Check C99-compat for Cmm preprocessor

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Wed May 15 10:53:47 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/24815 at Glasgow Haskell Compiler / GHC


Commits:
1a93d2db by Rodrigo Mesquita at 2024-05-15T11:53:27+01:00
configure: Check C99-compat for Cmm preprocessor

Fixes #24815

- - - - -


1 changed file:

- m4/fp_cmm_cpp_cmd_with_args.m4


Changes:

=====================================
m4/fp_cmm_cpp_cmd_with_args.m4
=====================================
@@ -2,8 +2,10 @@
 # --------------------------
 # sets CMM_CPP command and its arguments
 #
-# $1 = the variable to set to Cmm CPP command
-# $2 = the variable to set to Cmm CPP command arguments
+# $1 = the path to the C compiler
+# $2 = the variable to set to Cmm CPP command
+# $3 = the variable to set to Cmm CPP command arguments
+# $4 = whether Cmm CPP command supports -g0
 
 AC_DEFUN([FP_CMM_CPP_CMD_WITH_ARGS],[
 
@@ -46,14 +48,33 @@ AC_ARG_WITH(cmm-cpp-flags,
 
 AC_MSG_CHECKING([whether the C-- preprocessor "$CMM_CPP_CMD" $CMM_CPP_ARGS supports -g0])
 : > conftest.c
-if "$CMM_CPP_CMD" $CMM_CPP_ARGS conftest.c -g0 >/dev/null 2>&1; then
+if "$CMM_CPP_CMD" $CMM_CPP_ARGS conftest.c -o conftest -g0 >/dev/null 2>&1; then
   $4=True
   AC_MSG_RESULT([yes])
 else
   $4=False
   AC_MSG_RESULT([no])
 fi
-rm -f conftest.c
+
+AC_MSG_CHECKING([the C-- preprocessor for C99 support])
+cat > conftest.c <<EOF
+#include <stdio.h>
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
+EOF
+if "$CMM_CPP_CMD" $CMM_CPP_ARGS conftest.c -o conftest -g0 >/dev/null 2>&1; then
+  AC_MSG_RESULT([yes])
+else
+    # Try -std=gnu99
+    if "$CMM_CPP_CMD" -std=gnu99 $CMM_CPP_ARGS conftest.c -o conftest -g0 >/dev/null 2>&1; then
+      $3="-std=gnu99 $$3"
+      AC_MSG_RESULT([needs -std=gnu99])
+    else
+      AC_MSG_ERROR([C99-compatible compiler needed])
+    fi
+fi
+rm -f conftest.c conftest.o conftest
 
 
 $2="$CMM_CPP_CMD"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a93d2db3f31d8fa0ae3b8bb028cc3538990dc1c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a93d2db3f31d8fa0ae3b8bb028cc3538990dc1c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240515/0ea4f9e4/attachment-0001.html>


More information about the ghc-commits mailing list