aboutsummaryrefslogtreecommitdiffstats
path: root/Config.mk
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-05-23 17:38:28 +0100
committerKeir Fraser <keir@xen.org>2011-05-23 17:38:28 +0100
commit28f8fb7d2b3fde2f5cbe5526ac4f1c932e3f5d26 (patch)
tree6cab52be55a7f2c38f5a4719f6dc94ec9e47b6e7 /Config.mk
parent5a40af4739c1402ada1a8668c1a08c4ce6a1628f (diff)
downloadxen-28f8fb7d2b3fde2f5cbe5526ac4f1c932e3f5d26.tar.gz
xen-28f8fb7d2b3fde2f5cbe5526ac4f1c932e3f5d26.tar.bz2
xen-28f8fb7d2b3fde2f5cbe5526ac4f1c932e3f5d26.zip
Fix Config.mk's cc-option for -Wno-* options.
These disable-warning options are handled specially by GCC: (a) they are ignored unless the compiler emits a warning; and (b) even then they produce a warning rather than an error To handle this, modify the test invocation of GCC to compile a fragment of code that will always provoke a warning (integer assigned to pointer). This works around (a) above. Then, we grep the compiler's stdout/stderr for the option-under-test, the presence of which would indicate an "unrecognized command-line option" warning/error. This works around (b) above, letting us distinguish between the "integer assigned to pointer" and "unrecognized command-line option" warnings. Signed-off-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'Config.mk')
-rw-r--r--Config.mk14
1 files changed, 12 insertions, 2 deletions
diff --git a/Config.mk b/Config.mk
index d57a6e4478..aa681aebd0 100644
--- a/Config.mk
+++ b/Config.mk
@@ -71,9 +71,19 @@ PYTHON_PREFIX_ARG ?= --prefix="$(PREFIX)"
# https://bugs.launchpad.net/ubuntu/+bug/362570
# cc-option: Check if compiler supports first option, else fall back to second.
+#
+# This is complicated by the fact that unrecognised -Wno-* options:
+# (a) are ignored unless the compilation emits a warning; and
+# (b) even then produce a warning rather than an error
+# To handle this we do a test compile, passing the option-under-test, on a code
+# fragment that will always produce a warning (integer assigned to pointer).
+# We then grep for the option-under-test in the compiler's output, the presence
+# of which would indicate an "unrecognized command-line option" warning/error.
+#
# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
-cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
- /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
+cc-option = $(shell if test -z "`echo 'void*p=1;' | \
+ $(1) $(2) -S -o /dev/null -xc - 2>&1 | grep -- $(2)`"; \
+ then echo "$(2)"; else echo "$(3)"; fi ;)
# cc-option-add: Add an option to compilation flags, but only if supported.
# Usage: $(call cc-option-add CFLAGS,CC,-march=winchip-c6)