[dpdk-dev,v3,8/8] mk: always rebuild in the same order
Checks
Commit Message
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
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.
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
@@ -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 "$< -> $@ " ; \