Re: [PATCH 1/4] manywarnings: omit -fno-common in GCC 10+

2023-04-23 Thread Sam James

Paul Eggert  writes:

> * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Omit -fno-common
> in GCC 10 and later, as it is the default there.

I think this is fine, but I'd note that (to my surprise),
nixpkgs inverted this default for a while.

But I don't think that changes what you should do here.


signature.asc
Description: PGP signature


[PATCH 1/4] manywarnings: omit -fno-common in GCC 10+

2023-04-23 Thread Paul Eggert
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Omit -fno-common
in GCC 10 and later, as it is the default there.
Check exit status of ‘gcc --version’.
---
 ChangeLog  |  7 +++
 m4/manywarnings.m4 | 11 ---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 874cf704f7..9ae7506f45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-04-23  Paul Eggert  
+
+   manywarnings: omit -fno-common in GCC 10+
+   * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Omit -fno-common
+   in GCC 10 and later, as it is the default there.
+   Check exit status of ‘gcc --version’.
+
 2023-04-23  Bruno Haible  
 
libunistring: Fix build on Windows, when a libunistring is installed.
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 2fac86e20b..f88dcc5f12 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -109,7 +109,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
   #  <(LC_ALL=C gcc --help=warnings | sed -n 's/^  \(-[^ ]*\) .*/\1/p' | sort)
 
   $1=
-  for gl_manywarn_item in -fanalyzer -fno-common \
+  for gl_manywarn_item in -fanalyzer \
 -Wall \
 -Warith-conversion \
 -Wbad-function-cast \
@@ -178,14 +178,19 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
   gl_AS_VAR_APPEND([$1], [' -Wvla-larger-than=4031'])
 
   # These are needed for older GCC versions.
-  if test -n "$GCC"; then
-case `($CC --version) 2>/dev/null` in
+  if test -n "$GCC" && gl_gcc_version=`($CC --version) 2>/dev/null`; then
+case $gl_gcc_version in
   'gcc (GCC) '[[0-3]].* | \
   'gcc (GCC) '4.[[0-7]].*)
 gl_AS_VAR_APPEND([$1], [' -fdiagnostics-show-option'])
 gl_AS_VAR_APPEND([$1], [' -funit-at-a-time'])
   ;;
 esac
+case $gl_gcc_version in
+  'gcc (GCC) '[[0-9]].*)
+gl_AS_VAR_APPEND([$1], [' -fno-common'])
+  ;;
+esac
   fi
 
   # Disable specific options as needed.
-- 
2.40.0