[dpdk-dev,v3,8/8] mk: always rebuild in the same order

Message ID 20170623184153.24488-9-lboccass@brocade.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Luca Boccassi June 23, 2017, 6:41 p.m. UTC
  From: Luca Boccassi <luca.boccassi@gmail.com>

In order to achieve reproducible builds, always check dependencies in
the same order.

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
---
 mk/internal/rte.compile-pre.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Thomas Monjalon June 26, 2017, 11:22 p.m. UTC | #1
23/06/2017 20:41, lboccass@brocade.com:
> From: Luca Boccassi <luca.boccassi@gmail.com>
> 
> In order to achieve reproducible builds, always check dependencies in
> the same order.
> 
> Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
> ---
>  mk/internal/rte.compile-pre.mk | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

It seems something is missing in this patch,
because it is always rebuilding all on the second build.
  
Luca Boccassi June 27, 2017, 10:36 a.m. UTC | #2
On Tue, 2017-06-27 at 01:22 +0200, Thomas Monjalon wrote:
> 23/06/2017 20:41, lboccass@brocade.com:

> > From: Luca Boccassi <luca.boccassi@gmail.com>

> > 

> > In order to achieve reproducible builds, always check dependencies

> > in

> > the same order.

> > 

> > Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>

> > ---

> >  mk/internal/rte.compile-pre.mk | 8 ++++----

> >  1 file changed, 4 insertions(+), 4 deletions(-)

> 

> It seems something is missing in this patch,

> because it is always rebuilding all on the second build.


Indeed, thanks for spotting my mistake!

Sorting before comparing was changing the compared strings, so that was
not working. Duh!
Moving the sort as the "outer" call solves the problem, now rebuilds
correctly skip already built objects.

-- 
Kind regards,
Luca Boccassi
  

Patch

diff --git a/mk/internal/rte.compile-pre.mk b/mk/internal/rte.compile-pre.mk
index da8dda498..5d519100c 100644
--- a/mk/internal/rte.compile-pre.mk
+++ b/mk/internal/rte.compile-pre.mk
@@ -108,13 +108,13 @@  C_TO_O_DO = @set -e; \
 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))
 
 # return a non-empty string if the dst file does not exist
-file_missing = $(call compare,$(wildcard $@),$@)
+file_missing = $(call compare,$(sort $(wildcard $@)),$@)
 
 # return a non-empty string if cmdline changed
 cmdline_changed = $(call compare,$(strip $(cmd_$@)),$(strip $(1)))
 
 # return a non-empty string if a dependency file does not exist
-depfile_missing = $(call compare,$(wildcard $(dep_$@)),$(dep_$@))
+depfile_missing = $(call compare,$(sort $(wildcard $(dep_$@))),$(dep_$@))
 
 # return an empty string if no prereq is newer than target
 #     - $^ -> names of all the prerequisites
@@ -123,7 +123,7 @@  depfile_missing = $(call compare,$(wildcard $(dep_$@)),$(dep_$@))
 #       exist (filter-out removes existing ones from the list)
 #     - $? -> names of all the prerequisites newer than target
 depfile_newer = $(strip $(filter-out FORCE,$? \
-	$(filter-out $(wildcard $^),$^)))
+	$(filter-out $(sort $(wildcard $^)),$^)))
 
 # return 1 if parameter is a non-empty string, else 0
 boolean = $(if $1,1,0)
@@ -134,7 +134,7 @@  boolean = $(if $1,1,0)
 # user (by default it is empty)
 #
 .SECONDEXPANSION:
-%.o: %.c $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE
+%.o: %.c $$(sort $$(wildcard $$(dep_$$@))) $$(DEP_$$(@)) FORCE
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
 	$(if $(D),\
 		@echo -n "$< -> $@ " ; \