From 18137c0fec3cea30871f29238e11ea0f4e8523da Mon Sep 17 00:00:00 2001 From: Matias N Date: Sat, 12 Sep 2020 00:36:23 -0300 Subject: [PATCH] Fix: ensure archive files do not carry object files from prior builds This is the corresponding change to the one on main NuttX repo. In this case this involves splitting the build of libapps.a into: a) building all applications (which is safely parallelizable), b) adding each application's object files to the archive in turns (serial by nature). This removes the need for the flock used to protect the parallel build. --- .gitignore | 2 -- Application.mk | 10 ++++------ Directory.mk | 1 - Make.defs | 4 ---- Makefile | 19 +++++++++++++++---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 910e0595e..acf570e12 100644 --- a/.gitignore +++ b/.gitignore @@ -15,10 +15,8 @@ *.swp *.sym *~ -.built .depend .kconfig -/*.lock /bin /boot_romfsimg.h /external diff --git a/Application.mk b/Application.mk index 153628a33..fd9a02cc3 100644 --- a/Application.mk +++ b/Application.mk @@ -95,7 +95,7 @@ VPATH += :. # Targets follow -all:: .built +all:: $(OBJS) .PHONY: clean depend distclean .PRECIOUS: $(BIN) @@ -131,13 +131,12 @@ $(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT) $(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \ $(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@)) -.built: $(OBJS) +archive: ifeq ($(CONFIG_CYGWIN_WINTOOL),y) - $(call ARLOCK, "${shell cygpath -w $(BIN)}", $^) + $(call ARCHIVE_ADD, "${shell cygpath -w $(BIN)}", $(OBJS)) else - $(call ARLOCK, $(BIN), $^) + $(call ARCHIVE_ADD, $(BIN), $(OBJS)) endif - $(Q) touch $@ ifeq ($(BUILD_MODULE),y) @@ -234,7 +233,6 @@ endif depend:: .depend clean:: - $(call DELFILE, .built) $(call CLEAN) distclean:: clean diff --git a/Directory.mk b/Directory.mk index 6ce0149ec..c70a42840 100644 --- a/Directory.mk +++ b/Directory.mk @@ -39,7 +39,6 @@ include $(APPDIR)/Make.defs SUBDIRS := $(dir $(wildcard *$(DELIM)Makefile)) CONFIGSUBDIRS := $(filter-out $(dir $(wildcard *$(DELIM)Kconfig)),$(SUBDIRS)) -CLEANSUBDIRS := $(dir $(wildcard *$(DELIM).built)) CLEANSUBDIRS += $(dir $(wildcard *$(DELIM).depend)) CLEANSUBDIRS += $(dir $(wildcard *$(DELIM).kconfig)) CLEANSUBDIRS := $(sort $(CLEANSUBDIRS)) diff --git a/Make.defs b/Make.defs index f3f99ed40..fd4662c5c 100644 --- a/Make.defs +++ b/Make.defs @@ -108,10 +108,6 @@ define REGISTER $(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated" endef -define ARLOCK - $(Q) flock $1.lock $(call ARCHIVE, $1, $(2)) -endef - # Standard include path CFLAGS += ${shell $(INCDIR) "$(CC)" "$(APPDIR)$(DELIM)include"} diff --git a/Makefile b/Makefile index 394c9a8e8..acc4afbeb 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,13 @@ SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) # Build targets -all: $(BIN) +# We first remove libapps.a before letting the other rules add objects to it +# so that we ensure libapps.a does not contain objects from prior build + +all: + $(RM) $(BIN) + $(MAKE) $(BIN) + .PHONY: import install dirlinks context context_serialize clean_context context_rest export .depdirs preconfig depend clean distclean .PRECIOUS: $(BIN) @@ -87,10 +93,16 @@ else ifeq ($(CONFIG_BUILD_LOADABLE),) $(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) + $(Q) for app in ${CONFIGURED_APPS}; do \ + $(MAKE) -C "$${app}" archive TOPDIR="${TOPDIR}" APPDIR="${APPDIR}" ; \ + done else $(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) + $(Q) for app in ${CONFIGURED_APPS}; do \ + $(MAKE) -C "$${app}" archive TOPDIR="${TOPDIR}" APPDIR="${APPDIR}" ; \ + done $(Q) $(MAKE) install TOPDIR="$(TOPDIR)" $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) >$@.tmp $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) @@ -100,9 +112,9 @@ $(SYMTABOBJ): %$(OBJEXT): %.c $(BIN): $(SYMTABOBJ) ifeq ($(CONFIG_CYGWIN_WINTOOL),y) - $(call ARLOCK, "${shell cygpath -w $(BIN)}", $^) + $(call ARCHIVE_ADD, "${shell cygpath -w $(BIN)}", $^) else - $(call ARLOCK, $(BIN), $^) + $(call ARCHIVE_ADD, $(BIN), $^) endif endif # !CONFIG_BUILD_LOADABLE @@ -198,7 +210,6 @@ else fi; \ ) endif - $(call DELFILE, *.lock) $(call DELFILE, .depend) $(call DELFILE, $(SYMTABSRC)) $(call DELFILE, $(SYMTABOBJ))