From f55b8face6e5ccb3b5d7e53eb637c2e48e6b581a Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 10 Nov 2023 15:26:26 +0800 Subject: [PATCH] wamr: Add support for thumb target triple in Toolchain.defs Before WAMR 1.3.0, eabihf in wamrc is `gnueabihf`, so without this patch call wamrc will failed with target abi was `eabihf`, we should convert the standard llvm target to wamrc required. Both `eabihf` and `gnueabihf` supported after WAMR 1.3.0. Signed-off-by: Huang Qi --- interpreters/wamr/Toolchain.defs | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/interpreters/wamr/Toolchain.defs b/interpreters/wamr/Toolchain.defs index c00e1707a..22185efe6 100644 --- a/interpreters/wamr/Toolchain.defs +++ b/interpreters/wamr/Toolchain.defs @@ -37,16 +37,35 @@ else ifeq ($(CONFIG_ARCH_SIM),y) else WTARGET = x86_64 endif -else +else ifeq ($(findstring thumb,$(LLVM_ARCHTYPE)),thumb) - # Flags for other architectures (arm or riscv) - - WTARGET = $(LLVM_ARCHTYPE) - WCPU = $(LLVM_CPUTYPE) + # target triple of thumb may very complex, such as thumbv8m.main+dsp+mve.fp+fp.dp + # so we just use the target name before the first plus sign + WTARGET = $(shell echo $(LLVM_ARCHTYPE) | cut -d'+' -f1) endif -RCFLAGS += --target=$(WTARGET) --target-abi=$(LLVM_ABITYPE) --cpu=$(WCPU) +# If WTARGET is not defined, then use the same as LLVM_ARCHTYPE + +ifeq ($(WTARGET),) + WTARGET = $(LLVM_ARCHTYPE) +endif + +# If WCPU is not defined, then use the same as LLVM_CPU + +ifeq ($(WCPU),) + WCPU = $(LLVM_CPUTYPE) +endif + +# If LLVM_ABITYPE is eabihf, then convert it to gnueabihf which is used by wamrc + +ifeq ($(LLVM_ABITYPE),eabihf) + WABITYPE = gnueabihf +else + WABITYPE = $(LLVM_ABITYPE) +endif + +RCFLAGS += --target=$(WTARGET) --target-abi=$(WABITYPE) --cpu=$(WCPU) define WAMR_AOT_COMPILE $(if $(wildcard $(APPDIR)$(DELIM)wasm$(DELIM)*.wo), \