mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 02:40:08 +00:00
build: ensure rules with pipes might fail
.SHELLFLAGS is extended by option pipefail to make pipes fail if any pipe element fails. As .SHELLFLAGS is exported into sub-make instances it must be unexported before calling third-party build systems recursively.
This commit is contained in:
parent
7da691b52a
commit
d182b20705
@ -10,20 +10,17 @@ KERNEL_CXXFLAGS = -std=gnu++98 -fno-delete-null-pointer-checks $(CXXWARN) \
|
||||
-Wno-address-of-packed-member
|
||||
|
||||
$(FIASCO_BUILD_DIR):
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $(FIASCO_SRC) BUILDDIR=$@ \
|
||||
$(KERNEL_BUILD_OUTPUT_FILTER)
|
||||
$(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $@ oldconfig \
|
||||
$(KERNEL_BUILD_OUTPUT_FILTER)
|
||||
$(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out
|
||||
|
||||
$(FIASCO): $(FIASCO_BUILD_DIR)
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
MAKEFLAGS= CFLAGS="-std=gnu89 $(CWARN)" \
|
||||
$(VERBOSE_MK) MAKEFLAGS= CFLAGS="-std=gnu89 $(CWARN)" \
|
||||
CXXFLAGS="$(KERNEL_CXXFLAGS)" \
|
||||
$(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $(FIASCO_BUILD_DIR) \
|
||||
|
@ -33,6 +33,9 @@ ifeq ($(VERBOSE),)
|
||||
L4_VERBOSE = V=1
|
||||
endif
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
#
|
||||
# Execute the rules in this file only at the second build stage when we know
|
||||
# about the complete build settings, e.g., 'CROSS_DEV_PREFIX'.
|
||||
@ -61,8 +64,7 @@ CXXWARN = $(WARN) -Wno-bool-compare -Wno-c++11-compat -Wno-class-memaccess
|
||||
# 'off64_t' type, which is used by bootstrap.
|
||||
#
|
||||
%.tag:
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
MAKEFLAGS= CPPFLAGS="$(CC_MARCH)" \
|
||||
$(VERBOSE_MK) MAKEFLAGS= CPPFLAGS="$(CC_MARCH)" \
|
||||
CFLAGS="$(CC_MARCH) -std=gnu89 $(CWARN)" \
|
||||
CXXFLAGS="$(CC_MARCH) -D_GNU_SOURCE -std=gnu++98 $(CXXWARN)" \
|
||||
ASFLAGS="$(CC_MARCH)" LDFLAGS="$(LD_MARCH)" \
|
||||
|
@ -15,7 +15,7 @@ L4_BUILD_DIR := $(shell pwd)
|
||||
.Makeconf.bid.old:
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)cp $(L4_CONFIG) $(@:.old=)
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
$(VERBOSE_MK) \
|
||||
MAKEFLAGS= make $(VERBOSE_DIR) -C $(L4_SRC_DIR)/l4 \
|
||||
O=$(L4_BUILD_DIR) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" oldconfig \
|
||||
2>&1 | sed "s/^/ [l4build] /"
|
||||
|
@ -8,15 +8,13 @@ MAKEOVERRIDES := $(filter-out KERNEL=%,$(MAKEOVERRIDES))
|
||||
unexport KERNEL
|
||||
|
||||
$(FOC_BUILD_DIR):
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
$(MAKE) CROSS_COMPILE="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_MK) $(MAKE) CROSS_COMPILE="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $(FOC_SRC) BUILDDIR=$@ \
|
||||
$(KERNEL_BUILD_OUTPUT_FILTER)
|
||||
$(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out
|
||||
|
||||
$(FOC): $(FOC_BUILD_DIR)
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
$(MAKE) CROSS_COMPILE="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_MK) $(MAKE) CROSS_COMPILE="$(CROSS_DEV_PREFIX)" \
|
||||
CC="$(CC)" CXX="$(CXX)" \
|
||||
$(VERBOSE_DIR) -C $(FOC_BUILD_DIR) \
|
||||
$(KERNEL_BUILD_OUTPUT_FILTER)
|
||||
|
@ -39,6 +39,9 @@ PKG_TAGS = $(addsuffix .tag,$(addsuffix .$(BOARD),$(PKGS)))
|
||||
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s~^~ [$*] ~"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
#
|
||||
# Execute the rules in this file only at the second build stage when we know
|
||||
# about the complete build settings, e.g., 'CROSS_DEV_PREFIX'.
|
||||
@ -55,8 +58,7 @@ endif
|
||||
.NOTPARALLEL: $(PKG_TAGS)
|
||||
|
||||
%.$(BOARD).tag:
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
$(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) -C $(L4_PKG_DIR)/$* \
|
||||
$(VERBOSE_MK) $(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) -C $(L4_PKG_DIR)/$* \
|
||||
"$(L4_BUILD_OPT)" WARNINGS=$(WARNINGS) $(BUILD_OUTPUT_FILTER)
|
||||
$(VERBOSE)mkdir -p $(dir $@) && touch $@
|
||||
|
||||
|
@ -37,7 +37,7 @@ CC_OPT += -DL4SYS_USE_UTCB_WRAP=1 -Wno-unused-function
|
||||
# build system will stuble over predefined variables, i.e., 'LIB'
|
||||
#
|
||||
$(L4_BUILD_DIR)/.kconfig:
|
||||
$(VERBOSE_MK) set -o pipefail; \
|
||||
$(VERBOSE_MK) \
|
||||
MAKEFLAGS= $(MAKE) $(VERBOSE_DIR) -C $(L4_SRC_DIR)/l4 \
|
||||
B=$(L4_BUILD_DIR) DROPSCONF_DEFCONFIG="$(L4_CONFIG)" \
|
||||
VERBOSE="$(VERBOSE)" CROSS_COMPILE="$(CROSS_DEV_PREFIX)" \
|
||||
|
@ -9,6 +9,9 @@ CC_WARN += -Wno-array-bounds -Wno-unused-but-set-variable \
|
||||
-Wno-parentheses -Wno-format -Wno-builtin-declaration-mismatch \
|
||||
-Wno-unused-function -Wno-pointer-compare
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
user_build.tag:
|
||||
LIBGCCFLAGS="$(CC_MARCH)" \
|
||||
LDFLAGS="$(addprefix $(LD_PREFIX),$(LD_MARCH)) -nostdlib" \
|
||||
|
@ -24,6 +24,9 @@ $(KERNEL_BUILD_DIR)/Makefile:
|
||||
#
|
||||
unexport CCACHE
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
#
|
||||
# How to pass custom compiler flags to the Pistachio build system
|
||||
#
|
||||
|
@ -15,6 +15,9 @@ include $(REP_DIR)/src/virt_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -21,6 +21,9 @@ include $(REP_DIR)/src/virt_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -21,6 +21,9 @@ include $(REP_DIR)/src/virt_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -15,6 +15,9 @@ include $(REP_DIR)/src/pc_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -21,6 +21,9 @@ include $(REP_DIR)/src/pc_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -21,6 +21,9 @@ include $(REP_DIR)/src/pc_linux/target.inc
|
||||
# filter for make output of kernel build system
|
||||
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
|
||||
|
||||
# do not confuse third-party sub-makes
|
||||
unexport .SHELLFLAGS
|
||||
|
||||
kernel_config.tag:
|
||||
$(MSG_CONFIG)Linux
|
||||
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
|
||||
|
@ -40,6 +40,12 @@
|
||||
## Define global configuration variables
|
||||
##
|
||||
|
||||
#
|
||||
# We initially enforce .SHELLFLAGS flags in case build.mk called recursively
|
||||
# (from tool/run) as SHELL will be reset to /bin/sh before setting up bash.
|
||||
#
|
||||
.SHELLFLAGS := -c
|
||||
|
||||
#
|
||||
# Whenever using the 'run/%' rule and the run tool spawns this Makefile again
|
||||
# when encountering a 'build' step, the build.conf is included a second time,
|
||||
@ -91,7 +97,17 @@ endif
|
||||
# standard shell is dash, which breaks colored output via its built-in echo
|
||||
# command.
|
||||
#
|
||||
export SHELL := $(shell sh -c "command -v bash")
|
||||
# SHELL is exported into the environment for tools used in rules
|
||||
# (like tool/run). Unfortunately, sub-make instances will reset SHELL to
|
||||
# /bin/sh if it is not explicitly provided on the command like (as we do
|
||||
# below). See GNU Make manual "5.3.2 Choosing the Shell" for further details.
|
||||
# .SHELLFLAGS is extended by option pipefail to make pipes fail if any pipe
|
||||
# element fails.
|
||||
#
|
||||
export SHELL := $(shell sh -c "command -v bash")
|
||||
export .SHELLFLAGS := -o pipefail $(.SHELLFLAGS)
|
||||
|
||||
MAKE := $(MAKE) SHELL=$(SHELL)
|
||||
|
||||
#
|
||||
# Discharge variables evaluated by ccache mechanism that may be inherited when
|
||||
@ -267,7 +283,6 @@ traverse_target_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progr
|
||||
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_prg.mk \
|
||||
REP_DIR=$$rep TARGET_MK=$$rep/src/$$target \
|
||||
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
||||
SHELL=$(SHELL) \
|
||||
DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)" || result=false; \
|
||||
break; \
|
||||
done; \
|
||||
@ -282,7 +297,6 @@ traverse_lib_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress
|
||||
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk \
|
||||
REP_DIR=$$rep LIB=$(LIB) \
|
||||
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
||||
SHELL=$(SHELL) \
|
||||
DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)"; \
|
||||
echo "all: $(LIB).lib" >> $(LIB_DEP_FILE); \
|
||||
|
||||
@ -323,11 +337,12 @@ gen_deps_and_build_targets: $(INSTALL_DIR) $(DEBUG_DIR) $(LIB_DEP_FILE)
|
||||
echo "check_ports:"; \
|
||||
echo "endif"; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
@$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
||||
$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
||||
|
||||
|
||||
.PHONY: again
|
||||
again: $(INSTALL_DIR) $(DEBUG_DIR)
|
||||
@$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
||||
$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
||||
|
||||
#
|
||||
# Read tools configuration to obtain the cross-compiler prefix passed
|
||||
@ -433,7 +448,6 @@ clean_targets:
|
||||
-f $(BASE_DIR)/mk/prg.mk \
|
||||
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
||||
PRG_REL_DIR=$$d \
|
||||
SHELL=$(SHELL) \
|
||||
REP_DIR=$$r || \
|
||||
true; \
|
||||
done; \
|
||||
|
@ -33,3 +33,7 @@ file_content = $(if $(wildcard $1),$(shell cat $1),)
|
||||
|
||||
# Force stable sorting order
|
||||
SORT := LC_ALL=C sort
|
||||
|
||||
# ensure pipes might fail but do not confuse sub-makes
|
||||
.SHELLFLAGS := -o pipefail -c
|
||||
unexport .SHELLFLAGS
|
||||
|
Loading…
Reference in New Issue
Block a user