public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] extboot: fix -fno-stack-protector usage
@ 2008-01-08 16:56 Christian Ehrhardt
       [not found] ` <11998113973225-git-send-email-ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Ehrhardt @ 2008-01-08 16:56 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Christian Ehrhardt

Subject: [PATCH] extboot: fix -fno-stack-protector usage 
From: Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>

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-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>

 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-08 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-08 16:56 [PATCH] extboot: fix -fno-stack-protector usage Christian Ehrhardt
     [not found] ` <11998113973225-git-send-email-ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-01-08 17:10   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox