On 02/02/2023 10:26, Amit Daniel Kachhap wrote:
This commit allows morello kselftest to be compiled by Gcc toolchain. While at it, remove clang compiler flags -integrated-as and --target as they are already set in kselftest root makefile.
Note: This commit requires CC to be set for Clang toolchain which was not the case earlier.
If you go with my suggestion below, this would become "either CC or LLVM".
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com
tools/testing/selftests/arm64/morello/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/Makefile b/tools/testing/selftests/arm64/morello/Makefile index 21906770f216..d9328bfe009f 100644 --- a/tools/testing/selftests/arm64/morello/Makefile +++ b/tools/testing/selftests/arm64/morello/Makefile @@ -1,16 +1,18 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (C) 2021 Arm Limited -# lib.mk sets CC. This switch triggers it to clang +# Assume gcc by default +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) +LDFLAGS_CLANG = -fuse-ld=lld
Since lib.mk defines CLANG_FLAGS, it would be more consistent to call this CLANG_LDFLAGS.
Something else I'm thinking about: in v1 I suggested to get the user to set LLVM themselves, so that CC gets set automatically. Here we're doing the opposite, but on second thoughts it makes sense as we're always setting CC in our build scripts. That said I think we could in fact support both, i.e. also LLVM being set and not CC, by moving this line out of the conditional and guard it with ifneq ($(LLVM),). I've tested that locally, it seems to work fine.
+# This switch triggers it to clang in lib.mk where different flags are set
Unclear what "it" refers to, in fact we're forcing LLVM=1 to get CLANG_FLAGS defined appropriately, so we could say just that.
LLVM := 1 +endif -CLANG_FLAGS = --target=aarch64-linux-gnu CFLAGS_PURECAP = -march=morello+c64 -mabi=purecap CFLAGS_COMMON = -g -ffreestanding -Wall -Wextra -MMD
Just noticed, looking at the generated command lines, that we can also remove -g and -Wall from here as they are already added by the arm64 Makefile.
Kevin
CFLAGS_COMMON += -nostdinc -isystem $(shell $(CC) -print-file-name=include 2>/dev/null) -CFLAGS_CLANG = $(CLANG_FLAGS) -integrated-as -CFLAGS += $(CFLAGS_CLANG) $(CFLAGS_PURECAP) $(CFLAGS_COMMON) -LDFLAGS := -fuse-ld=lld $(CLANG_FLAGS) -nostdlib -static +CFLAGS += $(CLANG_FLAGS) $(CFLAGS_PURECAP) $(CFLAGS_COMMON) +LDFLAGS += $(LDFLAGS_CLANG) $(CLANG_FLAGS) -nostdlib -static SRCS := $(wildcard *.c) $(wildcard *.S) PROGS := bootstrap clone exit mmap read_write sched signal