diff mbox series

[01/11] kselftest/arm64: mte: Fix compilation with native compiler

Message ID 20210319165334.29213-2-andre.przywara@arm.com (mailing list archive)
State Accepted
Commit 4a423645bc2690376a7a94b4bb7b2f74bc6206ff
Headers show
Series kselftest/arm64: mte: Fix feature detection and compilation | expand

Commit Message

Andre Przywara March 19, 2021, 4:53 p.m. UTC
The mte selftest Makefile contains a check for GCC, to add the memtag
-march flag to the compiler options. This check fails if the compiler
is not explicitly specified, so reverts to the standard "cc", in which
case --version doesn't mention the "gcc" string we match against:
$ cc --version | head -n 1
cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

This will not add the -march switch to the command line, so compilation
fails:
mte_helper.S: Assembler messages:
mte_helper.S:25: Error: selected processor does not support `irg x0,x0,xzr'
mte_helper.S:38: Error: selected processor does not support `gmi x1,x0,xzr'
...

Actually clang accepts the same -march option as well, so we can just
drop this check and add this unconditionally to the command line, to avoid
any future issues with this check altogether (gcc actually prints
basename(argv[0]) when called with --version).

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 tools/testing/selftests/arm64/mte/Makefile | 2 --
 1 file changed, 2 deletions(-)

Comments

Nick Desaulniers March 19, 2021, 5:29 p.m. UTC | #1
On Fri, Mar 19, 2021 at 9:53 AM Andre Przywara <andre.przywara@arm.com> wrote:
>
> The mte selftest Makefile contains a check for GCC, to add the memtag
> -march flag to the compiler options. This check fails if the compiler
> is not explicitly specified, so reverts to the standard "cc", in which
> case --version doesn't mention the "gcc" string we match against:
> $ cc --version | head -n 1
> cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
>
> This will not add the -march switch to the command line, so compilation
> fails:
> mte_helper.S: Assembler messages:
> mte_helper.S:25: Error: selected processor does not support `irg x0,x0,xzr'
> mte_helper.S:38: Error: selected processor does not support `gmi x1,x0,xzr'
> ...
>
> Actually clang accepts the same -march option as well, so we can just
> drop this check and add this unconditionally to the command line, to avoid
> any future issues with this check altogether (gcc actually prints
> basename(argv[0]) when called with --version).
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  tools/testing/selftests/arm64/mte/Makefile | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
> index 0b3af552632a..df15d44aeb8d 100644
> --- a/tools/testing/selftests/arm64/mte/Makefile
> +++ b/tools/testing/selftests/arm64/mte/Makefile
> @@ -6,9 +6,7 @@ SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
>  PROGS := $(patsubst %.c,%,$(SRCS))
>
>  #Add mte compiler option
> -ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep gcc),)
>  CFLAGS += -march=armv8.5-a+memtag
> -endif
>
>  #check if the compiler works well
>  mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
> --
> 2.17.5
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
index 0b3af552632a..df15d44aeb8d 100644
--- a/tools/testing/selftests/arm64/mte/Makefile
+++ b/tools/testing/selftests/arm64/mte/Makefile
@@ -6,9 +6,7 @@  SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
 PROGS := $(patsubst %.c,%,$(SRCS))
 
 #Add mte compiler option
-ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep gcc),)
 CFLAGS += -march=armv8.5-a+memtag
-endif
 
 #check if the compiler works well
 mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)