summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ehrhardt <ehrhardt@linux.vnet.ibm.com>2008-01-08 17:56:37 +0100
committerAvi Kivity <avi@qumranet.com>2008-01-08 19:00:35 +0200
commit096b67c70f2643b2e8cea9ae821c3fbbf8c69f7d (patch)
tree796de905bcf70ddd80a2628fd994420495dfd8fe /kvm/extboot
parentFixup virtio_net TX timer (diff)
downloadqemu-kvm-096b67c70f2643b2e8cea9ae821c3fbbf8c69f7d.tar.gz
qemu-kvm-096b67c70f2643b2e8cea9ae821c3fbbf8c69f7d.tar.bz2
qemu-kvm-096b67c70f2643b2e8cea9ae821c3fbbf8c69f7d.zip
kvm: extboot: fix -fno-stack-protector usage
Option -fno-stack-protector breaks kvm-userspace in environments without stack-protector functionality. They fail with "unrecognized command line option" when compiling extboot. This patch removes the fix -fno-stack-protector option and replaces it with a detection that only adds -fno-stack-protector if the option is supported by the used gcc. The detection code is copied from kernel sources scripts/Kbuild.include. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'kvm/extboot')
-rw-r--r--kvm/extboot/Makefile24
1 files changed, 22 insertions, 2 deletions
diff --git a/kvm/extboot/Makefile b/kvm/extboot/Makefile
index 1ea71a735..ab2dae70d 100644
--- a/kvm/extboot/Makefile
+++ b/kvm/extboot/Makefile
@@ -1,7 +1,27 @@
OBJCOPY=objcopy
-CFLAGS=-Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin \
- -fno-stack-protector
+# from kernel sources - scripts/Kbuild.include
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e; \
+ TMP="$(TMPOUT).$$$$.tmp"; \
+ if ($(1)) >/dev/null 2>&1; \
+ then echo "$(2)"; \
+ else echo "$(3)"; \
+ fi; \
+ rm -f "$$TMP")
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+cc-option-yn = $(call try-run,\
+ $(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
+
+CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
+ifeq ($(call cc-option-yn,-fno-stack-protector),y)
+CFLAGS += -fno-stack-protector
+endif
all: extboot.bin