[m-rev.] diff: strengthen GCC version deteciotn in the configure script
Julien Fischer
jfischer at opturion.com
Fri Jan 17 01:48:07 AEDT 2020
Branches: 20.01, master
My recent fix to Mantis bug #492 doesn't work on Fedora 31, due to
its GCC being configured only return the major version when invoked
with -dumpversion.
------------------------------
Strengthen GCC version detection in the configure script.
Use "gcc -dumpfullversion" to determine the GCC version where available.
Unlike -dumpversion, its output is guaranteed to be in the form
major.minor.patch.
Include the GCC version in the configure progress message.
m4/mercury.m4:
As above.
Julien.
diff --git a/m4/mercury.m4 b/m4/mercury.m4
index d3f8b49..8b29907 100644
--- a/m4/mercury.m4
+++ b/m4/mercury.m4
@@ -685,11 +685,22 @@ AC_SUBST([ERL])
AC_DEFUN([MERCURY_GCC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
+
+AC_MSG_CHECKING([what the gcc version is])
+
+# -dumpfullversion has only been supported since GCC 7; if it is available we
+# prefer its output since it is guaranteed to be in the form major.minor.patch.
+#
+raw_gcc_version=`$CC -dumpfullversion 2> /dev/null`
+if test $? -ne 0
+then
+ raw_gcc_version=`$CC -dumpversion`
+fi
# We expect that the major and minor version numbers will always be present.
# MinGW-w64 may add a suffix "-win32" or "-posix" after the second or third
# number that should be ignored.
-mercury_cv_gcc_version=`$CC -dumpversion | tr .- ' ' | {
+mercury_cv_gcc_version=`echo $raw_gcc_version | tr .- ' ' | {
read major minor third ignore
case $third in
[[0-9]]*)
@@ -701,6 +712,8 @@ mercury_cv_gcc_version=`$CC -dumpversion | tr .- ' ' | {
esac
echo ${major:-u}_${minor:-u}_${patchlevel:-u}
}`
+
+AC_MSG_RESULT([$mercury_cv_gcc_version])
])
#-----------------------------------------------------------------------------#
More information about the reviews
mailing list