2022-12-02 04:39:46 +00:00
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name : spec test on nuttx
on :
2023-11-18 01:09:30 +00:00
pull_request :
types :
2023-12-11 01:48:59 +00:00
- opened
- synchronize
paths :
- ".github/workflows/spec_test_on_nuttx.yml"
2024-02-06 12:47:11 +00:00
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
- "wamr-sdk/**"
2022-12-02 04:39:46 +00:00
schedule :
- cron : '0 0 * * *'
workflow_dispatch :
2024-04-24 08:39:38 +00:00
# Note on INTERPRETERS_WAMR_STACK_GUARD_SIZE:
# https://github.com/apache/nuttx-apps/pull/2241 is not included in
# releases/12.4 branch as of writing this.
2022-12-26 06:22:15 +00:00
env :
LLVM_CACHE_SUFFIX : "build-llvm_libraries_ex"
2023-03-07 04:06:38 +00:00
WASI_SDK_PATH : "/opt/wasi-sdk"
2023-11-27 07:24:02 +00:00
WAMR_COMMON_OPTION :
2024-07-26 06:14:04 +00:00
"CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_LOG=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\nCONFIG_INTERPRETERS_WAMR_REF_TYPES=y\\nCONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST=y\\nCONFIG_INTERPRETERS_WAMR_SHARED_MEMORY=y\\nCONFIG_INTERPRETERS_WAMR_BULK_MEMORY=y\\nCONFIG_EOL_IS_LF=y\\nCONFIG_LIBC_FLOATINGPOINT=y\\nCONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE=1024\\n"
HOSTFS_OPTION :
"CONFIG_ARM_SEMIHOSTING_HOSTFS=y\\nCONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE=y\\nCONFIG_RISCV_SEMIHOSTING_HOSTFS=y\\nCONFIG_FS_HOSTFS=y\\n"
2022-12-26 06:22:15 +00:00
2022-12-02 04:39:46 +00:00
jobs :
2022-12-26 06:22:15 +00:00
build_llvm_libraries :
uses : ./.github/workflows/build_llvm_libraries.yml
with :
2023-02-02 01:42:25 +00:00
os : "ubuntu-22.04"
arch : "ARM RISCV AArch64"
2024-02-06 12:47:11 +00:00
container_image : ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
2022-12-26 06:22:15 +00:00
2024-07-18 05:51:16 +00:00
build_llvm_libraries_xtensa :
uses : ./.github/workflows/build_llvm_libraries.yml
with :
os : "ubuntu-22.04"
arch : "Xtensa"
extra_build_llvm_options : "--platform xtensa"
cache_key_suffix : "-xtensa"
container_image : ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
2022-12-02 04:39:46 +00:00
spec_test_on_qemu :
2023-12-11 01:48:59 +00:00
runs-on : ubuntu-latest
2024-07-26 06:14:04 +00:00
needs : [ build_llvm_libraries, build_llvm_libraries_xtensa]
2023-12-11 01:48:59 +00:00
container :
2024-02-06 12:47:11 +00:00
image : ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
2022-12-02 04:39:46 +00:00
strategy :
matrix :
2023-11-27 07:24:02 +00:00
target_config : [
# {
# config: "boards/arm64/qemu/qemu-armv8a/configs/nsh",
# target: "aarch64_vfp",
2023-12-04 10:57:18 +00:00
# fpu_type: "fp"
2023-11-27 07:24:02 +00:00
# },
# {
# config: "boards/arm/imx6/sabre-6quad/configs/nsh",
# target: "thumbv7",
2023-12-04 10:57:18 +00:00
# fpu_type: "none"
2023-11-27 07:24:02 +00:00
# },
{
config : "boards/arm/imx6/sabre-6quad/configs/nsh" ,
target : "thumbv7_vfp" ,
2023-12-04 10:57:18 +00:00
fpu_type : "dp"
2023-11-27 07:24:02 +00:00
},
{
config : "boards/risc-v/qemu-rv/rv-virt/configs/nsh" ,
target : "riscv32" ,
2023-12-04 10:57:18 +00:00
fpu_type : "none"
2023-11-27 07:24:02 +00:00
},
# {
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# target: "riscv32_ilp32d",
2023-12-04 10:57:18 +00:00
# fpu_type: "dp"
2023-11-27 07:24:02 +00:00
# },
2023-12-04 06:22:47 +00:00
{
config : "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" ,
target : "riscv64" ,
2023-12-04 10:57:18 +00:00
fpu_type : "none"
2023-12-04 06:22:47 +00:00
},
2024-07-26 06:14:04 +00:00
{
config : "boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_debug" ,
target : "xtensa" ,
fpu_type : "none"
},
2022-12-02 04:39:46 +00:00
]
2023-11-27 07:24:02 +00:00
2022-12-02 04:39:46 +00:00
wamr_test_option : [
2023-11-27 07:24:02 +00:00
{
mode : "-t aot" ,
option : "CONFIG_INTERPRETERS_WAMR_AOT=y\\n"
},
2024-07-27 07:31:31 +00:00
{
mode : "-t aot -X" ,
option : "CONFIG_INTERPRETERS_WAMR_AOT=y\\n"
},
2024-02-06 12:47:11 +00:00
# {
# mode: "-t classic-interp",
# option: "CONFIG_INTERPRETERS_WAMR_CLASSIC=y\\n"
# },
# {
# mode: "-t fast-interp",
# option: "CONFIG_INTERPRETERS_WAMR_FAST=y\\n"
# },
2022-12-02 04:39:46 +00:00
]
2023-11-27 07:24:02 +00:00
2024-02-06 12:47:11 +00:00
wamr_feature_option :
# Empty option for default
- { option : "" , mode : "" }
- { option : "CONFIG_INTERPRETERS_WAMR_GC=y\\nCONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME=y\\n" , mode : "-G" }
2023-12-04 06:22:47 +00:00
exclude :
# XIP is not fully supported yet on RISCV64, some relocations can not be resolved
- target_config : { config : "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" }
wamr_test_option : { mode : "-t aot -X" }
2024-07-26 06:14:04 +00:00
# Our xtensa environment doesn't have enough memory
- target_config : { target : "xtensa" }
wamr_feature_option : { mode : "-G" }
2022-12-02 04:39:46 +00:00
steps :
2024-07-26 06:14:04 +00:00
# Note: we use an unreleased version nuttx for xtensa because
# 12.4 doesn't contain necessary esp32s3 changes.
2022-12-02 04:39:46 +00:00
- name : Checkout NuttX
2024-01-26 23:55:49 +00:00
uses : actions/checkout@v4
2022-12-02 04:39:46 +00:00
with :
2024-05-31 07:39:23 +00:00
repository : apache/nuttx
2024-07-26 06:14:04 +00:00
ref : ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.4' }}
2022-12-02 04:39:46 +00:00
path : nuttx
- name : Checkout NuttX Apps
2024-01-26 23:55:49 +00:00
uses : actions/checkout@v4
2022-12-02 04:39:46 +00:00
with :
2024-05-31 07:39:23 +00:00
repository : apache/nuttx-apps
2024-07-26 06:14:04 +00:00
ref : ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.4' }}
2022-12-02 04:39:46 +00:00
path : apps
- name : Checkout WAMR
2024-01-26 23:55:49 +00:00
uses : actions/checkout@v4
2022-12-02 04:39:46 +00:00
with :
repository : ${{ github.repository }}
path : apps/interpreters/wamr/wamr
2022-12-26 06:22:15 +00:00
- name : Get LLVM libraries
2023-11-27 07:24:02 +00:00
if : contains(matrix.wamr_test_option.mode, 'aot')
2023-02-02 01:42:25 +00:00
id : retrieve_llvm_libs
2024-01-26 23:55:49 +00:00
uses : actions/cache@v4
2022-12-26 06:22:15 +00:00
with :
path : |
./core/deps/llvm/build/bin
./core/deps/llvm/build/include
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
2024-07-26 06:14:04 +00:00
key : ${{ matrix.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
2022-12-26 06:22:15 +00:00
- name : Quit if cache miss
2023-11-27 07:24:02 +00:00
if : contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
2022-12-26 06:22:15 +00:00
run : echo "::error::can not get prebuilt llvm libraries" && exit 1
- name : Copy LLVM
2023-11-27 07:24:02 +00:00
if : contains(matrix.wamr_test_option.mode, 'aot')
2022-12-26 06:22:15 +00:00
run : cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
2024-02-06 12:47:11 +00:00
# Inject the config option to NuttX
# TODO: Merge this into NuttX once GC is generally available
2024-07-26 06:14:04 +00:00
#
# Note: the version of nuttx-apps we use for xtensa does have
# an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
# different though.)
2024-02-06 12:47:11 +00:00
- name : Modify Kconfig
2024-07-26 06:14:04 +00:00
if : matrix.target_config.target != 'xtensa'
2024-02-06 12:47:11 +00:00
run : |
echo "\n" >> apps/interpreters/wamr/Kconfig
echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
echo "\n" >> apps/interpreters/wamr/Kconfig
echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig
echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
echo "\n" >> apps/interpreters/wamr/Kconfig
echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig
echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig
echo "\tdefault y" >> apps/interpreters/wamr/Kconfig
2022-12-02 04:39:46 +00:00
- name : Enable WAMR for NuttX
run : |
2023-11-27 07:24:02 +00:00
find nuttx/boards -name defconfig | xargs sed -i '$a\${{ env.WAMR_COMMON_OPTION }}'
2024-07-26 06:14:04 +00:00
- name : Set WAMR stack size for NuttX
if : matrix.target_config.target != 'xtensa'
run : |
find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_STACKSIZE=327680\n'
# because qemu doesn't have a proper emulation of esp32s3 psram,
# we are limited to the internal ram, which is about 400KB.
- name : Set WAMR stack size for NuttX (xtensa)
if : matrix.target_config.target == 'xtensa'
run : |
find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_STACKSIZE=25600\n'
# Note: the nuttx config we happened to use for xtensa already has
# hostfs enabled.
- name : Enable hostfs for NuttX
if : matrix.target_config.target != 'xtensa'
run : |
find nuttx/boards -name defconfig | xargs sed -i '$a\${{ env.HOSTFS_OPTION }}'
2023-11-27 07:24:02 +00:00
- name : Enable WAMR Interpreter for NuttX
run : |
find nuttx/boards -name defconfig | xargs sed -i '$a\${{ matrix.wamr_test_option.option }}'
2022-12-02 04:39:46 +00:00
2024-02-06 12:47:11 +00:00
- name : Enable WAMR Feature for NuttX
if : matrix.wamr_feature_option.option != ''
run : |
find nuttx/boards -name defconfig | xargs sed -i '$a\${{ matrix.wamr_feature_option.option }}'
2023-11-27 07:24:02 +00:00
- name : Disable FPU for NuttX
2023-12-04 10:57:18 +00:00
if : matrix.target_config.fpu_type == 'none'
2023-11-18 01:09:30 +00:00
run : |
find nuttx/boards -name defconfig | xargs sed -i '$a\# CONFIG_ARCH_FPU is not set\n'
2023-12-04 10:57:18 +00:00
- name : Disable DPFPU for NuttX
if : matrix.target_config.fpu_type == 'fp'
run : |
find nuttx/boards -name defconfig | xargs sed -i '$a\# CONFIG_ARCH_DPFPU is not set\n'
2024-07-26 06:14:04 +00:00
# Note: while a real hardware would need
# INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
# it doesn't work with xtensa qemu which we use on the CI because it
# doesn't have a proper emulation of I/D separate mappings.
# we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
# this configuration won't work on a real hardware.
- name : Tweak NuttX config (xtensa)
if : matrix.target_config.target == 'xtensa'
run : |
find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ=y\n\# CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR is not set\n'
2022-12-02 04:39:46 +00:00
- name : Build wamrc
2023-11-27 07:24:02 +00:00
if : contains(matrix.wamr_test_option.mode, 'aot')
2022-12-02 04:39:46 +00:00
working-directory : apps/interpreters/wamr/wamr/wamr-compiler
run : |
2022-12-26 06:22:15 +00:00
cmake -Bbuild .
2022-12-02 04:39:46 +00:00
cmake --build build
2024-07-26 06:14:04 +00:00
# the nuttx version we use for xtensa requires esptool.py newer than
# what we have in our version of the apache-nuttx-ci-linux image.
- name : Install the latest esptool.py (xtensa)
if : matrix.target_config.target == 'xtensa'
run : |
pip3 install esptool==4.7.0
esptool.py version
- name : Configure NuttX
2022-12-02 04:39:46 +00:00
run : |
2023-11-27 07:24:02 +00:00
tools/configure.sh ${{ matrix.target_config.config }}
2024-07-26 06:14:04 +00:00
working-directory : nuttx
# depending on configurations, the iwasm command line generated
# by spec-test-script can be longer than the default NSH_LINELEN,
# which is 64 or 80.
- name : Tweak NuttX config
run : |
kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
working-directory : nuttx
- name : Build NuttX
run : |
make olddefconfig
2022-12-02 04:39:46 +00:00
make -j$(nproc)
2024-07-26 06:14:04 +00:00
working-directory : nuttx
# for xtensa, build a 8MB firmware image.
# simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
# qemu will infer the flash size from the file size.
- name : Post build processing (xtensa)
if : matrix.target_config.target == 'xtensa'
run : |
cd nuttx
dd if=/dev/zero of=flash.img bs=1024 count=8192
dd if=nuttx.bin of=flash.img conv=notrunc
mv flash.img nuttx
- name : Build firmware path
id : build_firmware_path
run : |
echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
2023-11-27 07:24:02 +00:00
2024-07-26 06:14:04 +00:00
# for xtensa, use the espressif fork of qemu, which has esp32s3 support.
- name : Install QEMU (xtensa)
if : matrix.target_config.target == 'xtensa'
run : |
apt-get remove -y qemu-system-misc
apt-get update && apt-get install -y libsdl2-2.0-0
./.github/scripts/install_qemu_xtensa.sh
qemu-system-xtensa --version
working-directory : apps/interpreters/wamr/wamr
- name : Test
if : matrix.target_config.target != 'xtensa'
run : |
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -P -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
# for xtensa, for some reasons, when running the tests
# with test_wamr.sh -P, nuttx occasionally hangs after
# "total segments stored 6" on the CI.
# i (yamamoto) couldn't reproduce it locally (macOS) even
# with the identical flash image.
# for now, run the tests without -P.
2023-11-27 07:24:02 +00:00
- name : Test
2024-07-26 06:14:04 +00:00
if : matrix.target_config.target == 'xtensa'
2022-12-02 04:39:46 +00:00
run : |
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
2024-07-26 06:14:04 +00:00
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}