[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 13/51] pc-bios/optionrom: detect CC options just once
From: |
Alex Bennée |
Subject: |
[PATCH v1 13/51] pc-bios/optionrom: detect CC options just once |
Date: |
Thu, 29 Sep 2022 12:41:53 +0100 |
From: Paolo Bonzini <pbonzini@redhat.com>
In preparation for adding Docker container support, detect compiler options
just once rather than once per Make run; container startup overhead is
substantial and doing the detection just once makes things faster.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
pc-bios/optionrom/Makefile | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index 3e06c11dea..f514e4f84b 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -8,23 +8,33 @@ all: multiboot.bin multiboot_dma.bin linuxboot.bin
linuxboot_dma.bin kvmvapic.bi
CFLAGS = -O2 -g
-quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
-cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null
2>&1 && echo OK), $1, $2)
-
-override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16
+NULL :=
+SPACE := $(NULL) #
+TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR))
-# If -fcf-protection is enabled in flags or compiler defaults that will
-# conflict with -march=i486
-override CFLAGS += $(call cc-option, -fcf-protection=none)
+quiet-@ = $(if $(V),,@)
+quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
# Flags for dependency generation
override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
-override CFLAGS += $(call cc-option, -fno-pie)
-override CFLAGS += $(call cc-option, -no-pie)
+override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16
override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
-override CFLAGS += $(call cc-option, -fno-stack-protector)
-override CFLAGS += $(call cc-option, -Wno-array-bounds)
+
+cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
+cc-option = if $(call cc-test, $1); then \
+ echo "$(TARGET_PREFIX)$1 detected" && echo "override CFLAGS += $1" >&3;
else \
+ echo "$(TARGET_PREFIX)$1 not detected" $(if $2,&& echo "override CFLAGS +=
$2" >&3); fi
+
+# If -fcf-protection is enabled in flags or compiler defaults that will
+# conflict with -march=i486
+config-cc.mak: Makefile
+ $(quiet-@)($(call cc-option,-fcf-protection=none); \
+ $(call cc-option,-fno-pie); \
+ $(call cc-option,-no-pie); \
+ $(call cc-option,-fno-stack-protector); \
+ $(call cc-option,-Wno-array-bounds)) 3> config-cc.mak
+-include config-cc.mak
override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds
@@ -50,7 +60,10 @@ include $(wildcard *.d)
clean:
rm -f *.o *.d *.raw *.img *.bin *~
+distclean:
+ rm -f config-cc.mak
+
# suppress auto-removal of intermediate files
.SECONDARY:
-.PHONY: all clean
+.PHONY: all clean distclean
--
2.34.1
- [PATCH v1 08/51] target/hexagon: manually add flex/bison/glib2 to remaining containers, (continued)
- [PATCH v1 08/51] target/hexagon: manually add flex/bison/glib2 to remaining containers, Alex Bennée, 2022/09/29
- [PATCH v1 11/51] tests/qtest: bump up QOS_PATH_MAX_ELEMENT_SIZE, Alex Bennée, 2022/09/29
- [PATCH v1 05/51] configure: move detected gdb to TCG's config-host.mak, Alex Bennée, 2022/09/29
- [PATCH v1 10/51] tests/docker: move alpine from edge to tagged release, Alex Bennée, 2022/09/29
- [PATCH v1 14/51] pc-bios/s390-ccw: detect CC options just once, Alex Bennée, 2022/09/29
- [PATCH v1 12/51] configure: do not invoke as/ld directly for pc-bios/optionrom, Alex Bennée, 2022/09/29
- [PATCH v1 04/51] tests/docker: run script use realpath instead of readlink, Alex Bennée, 2022/09/29
- [PATCH v1 16/51] build: add recursive distclean rules, Alex Bennée, 2022/09/29
- [PATCH v1 28/51] configure: build ROMs with container-based cross compilers, Alex Bennée, 2022/09/29
- [PATCH v1 09/51] tests/docker: update fedora-win[32|64]-cross with lcitool, Alex Bennée, 2022/09/29
- [PATCH v1 13/51] pc-bios/optionrom: detect CC options just once,
Alex Bennée <=
- [PATCH v1 15/51] vof: add distclean target, Alex Bennée, 2022/09/29
- [PATCH v1 19/51] tests: simplify Makefile invocation for tests/tcg, Alex Bennée, 2022/09/29
- [PATCH v1 36/51] plugins: Assert mmu_idx in range before use in qemu_plugin_get_hwaddr, Alex Bennée, 2022/09/29
- [PATCH v1 38/51] docs/devel: move API to end of tcg-plugins.rst, Alex Bennée, 2022/09/29
- [PATCH v1 34/51] disas: use result of ->read_memory_func, Alex Bennée, 2022/09/29
- [PATCH v1 43/51] gdbstub: move sstep flags probing into AccelClass, Alex Bennée, 2022/09/29
- [PATCH v1 25/51] configure: move tests/tcg/Makefile.prereqs to root build directory, Alex Bennée, 2022/09/29