Config.mk: extend cc-option to consider exit status
PATCH 1/1 Config.mk: extend cc-option to consider exit status
Option like -Og produces something like
cc1: error: argument to '-O' should be a non-negative integer
with a compiler that doesn't support it.
Grepping for the exact option wouldn't work. Extend cc-option to take into account the exit status of the test.
--- Config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Config.mk +1 -1
@@ -100,7 +100,7 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix)" # # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586) cc-option = $(shell if test -z "`echo 'void*p=1;' | \ - $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \ + { $(1) $(2) -S -o /dev/null -x c - 2>&1 || echo $(2); } | grep -- $(2) -`"; \ then echo "$(2)"; else echo "$(3)"; fi ;) # cc-option-add: Add an option to compilation flags, but only if supported.
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 15.03.18 at 13:46, <[email protected]> wrote:
Option like -Og produces something like
cc1: error: argument to '-O' should be a non-negative integer
Quoted 7 lines
with a compiler that doesn't support it.
Grepping for the exact option wouldn't work. Extend cc-option to take into account the exit status of the test.
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Wei Liu <[email protected]>
Taking on my reviewer's hat:
Config.mk PYTHON_PREFIX_ARG ?= --prefix="$(prefix)" · line 103
Quoted 8 lines
Config.mk +1
-1@@ -100,7 +100,7 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix)" # # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586) cc-option = $(shell if test -z "`echo 'void*p=1;' | \ - $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \ + { $(1) $(2) -S -o /dev/null -x c - 2>&1 || echo $(2); } | grep -- $(2) -`"; \
I only now realize that compilers are permitted to actually error on the construct being compiled (it just so happens that gcc as an extension allows integral types be assigned to pointer type variables). Hence at the very least you need to be certain (and should say so in the description) that no compiler (version) we support would error on that construct.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel