Subject: [PATCH] extboot: fix -fno-stack-protector usage 
From: Christian Ehrhardt <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>

 Makefile |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/extboot/Makefile b/extboot/Makefile
index 1ea71a7..ab2dae7 100644
--- a/extboot/Makefile
+++ b/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
 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to