Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH] Add silent Makefile rules
Date: Fri, 02 Mar 2018 20:21:00 -0000	[thread overview]
Message-ID: <1520022036-28308-1-git-send-email-simon.marchi@ericsson.com> (raw)

From: Simon Marchi <simon.marchi@polymtl.ca>

Many projects (e.g. the Linux kernel) and build systems use "silent"
rules, which means that they'll only print a summary of what's being
done instead of printing all the detailed command lines.  While chatting
on the #gdb IRC channel, I realized a few people (including me) thought
it would be nice to have it in GDB too.

The idea is that too much text is not useful, the important information
gets lost.  If there's only the essential information, it's more likely
to be useful.  Most of the time, when I look at the build output, it's
to see how it's progressing.  By just printing a brief summary of each
operation, I can easily spot what's currently being compiled and
therefore how the build progresses (with time you know the order in
which files are compiled almost by heart).

As with other projects (Linux, automake-based things, probably others),
it's possible to print the complete command lines by passing V=1 to make
(or any other non-zero value).

I had one hesitation about this: when people report build failures, we
are more likely to miss the full compile command line.  We'll probably
sometimes need to ask people to include the build log with "make V=1".
I don't think it's a big downside, if other projects the size of the
Linux kernel can live with it, I'm sure we can too.

gdb/ChangeLog:

	* silent-rules.mk: New.
	* Makefile.in: Include silent-rules.mk
	(srcdir, VPATH, top_srcdir): Move up.
	(COMPILE): Add ECHO_CC.
	(test-cp-name-parser$(EXEEXT)): Add ECHO_LD.
	(init.c): Add ECHO_INIT_C.
	(gdb$(EXEEXT)): Add SILENCE and ECHO_LD.
	(version.c): Add ECHO_GEN.
	(printcmd.o): Add ECHO_CC.
	(target-float.o): Add ECHO_CC.
	(ada-exp.o): Add ECHO_CC.
	(stamp-xml): Add SILENCE and ECHO_GEN_XML_BUILTIN.
	(insight$(EXEEXT)): Add ECHO_LD.

gdb/testsuite/ChangeLog:

	* Makefile.in: Include silent-rules.mk.
	(srcdir, abs_top_srcdir, abs_srcdir, VPATH): Move up.
	(COMPILE): Add ECHO_CC.
	(gdbserver$(EXEEXT)): Add SILENCE and ECHO_LD.
	(gdbreplay$(EXEEXT)): Add SILENCE and ECHO_LD.
	($(IPA_LIB)): Add SILENCE and ECHO_LD.
	(version-generated.c): Add ECHO_GEN.
	(stamp-xml): Add SILENCE and ECHO_GEN_XML_BUILTIN_GENERATED.
	(IPAGENT_COMPILE): Add ECHO_CC.
	(%-generated.c): Add ECHO_REGDAT.
---
 gdb/Makefile.in           | 48 ++++++++++++++++++++-----------------
 gdb/gdbserver/Makefile.in | 60 ++++++++++++++++++++++++++---------------------
 gdb/silent-rules.mk       | 14 +++++++++++
 3 files changed, 73 insertions(+), 49 deletions(-)
 create mode 100644 gdb/silent-rules.mk

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 19be64f..c7cf1db 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -112,18 +112,20 @@ DEPMODE = @CCDEPMODE@
 DEPDIR = @DEPDIR@
 depcomp = $(SHELL) $(srcdir)/../depcomp
 
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+top_srcdir = @top_srcdir@
+
+include $(srcdir)/silent-rules.mk
+
 # Note that these are overridden by GNU make-specific code below if
 # GNU make is used.  The overrides implement dependency tracking.
 COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT)
 COMPILE.post = -c -o $@
-COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
+COMPILE = $(ECHO_CC) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
 POSTCOMPILE = @true
 
-# Directory containing source files.
-srcdir = @srcdir@
-VPATH = @srcdir@
-top_srcdir = @top_srcdir@
-
 YACC = @YACC@
 
 # This is used to rebuild ada-lex.c from ada-lex.l.  If the program is
@@ -1794,7 +1796,7 @@ test-cp-name-parser.o: cp-name-parser.c
 	$(POSTCOMPILE)
 
 test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
-	$(CC_LD) $(INTERNAL_LDFLAGS) -o test-cp-name-parser$(EXEEXT) \
+	$(ECHO_LD) $(CC_LD) $(INTERNAL_LDFLAGS) -o test-cp-name-parser$(EXEEXT) \
 		test-cp-name-parser.o $(LIBIBERTY)
 
 # We do this by grepping through sources.  If that turns out to be too slow,
@@ -1836,7 +1838,7 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
 
 INIT_FILES = $(COMMON_OBS) $(TSOBS) $(CONFIG_SRCS) $(SUBDIR_GCC_COMPILE_SRCS)
 init.c: $(INIT_FILES)
-	@echo Making init.c
+	@$(ECHO_INIT_C) echo "Making init.c"
 	@rm -f init.c-tmp init.l-tmp
 	@touch init.c-tmp
 	@echo gdbtypes > init.l-tmp
@@ -1896,8 +1898,8 @@ libgdb.a: $(LIBGDB_OBS)
 
 # Removing the old gdb first works better if it is running, at least on SunOS.
 gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
-	rm -f gdb$(EXEEXT)
-	$(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
+	$(SILENCE) rm -f gdb$(EXEEXT)
+	$(ECHO_LD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
 		-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
 
@@ -2128,7 +2130,7 @@ $(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 $(srcdir)/copy
 	mv $(srcdir)/copying.tmp $(srcdir)/copying.c
 
 version.c: Makefile version.in $(srcdir)/../bfd/version.h $(srcdir)/common/create-version.sh
-	$(SHELL) $(srcdir)/common/create-version.sh $(srcdir) \
+	$(ECHO_GEN) $(SHELL) $(srcdir)/common/create-version.sh $(srcdir) \
 	    $(host_alias) $(target_alias) version.c
 
 observer.h: observer.sh doc/observer.texi
@@ -2373,14 +2375,16 @@ ALLDEPFILES = \
 # Do not try to build "printcmd.c" with -Wformat-nonliteral.  It manually
 # checks format strings.
 printcmd.o: $(srcdir)/printcmd.c
-	$(COMPILE.pre) $(INTERNAL_CFLAGS) $(GDB_WARN_CFLAGS_NO_FORMAT) \
-		$(COMPILE.post) $(srcdir)/printcmd.c
+	$(ECHO_CC) $(COMPILE.pre) $(INTERNAL_CFLAGS) \
+		$(GDB_WARN_CFLAGS_NO_FORMAT) $(COMPILE.post) \
+		$(srcdir)/printcmd.c
 	$(POSTCOMPILE)
 
 # Same for "target-float.c".
 target-float.o: $(srcdir)/target-float.c
-	$(COMPILE.pre) $(INTERNAL_CFLAGS) $(GDB_WARN_CFLAGS_NO_FORMAT) \
-		$(COMPILE.post) $(srcdir)/target-float.c
+	$(ECHO_CC) $(COMPILE.pre) $(INTERNAL_CFLAGS) \
+		$(GDB_WARN_CFLAGS_NO_FORMAT) $(COMPILE.post) \
+		$(srcdir)/target-float.c
 
 # ada-exp.c can appear in srcdir, for releases; or in ., for
 # development builds.
@@ -2389,8 +2393,8 @@ ADA_EXP_C = `if test -f ada-exp.c; then echo ada-exp.c; else echo $(srcdir)/ada-
 # Some versions of flex give output that triggers
 # -Wold-style-definition.
 ada-exp.o: ada-exp.c
-	$(COMPILE.pre) $(INTERNAL_CFLAGS) $(GDB_WARN_CFLAGS_NO_DEFS) \
-		$(COMPILE.post) $(ADA_EXP_C)
+	$(ECHO_CC) $(COMPILE.pre) $(INTERNAL_CFLAGS) \
+		$(GDB_WARN_CFLAGS_NO_DEFS) $(COMPILE.post) $(ADA_EXP_C)
 	$(POSTCOMPILE)
 
 # Message files.  Based on code in gcc/Makefile.in.
@@ -2521,12 +2525,12 @@ po/$(PACKAGE).pot: force
 
 xml-builtin.c: stamp-xml; @true
 stamp-xml: $(srcdir)/features/feature_to_c.sh Makefile $(XMLFILES)
-	rm -f xml-builtin.tmp
-	AWK="$(AWK)" \
+	$(SILENCE) rm -f xml-builtin.tmp
+	$(ECHO_GEN_XML_BUILTIN) AWK="$(AWK)" \
 	  $(SHELL) $(srcdir)/features/feature_to_c.sh \
 	  xml-builtin.tmp $(XMLFILES)
-	$(SHELL) $(srcdir)/../move-if-change xml-builtin.tmp xml-builtin.c
-	echo stamp > stamp-xml
+	$(SILENCE) $(SHELL) $(srcdir)/../move-if-change xml-builtin.tmp xml-builtin.c
+	$(SILENCE) echo stamp > stamp-xml
 
 .PRECIOUS: xml-builtin.c
 
@@ -2584,7 +2588,7 @@ clean-gdbtk:
 insight$(EXEEXT): gdbtk-main.o libgdb.a $(ADD_DEPS) \
 		$(CDEPS) $(TDEPLIBS)
 	rm -f insight$(EXEEXT)
-	$(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
+	$(ECHO_LD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
 		-o insight$(EXEEXT) gdbtk-main.o libgdb.a \
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
 
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index f293692..0cb6b9b 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -64,13 +64,6 @@ DEPMODE = @CCDEPMODE@
 DEPDIR = @DEPDIR@
 depcomp = $(SHELL) $(srcdir)/../depcomp
 
-# Note that these are overridden by GNU make-specific code below if
-# GNU make is used.  The overrides implement dependency tracking.
-COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT)
-COMPILE.post = -c -o $@
-COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
-POSTCOMPILE = @true
-
 # Directory containing source files.  Don't clean up the spacing,
 # this exact string is matched for by the "configure" script.
 srcdir = @srcdir@
@@ -78,6 +71,15 @@ abs_top_srcdir = @abs_top_srcdir@
 abs_srcdir = @abs_srcdir@
 VPATH = @srcdir@
 
+include $(srcdir)/../silent-rules.mk
+
+# Note that these are overridden by GNU make-specific code below if
+# GNU make is used.  The overrides implement dependency tracking.
+COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT)
+COMPILE.post = -c -o $@
+COMPILE = $(ECHO_CC) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
+POSTCOMPILE = @true
+
 # It is also possible that you will need to add -I/usr/include/sys to the
 # CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
 # is where it should be according to Posix).
@@ -378,9 +380,10 @@ clean-info: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
-	rm -f gdbserver$(EXEEXT)
-	$(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
-	$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
+	$(SILENCE) rm -f gdbserver$(EXEEXT)
+	$(ECHO_LD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
+		-o gdbserver$(EXEEXT) $(OBS) $(LIBGNU) $(LIBIBERTY) \
+		$(GDBSERVER_LIBS) $(XM_CLIBS)
 
 $(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
 all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
@@ -388,9 +391,10 @@ all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
 .PHONY: all-lib
 
 gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
-	rm -f gdbreplay$(EXEEXT)
-	$(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
-	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
+	$(SILENCE) rm -f gdbreplay$(EXEEXT)
+	$(ECHO_LD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
+		-o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) $(XM_CLIBS) $(LIBGNU) \
+		$(LIBIBERTY)
 
 IPA_OBJS = \
 	ax-ipa.o \
@@ -410,9 +414,10 @@ IPA_OBJS = \
 IPA_LIB = libinproctrace.so
 
 $(IPA_LIB): $(IPA_OBJS) ${ADD_DEPS} ${CDEPS}
-	rm -f $(IPA_LIB)
-	$(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) -Wl,--no-undefined $(INTERNAL_CFLAGS) \
-	$(INTERNAL_LDFLAGS) -o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread
+	$(SILENCE) rm -f $(IPA_LIB)
+	$(ECHO_LD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \
+		-Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
+		-o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread
 
 # Put the proper machine-specific files first, so M-. on a machine
 # specific routine gets the one for the correct machine.
@@ -494,15 +499,16 @@ am--refresh:
 force:
 
 version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
-	$(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
-	    $(host_alias) $(target_alias) $@
+	$(ECHO_GEN) $(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
+		$(host_alias) $(target_alias) $@
 
 xml-builtin-generated.c: stamp-xml; @true
 stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
-	rm -f xml-builtin.tmp
-	$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
-	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
-	echo stamp > stamp-xml
+	$(SILENCE) rm -f xml-builtin.tmp
+	$(ECHO_GEN_XML_BUILTIN_GENERATED) $(SHELL) $(XML_DIR)/feature_to_c.sh \
+		xml-builtin.tmp $(XML_FILES)
+	$(SILENCE) $(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
+	$(SILENCE) echo stamp > stamp-xml
 
 .PRECIOUS: xml-builtin.c
 
@@ -527,7 +533,7 @@ IPAGENT_CFLAGS = $(INTERNAL_CFLAGS) $(UST_CFLAGS) \
 	-fPIC -DIN_PROCESS_AGENT \
 	-fvisibility=hidden
 
-IPAGENT_COMPILE = $(COMPILE.pre) $(IPAGENT_CFLAGS) $(COMPILE.post)
+IPAGENT_COMPILE = $(ECHO_CC) $(COMPILE.pre) $(IPAGENT_CFLAGS) $(COMPILE.post)
 
 # Rules for special cases.
 
@@ -598,16 +604,16 @@ common/%.o: ../common/%.c
 # -generated to identify and clean them easily.
 
 %-generated.c: ../regformats/%.dat | $(regdat_sh)
-	$(SHELL) $(regdat_sh) $< $@
+	$(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
 
 %-generated.c: ../regformats/arm/%.dat | $(regdat_sh)
-	$(SHELL) $(regdat_sh) $< $@
+	$(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
 
 %-generated.c: ../regformats/i386/%.dat | $(regdat_sh)
-	$(SHELL) $(regdat_sh) $< $@
+	$(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
 
 %-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
-	$(SHELL) $(regdat_sh) $< $@
+	$(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
 
 #
 # Dependency tracking.
diff --git a/gdb/silent-rules.mk b/gdb/silent-rules.mk
new file mode 100644
index 0000000..d2715ad
--- /dev/null
+++ b/gdb/silent-rules.mk
@@ -0,0 +1,14 @@
+# If V is undefined or V=0 is specified, use the silent/verbose/compact mode.
+V ?= 0
+ifeq ($(V),0)
+ECHO_CC =     @echo "  CC      $@";
+ECHO_LD =     @echo "  LD      $@";
+ECHO_REGDAT = @echo "  REGDAT  $@";
+ECHO_GEN =    @echo "  GEN     $@";
+ECHO_GEN_XML_BUILTIN = \
+              @echo "  GEN     xml-builtin.c";
+ECHO_GEN_XML_BUILTIN_GENERATED = \
+              @echo "  GEN     xml-builtin-generated.c";
+ECHO_INIT_C =  echo "  GEN     init.c" ||
+SILENCE = @
+endif
-- 
2.7.4


             reply	other threads:[~2018-03-02 20:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02 20:21 Simon Marchi [this message]
2018-03-02 20:25 ` Simon Marchi
2018-03-03  8:09   ` Eli Zaretskii
2018-03-03 18:06     ` Simon Marchi
2018-03-03  7:54 ` Eli Zaretskii
2018-03-03 14:39   ` Simon Marchi
2018-03-03 18:27 ` [PATCH v2] " Simon Marchi
2018-03-16 20:32   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1520022036-28308-1-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox