Skip to content

Commit 2285bb8

Browse files
committed
riscv32: enable riscv32 JIT for pico2 (hazard3), add it to CI
Signed-off-by: Paul Guyot <[email protected]>
1 parent 80233ac commit 2285bb8

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

.github/workflows/pico-build.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ jobs:
4141
strategy:
4242
matrix:
4343
board: ["pico", "pico_w", "pico2"]
44-
language: ["cpp"]
44+
platform: [""]
45+
jit: ["", "-DAVM_DISABLE_JIT=OFF"]
46+
include:
47+
- board: "pico2"
48+
platform: "-DPICO_PLATFORM=rp2350-riscv"
49+
jit: ""
50+
51+
- board: "pico2"
52+
platform: "-DPICO_PLATFORM=rp2350-riscv"
53+
jit: "-DAVM_DISABLE_JIT=OFF"
4554

4655
steps:
4756
- name: Checkout repo
@@ -57,13 +66,23 @@ jobs:
5766
libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib \
5867
erlang-base erlang-dev erlang-dialyzer erlang-eunit rebar3
5968
69+
- name: Install riscv32 toolchain
70+
if: matrix.platform == '-DPICO_PLATFORM=rp2350-riscv'
71+
run: |
72+
sudo mkdir -p /opt/riscv32-toolchain
73+
cd /opt/riscv32-toolchain
74+
sudo wget -q https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.2.0-3/riscv-toolchain-15-x86_64-lin.tar.gz
75+
sudo tar xzf riscv-toolchain-15-x86_64-lin.tar.gz
76+
sudo rm riscv-toolchain-15-x86_64-lin.tar.gz
77+
echo "/opt/riscv32-toolchain/bin" >> $GITHUB_PATH
78+
6079
- name: "Git config safe.directory for codeql"
6180
run: git config --global --add safe.directory /__w/AtomVM/AtomVM
6281

6382
- name: "Initialize CodeQL"
6483
uses: github/codeql-action/init@v3
6584
with:
66-
languages: ${{matrix.language}}
85+
languages: "cpp"
6786
build-mode: manual
6887
queries: +./code-queries/term-to-non-term-func.ql,./code-queries/non-term-to-term-func.ql
6988

@@ -74,7 +93,7 @@ jobs:
7493
set -euo pipefail
7594
mkdir build
7695
cd build
77-
cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }}
96+
cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }} ${{ matrix.platform }} ${{ matrix.jit }}
7897
ninja
7998
8099
- name: "Perform CodeQL Analysis"
@@ -97,7 +116,7 @@ jobs:
97116
mkdir build.nosmp
98117
cd build.nosmp
99118
# TODO: fix all warnings and enable -DAVM_WARNINGS_ARE_ERRORS=ON
100-
cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }} -DAVM_DISABLE_SMP=1
119+
cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }} ${{ matrix.jit }} -DAVM_DISABLE_SMP=1
101120
cmake --build . --target=rp2_tests
102121
103122
- name: Run tests with rp2040js
@@ -112,7 +131,7 @@ jobs:
112131
npx tsx run-tests.ts ../build.nosmp/tests/rp2_tests.uf2 ../build.nosmp/tests/test_erl_sources/rp2_test_modules.uf2
113132
114133
- name: Build atomvmlib.uf2
115-
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w'
134+
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w' && matrix.platform == '' && matrix.jit == ''
116135
shell: bash
117136
run: |
118137
set -euo pipefail
@@ -122,7 +141,7 @@ jobs:
122141
make atomvmlib-${{ matrix.board }}.uf2
123142
124143
- name: Rename AtomVM and write sha256sum
125-
if: startsWith(github.ref, 'refs/tags/')
144+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == '' && matrix.jit == ''
126145
shell: bash
127146
run: |
128147
pushd src/platforms/rp2/build
@@ -137,7 +156,7 @@ jobs:
137156
popd
138157
139158
- name: Rename atomvmlib and write sha256sum
140-
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w'
159+
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w' && matrix.platform == '' && matrix.jit == ''
141160
shell: bash
142161
run: |
143162
pushd build/libs
@@ -148,7 +167,7 @@ jobs:
148167
149168
- name: Release (Pico & Pico2)
150169
uses: softprops/action-gh-release@v1
151-
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w'
170+
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w' && matrix.platform == '' && matrix.jit == ''
152171
with:
153172
draft: true
154173
fail_on_unmatched_files: true
@@ -160,7 +179,7 @@ jobs:
160179
161180
- name: Release (PicoW)
162181
uses: softprops/action-gh-release@v1
163-
if: startsWith(github.ref, 'refs/tags/') && matrix.board == 'pico_w'
182+
if: startsWith(github.ref, 'refs/tags/') && matrix.board == 'pico_w' && matrix.platform == '' && matrix.jit == ''
164183
with:
165184
draft: true
166185
fail_on_unmatched_files: true

src/platforms/rp2/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^cortex-m.+$")
7171
if (NOT AVM_DISABLE_JIT)
7272
set(AVM_JIT_TARGET_ARCH "armv6m")
7373
endif()
74+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^hazard3$")
75+
# Pico2 RISC-V processor (Hazard3)
76+
if (NOT AVM_DISABLE_JIT)
77+
set(AVM_JIT_TARGET_ARCH "riscv32")
78+
endif()
7479
else()
75-
# Typically riscv is not supported yet
80+
# Other processors not supported yet
7681
if (NOT AVM_DISABLE_JIT)
7782
message("JIT is not supported on ${CMAKE_SYSTEM_PROCESSOR}")
7883
set(AVM_DISABLE_JIT ON CACHE BOOL "Disable just in time compilation." FORCE)

0 commit comments

Comments
 (0)