This commit allows morello kselftest to be compiled from GCC toolchain. Also, Gcc toolchain complains for the missing memcpy function with -nostdlib linker option so a memcpy implementation is added.
Note: This commit requires CC to be set for Clang toolchain which was not earlier.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- tools/testing/selftests/arm64/morello/Makefile | 12 +++++++----- tools/testing/selftests/arm64/morello/freestanding.c | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/Makefile b/tools/testing/selftests/arm64/morello/Makefile index 7dbf5b140695..51e46838e345 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 -LLVM := 1 - +# Provide clang as CC otherwise defaults to gcc +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) CLANG_FLAGS = --target=aarch64-linux-gnu +CFLAGS_CLANG = $(CLANG_FLAGS) -integrated-as +LDFLAGS_CLANG = -fuse-ld=lld +endif + CFLAGS_PURECAP = -march=morello+c64 -mabi=purecap CFLAGS_COMMON = -g -ffreestanding -Wall -Wextra -MMD 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 +LDFLAGS := $(LDFLAGS_CLANG) $(CLANG_FLAGS) -nostdlib -static
SRCS := $(wildcard *.c) $(wildcard *.S) PROGS := bootstrap clone exit mmap read_write sched signal diff --git a/tools/testing/selftests/arm64/morello/freestanding.c b/tools/testing/selftests/arm64/morello/freestanding.c index 45c0fa8b0914..81599201928d 100644 --- a/tools/testing/selftests/arm64/morello/freestanding.c +++ b/tools/testing/selftests/arm64/morello/freestanding.c @@ -185,3 +185,10 @@ int printf(const char *fmt, ...)
return written; } + +void *memcpy(void *dest, const void *src, size_t n) +{ + for (size_t i = 0; i < n; i++) + ((char *)dest)[i] = ((char *)src)[i]; + return dest; +}