diff mbox series

libtracefs: avoid pointless extra DEP stage

Message ID 20220620150316.21022-1-jengelh@inai.de (mailing list archive)
State Superseded
Headers show
Series libtracefs: avoid pointless extra DEP stage | expand

Commit Message

Jan Engelhardt June 20, 2022, 3:03 p.m. UTC
Call the compiler only once per source file.
Reduces build time from 0.85 to 0.75 seconds for me.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
 scripts/utils.mk |  4 ++--
 src/Makefile     | 14 ++------------
 2 files changed, 4 insertions(+), 14 deletions(-)

Comments

Steven Rostedt July 8, 2022, 6:22 p.m. UTC | #1
On Mon, 20 Jun 2022 17:03:16 +0200
Jan Engelhardt <jengelh@inai.de> wrote:

>  clean:
> -	$(Q)$(call do_clean,$(OBJS) .*.d)
> +	$(Q)$(call do_clean,$(OBJS) *.d)
>  
> -dep_includes := $(wildcard $(DEPS))
> -
> -ifneq ($(dep_includes),)
> -  include $(dep_includes)
> -endif
> +-include *.d
>  

After this change, the .d files are visible. Is there a way to keep them
hidden? That is, keep the . in front?

-- Steve
Jan Engelhardt July 11, 2022, 7:37 p.m. UTC | #2
On Friday 2022-07-08 20:22, Steven Rostedt wrote:

>On Mon, 20 Jun 2022 17:03:16 +0200
>Jan Engelhardt <jengelh@inai.de> wrote:
>
>>  clean:
>> -	$(Q)$(call do_clean,$(OBJS) .*.d)
>> +	$(Q)$(call do_clean,$(OBJS) *.d)
>>  
>> -dep_includes := $(wildcard $(DEPS))
>> -
>> -ifneq ($(dep_includes),)
>> -  include $(dep_includes)
>> -endif
>> +-include *.d
>>  
>
>After this change, the .d files are visible. Is there a way to keep them
>hidden? That is, keep the . in front?

Generally there is. Let me see how to stick
that into the $(CC) line.
diff mbox series

Patch

diff --git a/scripts/utils.mk b/scripts/utils.mk
index 5f43de1..b8a32a3 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -53,12 +53,12 @@  endif
 
 do_fpic_compile =					\
 	($(print_fpic_compile)				\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) -fPIC $< -o $@)
+	$(CC) -MMD -MP -c $(CPPFLAGS) $(CFLAGS) $(EXT) -fPIC $< -o $@)
 
 do_compile =							\
 	($(if $(GENERATE_PIC), $(do_fpic_compile),		\
 	 $(print_compile)					\
-	 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) $< -o $@))
+	 $(CC) -MMD -MP -c $(CPPFLAGS) $(CFLAGS) $(EXT) $< -o $@))
 
 do_app_build =						\
 	($(print_app_build)				\
diff --git a/src/Makefile b/src/Makefile
index 645d518..3cd4263 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -48,24 +48,14 @@  sqlhist-lex.c: sqlhist.l sqlhist.tab.c
 $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
-$(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
-
-$(OBJS): $(bdir)/%.o : $(bdir)/.%.d
-
 tracefs-sqlhist.o: sqlhist.tab.h
 
 $(OBJS): | $(bdir)
-$(DEPS): | $(bdir)
 
 clean:
-	$(Q)$(call do_clean,$(OBJS) .*.d)
+	$(Q)$(call do_clean,$(OBJS) *.d)
 
-dep_includes := $(wildcard $(DEPS))
-
-ifneq ($(dep_includes),)
-  include $(dep_includes)
-endif
+-include *.d
 
 $(bdir)/tracefs-sqlhist.o tracefs-sqlhist.o: sqlhist.tab.h