diff mbox

pflash: Clean up makefiles and resolve build race

Message ID 1469195260-319-1-git-send-email-joel@jms.id.au
State Accepted
Headers show

Commit Message

Joel Stanley July 22, 2016, 1:47 p.m. UTC
The pflash build process has regressed from when the were last fixed in
6c21c4ffaf82.

This patch resolves that issue and performs some cleanups:

 - Remove duplicated rules. Patches had moved rules into common files,
   but forgotten to remove them from the pflash makefiles.

 - Make assignements simply expanded variables where possible. Form the
   make manual:

     Functions referenced in the definition will be executed every time
     the variable is expanded.  This makes make run slower; worse, it
     causes the wildcard and shell functions to give unpredictable
     results because you cannot easily control when they are called, or
     even how many times.

     To avoid all the problems and inconveniences of recursively
     expanded variables, there is another flavor: simply expanded
     variables.

 - set the 'shared' target as a dependency of the libflash objects. This
   was the final piece to resolve the race condition.

The failed build could be reproduced by doing a `git clean -f -x` and
then running the following:

  $ make -j 32 CROSS_COMPILE=arm-linux-gnueabi- SKIBOOT_VERSION=5.2.4
  PFLASH_VERSION=5.2.4 V=1 -C external/pflash all LINKAGE=dynamic
  make: Entering directory '/home/joel/dev/skiboot/external/pflash'
  ln -sf ../../libflash ./libflash
  ln -sf ../../ccan ./ccan
  ln -sf ../common ./common
  cc -O2 -Wall -I. -c pflash.c -o pflash.o
  cc -O2 -Wall -I. -c progress.c -o progress.o
  make -C ../shared
  make[1]: Entering directory '/home/joel/dev/skiboot/external/shared'
  ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c common/ast-sf-ctrl.c
  ln -sf ../../include/ast.h common/ast.h
  ln -sf arch_flash_arm_io.h common/io.h
  cc -O2 -Wall -I.  -c common/arch_flash_common.c -o
  common-arch_flash_common.o
  cc -O2 -Wall -I.  -c common/arch_flash_arm.c -o common-arch_flash_arm.o
  cc -O2 -Wall -I.  -c common/ast-sf-ctrl.c -o common-ast-sf-ctrl.o
  cc -O2 -Wall -I. -c version.c -o version.o
  ld -r common-arch_flash_common.o common-arch_flash_arm.o
  common-ast-sf-ctrl.o -o common-arch_flash.o
  ln -sf ../../libflash ./libflash
  ln -sf ../../ccan ./ccan
  ln -sf ../common ./common
  make[1]: *** No rule to make target 'libflash/file.c', needed by
  'libflash-file.o'.  Stop.
  make[1]: *** Waiting for unfinished jobs....
  make[1]: Leaving directory '/home/joel/dev/skiboot/external/shared'
  rules.mk:25: recipe for target
  '../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce'
  failed
  make: ***
  [../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce]
  Error 2

Signed-off-by: Joel Stanley <joel@jms.id.au>
---

Stewart, please apply to master and 5.2 stable.

 external/pflash/Makefile |  2 +-
 external/pflash/rules.mk | 16 ++++------------
 external/shared/Makefile | 23 +++++++++++++++--------
 3 files changed, 20 insertions(+), 21 deletions(-)

Comments

Stewart Smith July 27, 2016, 8:15 a.m. UTC | #1
Joel Stanley <joel@jms.id.au> writes:
> The pflash build process has regressed from when the were last fixed in
> 6c21c4ffaf82.
>
> This patch resolves that issue and performs some cleanups:
>
>  - Remove duplicated rules. Patches had moved rules into common files,
>    but forgotten to remove them from the pflash makefiles.
>
>  - Make assignements simply expanded variables where possible. Form the
>    make manual:
>
>      Functions referenced in the definition will be executed every time
>      the variable is expanded.  This makes make run slower; worse, it
>      causes the wildcard and shell functions to give unpredictable
>      results because you cannot easily control when they are called, or
>      even how many times.
>
>      To avoid all the problems and inconveniences of recursively
>      expanded variables, there is another flavor: simply expanded
>      variables.
>
>  - set the 'shared' target as a dependency of the libflash objects. This
>    was the final piece to resolve the race condition.
>
> The failed build could be reproduced by doing a `git clean -f -x` and
> then running the following:
>
>   $ make -j 32 CROSS_COMPILE=arm-linux-gnueabi- SKIBOOT_VERSION=5.2.4
>   PFLASH_VERSION=5.2.4 V=1 -C external/pflash all LINKAGE=dynamic
>   make: Entering directory '/home/joel/dev/skiboot/external/pflash'
>   ln -sf ../../libflash ./libflash
>   ln -sf ../../ccan ./ccan
>   ln -sf ../common ./common
>   cc -O2 -Wall -I. -c pflash.c -o pflash.o
>   cc -O2 -Wall -I. -c progress.c -o progress.o
>   make -C ../shared
>   make[1]: Entering directory '/home/joel/dev/skiboot/external/shared'
>   ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c common/ast-sf-ctrl.c
>   ln -sf ../../include/ast.h common/ast.h
>   ln -sf arch_flash_arm_io.h common/io.h
>   cc -O2 -Wall -I.  -c common/arch_flash_common.c -o
>   common-arch_flash_common.o
>   cc -O2 -Wall -I.  -c common/arch_flash_arm.c -o common-arch_flash_arm.o
>   cc -O2 -Wall -I.  -c common/ast-sf-ctrl.c -o common-ast-sf-ctrl.o
>   cc -O2 -Wall -I. -c version.c -o version.o
>   ld -r common-arch_flash_common.o common-arch_flash_arm.o
>   common-ast-sf-ctrl.o -o common-arch_flash.o
>   ln -sf ../../libflash ./libflash
>   ln -sf ../../ccan ./ccan
>   ln -sf ../common ./common
>   make[1]: *** No rule to make target 'libflash/file.c', needed by
>   'libflash-file.o'.  Stop.
>   make[1]: *** Waiting for unfinished jobs....
>   make[1]: Leaving directory '/home/joel/dev/skiboot/external/shared'
>   rules.mk:25: recipe for target
>   '../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce'
>   failed
>   make: ***
>   [../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce]
>   Error 2
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>
> Stewart, please apply to master and 5.2 stable.

Thanks, merged to both:

5.2.x: 8692215d6ff81a935e8086ccff6c05e9dc2cc6be
master: c327edd
Stewart Smith July 27, 2016, 8:29 a.m. UTC | #2
Joel Stanley <joel@jms.id.au> writes:
> The pflash build process has regressed from when the were last fixed in
> 6c21c4ffaf82.
>
> This patch resolves that issue and performs some cleanups:
>
>  - Remove duplicated rules. Patches had moved rules into common files,
>    but forgotten to remove them from the pflash makefiles.
>
>  - Make assignements simply expanded variables where possible. Form the
>    make manual:
>
>      Functions referenced in the definition will be executed every time
>      the variable is expanded.  This makes make run slower; worse, it
>      causes the wildcard and shell functions to give unpredictable
>      results because you cannot easily control when they are called, or
>      even how many times.
>
>      To avoid all the problems and inconveniences of recursively
>      expanded variables, there is another flavor: simply expanded
>      variables.
>
>  - set the 'shared' target as a dependency of the libflash objects. This
>    was the final piece to resolve the race condition.
>
> The failed build could be reproduced by doing a `git clean -f -x` and
> then running the following:
>
>   $ make -j 32 CROSS_COMPILE=arm-linux-gnueabi- SKIBOOT_VERSION=5.2.4
>   PFLASH_VERSION=5.2.4 V=1 -C external/pflash all LINKAGE=dynamic
>   make: Entering directory '/home/joel/dev/skiboot/external/pflash'
>   ln -sf ../../libflash ./libflash
>   ln -sf ../../ccan ./ccan
>   ln -sf ../common ./common
>   cc -O2 -Wall -I. -c pflash.c -o pflash.o
>   cc -O2 -Wall -I. -c progress.c -o progress.o
>   make -C ../shared
>   make[1]: Entering directory '/home/joel/dev/skiboot/external/shared'
>   ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c common/ast-sf-ctrl.c
>   ln -sf ../../include/ast.h common/ast.h
>   ln -sf arch_flash_arm_io.h common/io.h
>   cc -O2 -Wall -I.  -c common/arch_flash_common.c -o
>   common-arch_flash_common.o
>   cc -O2 -Wall -I.  -c common/arch_flash_arm.c -o common-arch_flash_arm.o
>   cc -O2 -Wall -I.  -c common/ast-sf-ctrl.c -o common-ast-sf-ctrl.o
>   cc -O2 -Wall -I. -c version.c -o version.o
>   ld -r common-arch_flash_common.o common-arch_flash_arm.o
>   common-ast-sf-ctrl.o -o common-arch_flash.o
>   ln -sf ../../libflash ./libflash
>   ln -sf ../../ccan ./ccan
>   ln -sf ../common ./common
>   make[1]: *** No rule to make target 'libflash/file.c', needed by
>   'libflash-file.o'.  Stop.
>   make[1]: *** Waiting for unfinished jobs....
>   make[1]: Leaving directory '/home/joel/dev/skiboot/external/shared'
>   rules.mk:25: recipe for target
>   '../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce'
>   failed
>   make: ***
>   [../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce]
>   Error 2
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>
> Stewart, please apply to master and 5.2 stable.

regression on travis :(

https://travis-ci.org/stewart-ibm/skiboot/builds/147693375

I'll await a patch that fixes it and not yet revert this one
diff mbox

Patch

diff --git a/external/pflash/Makefile b/external/pflash/Makefile
index 3a4c5633f7ab..4c9b08baef29 100644
--- a/external/pflash/Makefile
+++ b/external/pflash/Makefile
@@ -1,5 +1,5 @@ 
 include rules.mk
-GET_ARCH = ../../external/common/get_arch.sh
+GET_ARCH := ../../external/common/get_arch.sh
 include ../../external/common/rules.mk
 
 all: links arch_links $(EXE)
diff --git a/external/pflash/rules.mk b/external/pflash/rules.mk
index df814fe1bfed..6be9b677698f 100644
--- a/external/pflash/rules.mk
+++ b/external/pflash/rules.mk
@@ -1,11 +1,8 @@ 
 .DEFAULT_GOAL := all
 
 override CFLAGS  += -O2 -Wall -I.
-PFLASH_OBJS    = pflash.o progress.o version.o common-arch_flash.o
-LIBFLASH_FILES := libflash.c libffs.c ecc.c blocklevel.c file.c
-LIBFLASH_OBJS := $(addprefix libflash-, $(LIBFLASH_FILES:.c=.o))
-LIBFLASH_SRC := $(addprefix libflash/,$(LIBFLASH_FILES))
-OBJS	= $(PFLASH_OBJS) $(LIBFLASH_OBJS)
+PFLASH_OBJS    := pflash.o progress.o version.o common-arch_flash.o
+OBJS	:= $(PFLASH_OBJS) $(LIBFLASH_OBJS)
 EXE     = pflash
 sbindir?=/usr/sbin
 
@@ -14,8 +11,8 @@  LINKAGE?=static
 
 ifeq ($(LINKAGE),dynamic)
 include ../shared/rules.mk
-SHARED=../shared/$(SHARED_NAME)
-OBJS=$(PFLASH_OBJS) $(SHARED)
+SHARED	:= ../shared/$(SHARED_NAME)
+OBJS	:= $(PFLASH_OBJS) $(SHARED)
 INSTALLDEPS+=install-shared
 
 install-shared:
@@ -35,11 +32,6 @@  version.c: .version
 %.o : %.c
 	$(Q_CC)$(CC) $(CFLAGS) -c $< -o $@
 
-$(LIBFLASH_SRC): | links
-
-$(LIBFLASH_OBJS): libflash-%.o : libflash/%.c
-	$(Q_CC)$(CC) $(CFLAGS) -c $< -o $@
-
 $(EXE): $(OBJS)
 	$(Q_CC)$(CC) $(CFLAGS) $^ -lrt -o $@
 
diff --git a/external/shared/Makefile b/external/shared/Makefile
index c643666458b9..e0b3ff3918a8 100644
--- a/external/shared/Makefile
+++ b/external/shared/Makefile
@@ -1,23 +1,30 @@ 
 .DEFAULT_GOAL := all
-GET_ARCH = ../../external/common/get_arch.sh
+GET_ARCH := ../../external/common/get_arch.sh
 include ../../external/common/rules.mk
 include rules.mk
 
 PREFIX ?= /usr/local/
-LIBDIR = $(PREFIX)/lib
-INCDIR = $(PREFIX)/include/libflash
+LIBDIR := $(PREFIX)/lib
+INCDIR := $(PREFIX)/include/libflash
 
 ifneq ($(ARCH), ARCH_ARM)
 CFLAGS += -m64
 endif
 CFLAGS += -Werror -Wall -g2 -ggdb -I. -fPIC
 
-LIBFLASH_OBJS = libflash-file.o libflash-libflash.o libflash-libffs.o libflash-ecc.o libflash-blocklevel.o
-ARCHFLASH_OBJS = common-arch_flash.o
-OBJS = $(LIBFLASH_OBJS) $(ARCHFLASH_OBJS)
+LIBFLASH_OBJS := libflash-file.o libflash-libflash.o libflash-libffs.o \
+	libflash-ecc.o libflash-blocklevel.o
+ARCHFLASH_OBJS := common-arch_flash.o
+OBJS := $(LIBFLASH_OBJS) $(ARCHFLASH_OBJS)
 
-LIBFLASH_H = libflash/file.h libflash/libflash.h libflash/libffs.h libflash/ffs.h libflash/ecc.h libflash/blocklevel.h libflash/errors.h
-ARCHFLASH_H = common/arch_flash.h
+LIBFLASH_H := libflash/file.h libflash/libflash.h libflash/libffs.h \
+	libflash/ffs.h libflash/ecc.h libflash/blocklevel.h libflash/errors.h
+ARCHFLASH_H := common/arch_flash.h
+
+LIBFLASH_FILES := libflash.c libffs.c ecc.c blocklevel.c file.c
+LIBFLASH_SRC := $(addprefix libflash/,$(LIBFLASH_FILES))
+
+$(LIBFLASH_SRC): | links
 
 $(LIBFLASH_OBJS) : libflash-%.o : libflash/%.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@