[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/54] pc-bios/s390-ccw: detect CC options just once
From: |
Alex Bennée |
Subject: |
[PULL 14/54] pc-bios/s390-ccw: detect CC options just once |
Date: |
Tue, 4 Oct 2022 14:00:58 +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>
Message-Id: <20220929114231.583801-15-alex.bennee@linaro.org>
diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak
index 7639da194c..ee59a5f4de 100644
--- a/pc-bios/s390-ccw/netboot.mak
+++ b/pc-bios/s390-ccw/netboot.mak
@@ -16,12 +16,9 @@ s390-netboot.elf: $(NETOBJS) libnet.a libc.a
s390-netboot.img: s390-netboot.elf
$(call quiet-command,$(STRIP) --strip-unneeded $< -o
$@,"STRIP","$(TARGET_DIR)$@")
-# SLOF is GCC-only, so ignore warnings about GNU extensions with Clang here
-NO_GNU_WARN := $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-gnu)
-
# libc files:
-LIBC_CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(NO_GNU_WARN) $(LIBC_INC)
$(LIBNET_INC) \
+LIBC_CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
-MMD -MP -MT $@ -MF $(@:%.o=%.d)
CTYPE_OBJS = isdigit.o isxdigit.o toupper.o
@@ -55,7 +52,7 @@ libc.a: $(LIBCOBJS)
LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \
dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o
-LIBNETCFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(NO_GNU_WARN) $(LIBC_INC)
$(LIBNET_INC) \
+LIBNETCFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
-DDHCPARCH=0x1F -MMD -MP -MT $@ -MF $(@:%.o=%.d)
%.o : $(SLOF_DIR)/lib/libnet/%.c
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index c8784c2a08..965e633f43 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -6,9 +6,12 @@ include config-host.mak
CFLAGS = -O2 -g
MAKEFLAGS += -rR
+NULL :=
+SPACE := $(NULL) #
+TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR))
+
+quiet-@ = $(if $(V),,@)
quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
-cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
- >/dev/null 2>&1 && echo OK),$2,$3)
VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in
set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath
$(PATTERN) $1)))
@@ -25,22 +28,33 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d
$(call quiet-command,$(CCAS) $(EXTRA_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
-c -o $@ $<,"CCAS","$(TARGET_DIR)$@")
-.PHONY : all clean build-all
+.PHONY : all clean build-all distclean
OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
-EXTRA_CFLAGS := $(EXTRA_CFLAGS) -Wall
-EXTRA_CFLAGS += $(call cc-option,-Werror
$(EXTRA_CFLAGS),-Wno-stringop-overflow)
+EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common
-fPIE
EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
-EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS), -fno-stack-protector)
-EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS), -Wno-array-bounds)
EXTRA_CFLAGS += -msoft-float
-EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS),-march=z900,-march=z10)
EXTRA_CFLAGS += -std=gnu99
LDFLAGS += -Wl,-pie -nostdlib
+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 "EXTRA_CFLAGS += $1" >&3; else \
+ echo "$(TARGET_PREFIX)$1 not detected" $(if $2,&& echo "EXTRA_CFLAGS +=
$2" >&3); fi
+
+config-cc.mak: Makefile
+ $(quiet-@)($(call cc-option,-Wno-stringop-overflow); \
+ $(call cc-option,-fno-stack-protector); \
+ $(call cc-option,-Wno-array-bounds); \
+ $(call cc-option,-Wno-gnu); \
+ $(call cc-option,-march=z900,-march=z10)) 3> config-cc.mak
+-include config-cc.mak
+
+LDFLAGS += -Wl,-pie -nostdlib
+
build-all: s390-ccw.img s390-netboot.img
s390-ccw.elf: $(OBJECTS)
@@ -63,3 +77,6 @@ ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS)
$(LIBNETOBJS))
clean:
rm -f *.o *.d *.img *.elf *~ *.a
+
+distclean:
+ rm -f config-cc.mak
--
2.34.1
- [PULL 07/54] target/hexagon: regenerate docker/cirrus files, (continued)
- [PULL 07/54] target/hexagon: regenerate docker/cirrus files, Alex Bennée, 2022/10/04
- [PULL 05/54] configure: move detected gdb to TCG's config-host.mak, Alex Bennée, 2022/10/04
- [PULL 03/54] scripts/ci/setup: spice-server only on x86 aarch64, Alex Bennée, 2022/10/04
- [PULL 10/54] tests/docker: move alpine from edge to tagged release, Alex Bennée, 2022/10/04
- [PULL 09/54] tests/docker: update fedora-win[32|64]-cross with lcitool, Alex Bennée, 2022/10/04
- [PULL 13/54] pc-bios/optionrom: detect CC options just once, Alex Bennée, 2022/10/04
- [PULL 52/54] contrib/gitdm: add Simon to individual contributors, Alex Bennée, 2022/10/04
- [PULL 11/54] tests/qtest: bump up QOS_PATH_MAX_ELEMENT_SIZE, Alex Bennée, 2022/10/04
- [PULL 29/54] pc-bios/optionrom: Adopt meson style Make output, Alex Bennée, 2022/10/04
- [PULL 14/54] pc-bios/s390-ccw: detect CC options just once,
Alex Bennée <=
- [PULL 51/54] contrib/gitdm: add China Telecom to the domain map, Alex Bennée, 2022/10/04
- [PULL 16/54] build: add recursive distclean rules, Alex Bennée, 2022/10/04
- [PULL 35/54] plugins: extend execlog to filter matches, Alex Bennée, 2022/10/04
- [PULL 17/54] configure: return status code from probe_target_compiler, Alex Bennée, 2022/10/04
- [PULL 25/54] configure: move tests/tcg/Makefile.prereqs to root build directory, Alex Bennée, 2022/10/04
- [PULL 44/54] gdbstub: move breakpoint logic to accel ops, Alex Bennée, 2022/10/04
- [PULL 38/54] docs/devel: move API to end of tcg-plugins.rst, Alex Bennée, 2022/10/04
- [PULL 45/54] gdbstub: move guest debug support check to ops, Alex Bennée, 2022/10/04
- [PULL 26/54] configure: unify creation of cross-compilation Makefiles, Alex Bennée, 2022/10/04