[2/2] Sort objects in gdb and gdbserver Makefiles

Message ID 87lg81nr1p.fsf@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 16, 2018, 8:08 p.m. UTC
  >>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:

Simon> Tom mentioned this a while ago, as a way to give you a cheap sense of
Simon> progression in your build, as all object files will be built
Simon> alphabetically (including the directory part).

Try this for fun.

Tom
  

Comments

Simon Marchi Sept. 17, 2018, 12:40 a.m. UTC | #1
On 2018-09-16 16:08, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
> 
> Simon> Tom mentioned this a while ago, as a way to give you a cheap 
> sense of
> Simon> progression in your build, as all object files will be built
> Simon> alphabetically (including the directory part).
> 
> Try this for fun.

Ah, impressive!  Though to be really useful, it would have to tell you 
how many objects are required to be built this particular time.  For 
example, you touch a header file and 100 .o files need to be rebuilt, it 
would show as "[X / 100]".  Then you would know if you have time to get 
coffee or not.

I pushed my two patches.

Thanks,

Simon
  
Tom Tromey Sept. 17, 2018, 3:46 a.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:

Simon> Ah, impressive!  Though to be really useful, it would have to tell you
Simon> how many objects are required to be built this particular time.

Yeah.  I couldn't think of a way to do this though.

Tom
  

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index d49f3eef446..366abba69fe 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1894,11 +1894,27 @@  libgdb.a: $(LIBGDB_OBS)
 	$(AR) q libgdb.a $(LIBGDB_OBS)
 	$(RANLIB) libgdb.a
 
+ALL_GDB_OBS = gdb.o $(LIBGDB_OBS)
+
+# Usage: set-object-index LIST
+# Where LIST is a list WORD1...WORDN
+# Define $(WORDN)-index to an integer and then recurse on the
+# remaining words.
+define set-object-index =
+$(if $(1),
+  $(lastword $(1))-index := $(words $(1))
+  $(call set-object-index,$(wordlist 1,$(words $(wordlist 2,100000,$(1))),$(1))))
+endef
+
+$(eval $(call set-object-index,$(ALL_GDB_OBS)))
+
+override ECHO_CXX = @echo "[$($@-index) / $(words $(ALL_GDB_OBS))]  CXX    $@  ";
+
 # Removing the old gdb first works better if it is running, at least on SunOS.
-gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(CDEPS) $(TDEPLIBS)
+gdb$(EXEEXT): $(ALL_GDB_OBS) $(CDEPS) $(TDEPLIBS)
 	$(SILENCE) rm -f gdb$(EXEEXT)
 	$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
-		-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
+		-o gdb$(EXEEXT) $(ALL_GDB_OBS) \
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
 ifneq ($(CODESIGN_CERT),)
 	$(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT)