From 8fcc556e50432052db21d8330da2b5da84104925 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 5 Sep 2022 12:12:32 +0800 Subject: [PATCH] ci: Cover more configurations & targets on NuttX (#1448) Enable building iwasm on Nuttx for target: * x86 * cortex-m0 * cortex-m4 * cortex-m7 * rv32imac * rv64imac * rv64gc --- .github/workflows/compilation_on_nuttx.yml | 39 ++++++++++++++++++---- core/iwasm/aot/arch/aot_reloc_thumb.c | 32 +++++++++--------- product-mini/platforms/nuttx/wamr.mk | 4 ++- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/.github/workflows/compilation_on_nuttx.yml b/.github/workflows/compilation_on_nuttx.yml index e248ca42..02392a90 100644 --- a/.github/workflows/compilation_on_nuttx.yml +++ b/.github/workflows/compilation_on_nuttx.yml @@ -43,20 +43,44 @@ jobs: strategy: matrix: nuttx_board_config : [ - "stm32f4discovery:nsh", - "nucleo-h743zi:nsh", - "sabre-6quad:nsh", + # x64 + "boards/sim/sim/sim/configs/nsh", + # cortex-m0 + "boards/arm/rp2040/raspberrypi-pico/configs/nsh", + # cortex-m4 + "boards/arm/stm32/stm32f4discovery/configs/nsh", + # cortex-m7 + "boards/arm/stm32h7/nucleo-h743zi/configs/nsh", + # cortex-a9 + "boards/arm/imx6/sabre-6quad/configs/nsh", + # riscv32imac + "boards/risc-v/qemu-rv/rv-virt/configs/nsh", + # riscv64imac + "boards/risc-v/qemu-rv/rv-virt/configs/nsh64", + # riscv64gc + "boards/risc-v/k210/maix-bit/configs/nsh", ] wamr_config_option: [ "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\n", "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\n", + "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\n", "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\n", "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\n", + "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\n", + "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\n", ] steps: - - name: Install Toolchains - run: sudo apt install -y gcc-arm-none-eabi kconfig-frontends-nox genromfs + - name: Install Utilities + run: sudo apt install -y kconfig-frontends-nox genromfs + + - name: Install ARM Compilers + if: ${{ contains(matrix.nuttx_board_config, 'arm') }} + run: sudo apt install -y gcc-arm-none-eabi + + - name: Install RISC-V Compilers + if: ${{ contains(matrix.nuttx_board_config, 'risc-v') }} + run: sudo apt install -y gcc-riscv64-unknown-elf - name: Checkout NuttX uses: actions/checkout@v3 @@ -77,7 +101,10 @@ jobs: path: apps/interpreters/wamr/wamr - name: Enable WAMR for NuttX - run: find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_CR=y\n${{ matrix.wamr_config_option }}' + run: | + find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_CR=y\n${{ matrix.wamr_config_option }}' + find nuttx/boards/sim -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n' + find nuttx/boards/risc-v -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n' - name: Build run: | diff --git a/core/iwasm/aot/arch/aot_reloc_thumb.c b/core/iwasm/aot/arch/aot_reloc_thumb.c index bfcf4233..627f334b 100644 --- a/core/iwasm/aot/arch/aot_reloc_thumb.c +++ b/core/iwasm/aot/arch/aot_reloc_thumb.c @@ -97,8 +97,24 @@ static SymbolMap target_sym_map[] = { /* clang-format off */ REG_COMMON_SYMBOLS /* compiler-rt symbols that come from compiler(e.g. gcc) */ +#if __ARM_ARCH != 6 REG_SYM(__adddf3), REG_SYM(__addsf3), + REG_SYM(__divdf3), + REG_SYM(__extendsfdf2), + REG_SYM(__fixdfsi), + REG_SYM(__floatsidf), + REG_SYM(__floatsisf), + REG_SYM(__floatunsidf), + REG_SYM(__floatunsisf), + REG_SYM(__muldf3), + REG_SYM(__mulsf3), + REG_SYM(__subdf3), + REG_SYM(__subsf3), + REG_SYM(__truncdfsf2), + REG_SYM(__unorddf2), + REG_SYM(__unordsf2), +#endif /* clang-format on */ REG_SYM(__aeabi_d2iz), REG_SYM(__aeabi_d2lz), @@ -133,26 +149,19 @@ static SymbolMap target_sym_map[] = { REG_SYM(__aeabi_uldivmod), REG_SYM(__ashldi3), REG_SYM(__clzsi2), - REG_SYM(__divdf3), REG_SYM(__divdi3), REG_SYM(__divsi3), REG_SYM(__eqdf2), REG_SYM(__eqsf2), - REG_SYM(__extendsfdf2), REG_SYM(__fixdfdi), - REG_SYM(__fixdfsi), REG_SYM(__fixsfdi), REG_SYM(__fixunsdfdi), REG_SYM(__fixunsdfsi), REG_SYM(__fixunssfdi), REG_SYM(__floatdidf), REG_SYM(__floatdisf), - REG_SYM(__floatsidf), - REG_SYM(__floatsisf), REG_SYM(__floatundidf), REG_SYM(__floatundisf), - REG_SYM(__floatunsidf), - REG_SYM(__floatunsisf), REG_SYM(__gedf2), REG_SYM(__gesf2), REG_SYM(__gtdf2), @@ -164,21 +173,14 @@ static SymbolMap target_sym_map[] = { REG_SYM(__ltsf2), REG_SYM(__moddi3), REG_SYM(__modsi3), - REG_SYM(__muldf3), REG_SYM(__muldi3), - REG_SYM(__mulsf3), REG_SYM(__nedf2), REG_SYM(__nesf2), - REG_SYM(__subdf3), - REG_SYM(__subsf3), - REG_SYM(__truncdfsf2), REG_SYM(__udivdi3), REG_SYM(__udivmoddi4), REG_SYM(__udivsi3), REG_SYM(__umoddi3), REG_SYM(__umodsi3), - REG_SYM(__unorddf2), - REG_SYM(__unordsf2), }; static void @@ -375,7 +377,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, if (error_buf != NULL) snprintf(error_buf, error_buf_size, "Load relocation section failed: " - "invalid relocation type %d.", + "invalid relocation type %" PRId32 ".", reloc_type); return false; } diff --git a/product-mini/platforms/nuttx/wamr.mk b/product-mini/platforms/nuttx/wamr.mk index 36953a67..bebd5f2a 100644 --- a/product-mini/platforms/nuttx/wamr.mk +++ b/product-mini/platforms/nuttx/wamr.mk @@ -5,7 +5,9 @@ CORE_ROOT := wamr/core IWASM_ROOT := wamr/core/iwasm SHARED_ROOT := wamr/core/shared -ifeq ($(CONFIG_ARCH_ARMV7A),y) +ifeq ($(CONFIG_ARCH_ARMV6M),y) +WAMR_BUILD_TARGET := THUMBV6M +else ifeq ($(CONFIG_ARCH_ARMV7A),y) WAMR_BUILD_TARGET := THUMBV7A else ifeq ($(CONFIG_ARCH_ARMV7M),y) WAMR_BUILD_TARGET := THUMBV7EM