public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gprofng: Don't hardcode -Wno-format-truncation/-Wno-switch
@ 2022-03-16 13:44 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2022-03-16 13:44 UTC (permalink / raw)
  To: bfd-cvs, gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=61a1f2e71118206dd700fc1ddf244b2178bf6610

commit 61a1f2e71118206dd700fc1ddf244b2178bf6610
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Mar 15 08:56:39 2022 -0700

    gprofng: Don't hardcode -Wno-format-truncation/-Wno-switch
    
    Use -Wno-format-truncation and -Wno-switch only if they are supported.
    
            PR gprof/28969
            * configure.ac (GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS): New
            AC_SUBST for -Wno-format-truncation.
            (GPROFNG_NO_SWITCH_CFLAGS): New AC_SUBST for -Wno-switch.
            * Makefile.in: Regenerate.
            * configure: Likewise.
            * src/Makefile.am (AM_CFLAGS): Replace -Wno-format-truncation
            and -Wno-switch with GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS and
            GPROFNG_NO_SWITCH_CFLAGS.
            * src/Makefile.in: Regenerate.

Diff:
---
 gprofng/Makefile.in     |   2 +
 gprofng/configure       | 122 +++++++++++++++++++++++++++++++++++++++++++++++-
 gprofng/configure.ac    |   4 ++
 gprofng/src/Makefile.am |   5 +-
 gprofng/src/Makefile.in |   7 ++-
 5 files changed, 134 insertions(+), 6 deletions(-)

diff --git a/gprofng/Makefile.in b/gprofng/Makefile.in
index 08ffdd2b65a..62005dc2b46 100644
--- a/gprofng/Makefile.in
+++ b/gprofng/Makefile.in
@@ -265,6 +265,8 @@ GPROFNG_CFLAGS = @GPROFNG_CFLAGS@
 GPROFNG_CPPFLAGS = @GPROFNG_CPPFLAGS@
 GPROFNG_LIBADD = @GPROFNG_LIBADD@
 GPROFNG_LIBDIR = @GPROFNG_LIBDIR@
+GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS = @GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS@
+GPROFNG_NO_SWITCH_CFLAGS = @GPROFNG_NO_SWITCH_CFLAGS@
 GREP = @GREP@
 HELP2MAN = @HELP2MAN@
 INSTALL = @INSTALL@
diff --git a/gprofng/configure b/gprofng/configure
index 9a4a334854b..1371caa45d6 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -658,6 +658,8 @@ BUILD_SRC_FALSE
 BUILD_SRC_TRUE
 BUILD_COLLECTOR_FALSE
 BUILD_COLLECTOR_TRUE
+GPROFNG_NO_SWITCH_CFLAGS
+GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS
 gprofng_cflags
 WERROR
 GPROFNG_LIBADD
@@ -12089,7 +12091,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12092 "configure"
+#line 12094 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12195,7 +12197,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12198 "configure"
+#line 12200 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15530,6 +15532,120 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS=
+save_CFLAGS="$CFLAGS"
+for real_option in -Wno-format-truncation; do
+  # Do the check with the no- prefix removed since gcc silently
+  # accepts any -Wno-* option on purpose
+  case $real_option in
+    -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
+    *) option=$real_option ;;
+  esac
+  as_acx_Woption=`$as_echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh`
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports $option" >&5
+$as_echo_n "checking whether $CC supports $option... " >&6; }
+if eval \${$as_acx_Woption+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  CFLAGS="$option"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_acx_Woption=yes"
+else
+  eval "$as_acx_Woption=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+eval ac_res=\$$as_acx_Woption
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  if test `eval 'as_val=${'$as_acx_Woption'};$as_echo "$as_val"'` = yes; then :
+  GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS="$GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS${GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS:+ }$real_option"
+fi
+  done
+CFLAGS="$save_CFLAGS"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+GPROFNG_NO_SWITCH_CFLAGS=
+save_CFLAGS="$CFLAGS"
+for real_option in -Wno-switch; do
+  # Do the check with the no- prefix removed since gcc silently
+  # accepts any -Wno-* option on purpose
+  case $real_option in
+    -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
+    *) option=$real_option ;;
+  esac
+  as_acx_Woption=`$as_echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh`
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports $option" >&5
+$as_echo_n "checking whether $CC supports $option... " >&6; }
+if eval \${$as_acx_Woption+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  CFLAGS="$option"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_acx_Woption=yes"
+else
+  eval "$as_acx_Woption=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+eval ac_res=\$$as_acx_Woption
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  if test `eval 'as_val=${'$as_acx_Woption'};$as_echo "$as_val"'` = yes; then :
+  GPROFNG_NO_SWITCH_CFLAGS="$GPROFNG_NO_SWITCH_CFLAGS${GPROFNG_NO_SWITCH_CFLAGS:+ }$real_option"
+fi
+  done
+CFLAGS="$save_CFLAGS"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
 gprofng_cppflags="-U_ASM"
 build_collector=
 build_src=
@@ -16507,6 +16623,8 @@ LD_NO_AS_NEEDED=${no_as_needed}
 
 GPROFNG_CFLAGS=${gprofng_cflags}
 
+
+
 GPROFNG_CPPFLAGS=${gprofng_cppflags}
 
 GPROFNG_LIBDIR=${libdir}
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index fa924dcee62..23fee8705ac 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -42,6 +42,8 @@ AC_SUBST(GPROFNG_LIBADD)
 
 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
 ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
+ACX_PROG_CC_WARNING_OPTS([-Wno-format-truncation], [GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS])
+ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
 gprofng_cppflags="-U_ASM"
 build_collector=
 build_src=
@@ -174,6 +176,8 @@ AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
 
 AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
 AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
+AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
+AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
 AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
 
diff --git a/gprofng/src/Makefile.am b/gprofng/src/Makefile.am
index b874b5b32aa..84fd1df9a44 100644
--- a/gprofng/src/Makefile.am
+++ b/gprofng/src/Makefile.am
@@ -102,8 +102,9 @@ AM_CPPFLAGS = $(GPROFNG_CPPFLAGS) -DLOCALEDIR=\"@localedir@\" -I.. -I$(srcdir) \
 	-I$(srcdir)/../common \
 	-I$(srcdir)/../../include -I$(srcdir)/../../opcodes \
 	-I../../bfd -I$(srcdir)/../../bfd
-AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) -Wno-switch \
-	-Wno-format-truncation
+AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
+	$(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS) \
+	$(GPROFNG_NO_SWITCH_CFLAGS)
 AM_CXXFLAGS = $(AM_CFLAGS)
 
 man_MANS = gprofng.1 \
diff --git a/gprofng/src/Makefile.in b/gprofng/src/Makefile.in
index f21671d9e67..6b3c82b0bc2 100644
--- a/gprofng/src/Makefile.in
+++ b/gprofng/src/Makefile.in
@@ -330,6 +330,8 @@ GPROFNG_CFLAGS = @GPROFNG_CFLAGS@
 GPROFNG_CPPFLAGS = @GPROFNG_CPPFLAGS@
 GPROFNG_LIBADD = @GPROFNG_LIBADD@
 GPROFNG_LIBDIR = @GPROFNG_LIBDIR@
+GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS = @GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS@
+GPROFNG_NO_SWITCH_CFLAGS = @GPROFNG_NO_SWITCH_CFLAGS@
 GREP = @GREP@
 HELP2MAN = @HELP2MAN@
 INSTALL = @INSTALL@
@@ -517,8 +519,9 @@ AM_CPPFLAGS = $(GPROFNG_CPPFLAGS) -DLOCALEDIR=\"@localedir@\" -I.. -I$(srcdir) \
 	-I$(srcdir)/../../include -I$(srcdir)/../../opcodes \
 	-I../../bfd -I$(srcdir)/../../bfd
 
-AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) -Wno-switch \
-	-Wno-format-truncation
+AM_CFLAGS = $(GPROFNG_CFLAGS) $(PTHREAD_CFLAGS) \
+	$(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS) \
+	$(GPROFNG_NO_SWITCH_CFLAGS)
 
 AM_CXXFLAGS = $(AM_CFLAGS)
 man_MANS = gprofng.1 \


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-16 13:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 13:44 [binutils-gdb] gprofng: Don't hardcode -Wno-format-truncation/-Wno-switch H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).