[Skiboot] [PATCH] pflash: Clean up makefiles and resolve build race
Joel Stanley
joel at jms.id.au
Fri Jul 22 23:47:40 AEST 2016
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 at 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(-)
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 $@
--
2.8.1
More information about the Skiboot
mailing list