Skip to content

Commit 38234de

Browse files
committed
Cross compile for armhf and s390x architectures
Also enable parallel compilation (make -j3) and fix circular dependency when building precompiled archives Signed-off-by: Paul Guyot <[email protected]>
1 parent 8480a7a commit 38234de

File tree

3 files changed

+159
-30
lines changed

3 files changed

+159
-30
lines changed

.github/workflows/build-and-test-other.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
arch: ["arm32v5", "arm32v7"]
73+
arch: ["arm32v5"]
7474

7575
include:
7676
- arch: "arm32v5"
@@ -92,21 +92,6 @@ jobs:
9292
apt install -y -t stretch-backports cmake &&
9393
apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev
9494
95-
- arch: "arm32v7"
96-
platform: "arm/v7"
97-
tag: "bookworm"
98-
# -D_FILE_OFFSET_BITS=64 is required for making atomvm:posix_readdir/1 test work
99-
# otherwise readdir will fail due to 64 bits inode numbers with 32 bit ino_t
100-
cflags: "-mcpu=cortex-a7 -mfloat-abi=hard -O2 -mthumb -mthumb-interwork -D_FILE_OFFSET_BITS=64"
101-
cmake_opts: "-DAVM_WARNINGS_ARE_ERRORS=ON"
102-
103-
# Required for testing big endian archs
104-
- arch: "s390x"
105-
platform: "s390x"
106-
tag: "bookworm"
107-
cflags: "-O2"
108-
cmake_opts: "-DAVM_WARNINGS_ARE_ERRORS=ON"
109-
11095
steps:
11196
- name: Checkout repo
11297
uses: actions/checkout@v4

.github/workflows/build-and-test.yaml

Lines changed: 148 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,36 @@ jobs:
321321
cmake_opts_other: "-DAVM_DISABLE_JIT=OFF"
322322
jit_target_arch: "aarch64"
323323

324+
# armhf build
325+
- os: "ubuntu-24.04"
326+
cc: "arm-linux-gnueabihf-gcc"
327+
cxx: "arm-linux-gnueabihf-g++"
328+
# -D_FILE_OFFSET_BITS=64 is required for making atomvm:posix_readdir/1 test work
329+
# otherwise readdir will fail due to 64 bits inode numbers with 32 bit ino_t
330+
cflags: "-mcpu=cortex-a7 -mfloat-abi=hard -O2 -mthumb -mthumb-interwork -D_FILE_OFFSET_BITS=64"
331+
otp: "28"
332+
elixir_version: "1.17"
333+
rebar3_version: "3.24.0"
334+
cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON -DCMAKE_TOOLCHAIN_FILE=${RUNNER_TEMP}/armhf_toolchain.cmake"
335+
compiler_pkgs: "crossbuild-essential-armhf libc6-dbg:armhf zlib1g-dev:armhf libmbedtls-dev:armhf qemu-user qemu-user-binfmt binfmt-support"
336+
arch: "armhf"
337+
library-arch: arm-linux-gnueabihf
338+
339+
# s390x build
340+
- os: "ubuntu-24.04"
341+
cc: "s390x-linux-gnu-gcc"
342+
cxx: "s390x-linux-gnu-g++"
343+
# -D_FILE_OFFSET_BITS=64 is required for making atomvm:posix_readdir/1 test work
344+
# otherwise readdir will fail due to 64 bits inode numbers with 32 bit ino_t
345+
cflags: "-O2"
346+
otp: "28"
347+
elixir_version: "1.17"
348+
rebar3_version: "3.24.0"
349+
cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON -DCMAKE_TOOLCHAIN_FILE=${RUNNER_TEMP}/s390x_toolchain.cmake"
350+
compiler_pkgs: "crossbuild-essential-s390x libc6-dbg:s390x zlib1g-dev:s390x libmbedtls-dev:s390x qemu-user qemu-user-binfmt binfmt-support"
351+
arch: "s390x"
352+
library-arch: s390x-linux-gnu
353+
324354
env:
325355
ImageOS: ${{ matrix.container == 'ubuntu:20.04' && 'ubuntu20' || matrix.os == 'ubuntu-20.04' && 'ubuntu20' || matrix.os == 'ubuntu-22.04' && 'ubuntu22' || matrix.os == 'ubuntu-24.04' && 'ubuntu24' || 'ubuntu24' }}
326356
CC: ${{ matrix.cc }}
@@ -340,6 +370,32 @@ jobs:
340370
if: matrix.arch == 'i386'
341371
run: sudo dpkg --add-architecture i386
342372

373+
- name: "Setup cross compilation architecture"
374+
if: matrix.library-arch != ''
375+
run: |
376+
sudo dpkg --add-architecture ${{ matrix.arch }}
377+
cat > ${RUNNER_TEMP}/cross-compile-sources.list <<EOF
378+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble main restricted
379+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble-updates main restricted
380+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble universe
381+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble-updates universe
382+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble multiverse
383+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble-updates multiverse
384+
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ noble-backports main restricted universe multiverse
385+
EOF
386+
sudo mv ${RUNNER_TEMP}/cross-compile-sources.list /etc/apt/sources.list.d/
387+
388+
sudo sed -i '/Types: deb/a Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources
389+
390+
cat > ${RUNNER_TEMP}/${{ matrix.arch }}_toolchain.cmake <<EOF
391+
set(CMAKE_SYSTEM_NAME Linux)
392+
set(CMAKE_C_LIBRARY_ARCHITECTURE ${{ matrix.library-arch }})
393+
394+
set(ZLIB_LIBRARY /usr/lib/${{ matrix.library-arch }}/libz.so)
395+
set(MBEDTLS_ROOT_DIR /usr)
396+
set(MBEDTLS_LIBRARIES_DIR /usr/lib/${{ matrix.library-arch }})
397+
EOF
398+
343399
- name: "APT update"
344400
run: sudo apt update -y
345401

@@ -407,99 +463,178 @@ jobs:
407463
408464
- name: "Build: run make"
409465
working-directory: build
410-
run: make
466+
run: make -j3
411467

412468
- name: "Build: run dialyzer"
413469
working-directory: build
414470
run: make dialyzer
415471

416472
# Test
417-
- name: "Test: test-erlang"
473+
- name: "Test: test-erlang with valgrind"
474+
if: matrix.library-arch == ''
418475
timeout-minutes: 30
419476
working-directory: build
420477
run: |
421478
ulimit -c unlimited
422479
valgrind --error-exitcode=1 ./tests/test-erlang -s prime_smp
480+
481+
- name: "Test: test-erlang"
482+
timeout-minutes: 10
483+
working-directory: build
484+
run: |
485+
ulimit -c unlimited
423486
./tests/test-erlang -s prime_smp
424487
425-
- name: "Test: test-enif"
488+
- name: "Test: test-enif with valgrind"
489+
if: matrix.library-arch == ''
426490
working-directory: build
427491
run: |
428492
ulimit -c unlimited
429493
valgrind --error-exitcode=1 ./tests/test-enif
494+
495+
- name: "Test: test-enif"
496+
working-directory: build
497+
run: |
498+
ulimit -c unlimited
430499
./tests/test-enif
431500
432-
- name: "Test: test-heap"
501+
- name: "Test: test-heap with valgrind"
502+
if: matrix.library-arch == ''
433503
working-directory: build
434504
run: |
435505
ulimit -c unlimited
436506
valgrind --error-exitcode=1 ./tests/test-heap
507+
508+
- name: "Test: test-heap"
509+
working-directory: build
510+
run: |
511+
ulimit -c unlimited
437512
./tests/test-heap
438513
439-
- name: "Test: test-mailbox"
514+
- name: "Test: test-mailbox with valgrind"
515+
if: matrix.library-arch == ''
440516
working-directory: build
441517
run: |
442518
ulimit -c unlimited
443519
valgrind --error-exitcode=1 ./tests/test-mailbox
520+
521+
- name: "Test: test-mailbox"
522+
working-directory: build
523+
run: |
524+
ulimit -c unlimited
444525
./tests/test-mailbox
445526
446-
- name: "Test: test-structs"
527+
- name: "Test: test-structs with valgrind"
528+
if: matrix.library-arch == ''
447529
timeout-minutes: 10
448530
working-directory: build
449531
run: |
450532
ulimit -c unlimited
451533
valgrind --error-exitcode=1 ./tests/test-structs
534+
535+
- name: "Test: test-structs"
536+
timeout-minutes: 10
537+
working-directory: build
538+
run: |
539+
ulimit -c unlimited
452540
./tests/test-structs
453541
542+
- name: "Test: test_etest.avm with valgrind"
543+
if: matrix.library-arch == ''
544+
timeout-minutes: 5
545+
working-directory: build
546+
run: |
547+
ulimit -c unlimited
548+
valgrind ./src/AtomVM ./tests/libs/etest/test_etest.avm
549+
454550
- name: "Test: test_etest.avm"
455551
timeout-minutes: 5
456552
working-directory: build
457553
run: |
458554
ulimit -c unlimited
459555
./src/AtomVM ./tests/libs/etest/test_etest.avm
460-
valgrind ./src/AtomVM ./tests/libs/etest/test_etest.avm
461556
462-
- name: "Test: test_estdlib.avm"
557+
- name: "Test: test_estdlib.avm with valgrind"
558+
if: matrix.library-arch == ''
463559
timeout-minutes: 30
464560
working-directory: build
465561
run: |
466562
ulimit -c unlimited
467563
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
564+
565+
- name: "Test: test_estdlib.avm"
566+
timeout-minutes: 20
567+
working-directory: build
568+
run: |
569+
ulimit -c unlimited
468570
./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
469571
470-
- name: "Test: test_eavmlib.avm"
572+
- name: "Test: test_eavmlib.avm with valgrind"
573+
if: matrix.library-arch == ''
471574
timeout-minutes: 10
472575
working-directory: build
473576
run: |
474577
ulimit -c unlimited
475578
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm
579+
580+
- name: "Test: test_eavmlib.avm"
581+
timeout-minutes: 10
582+
working-directory: build
583+
run: |
584+
ulimit -c unlimited
476585
./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm
477586
478-
- name: "Test: test_jit.avm"
587+
- name: "Test: test_jit.avm with valgrind"
588+
if: matrix.library-arch == '' && matrix.otp != '21' && matrix.otp != '22'
479589
timeout-minutes: 30
480-
if: matrix.otp != '21' && matrix.otp != '22'
481590
working-directory: build
482591
run: |
483592
ulimit -c unlimited
484593
valgrind --error-exitcode=1 ./src/AtomVM tests/libs/jit/test_jit.avm
594+
595+
- name: "Test: test_jit.avm"
596+
timeout-minutes: 20
597+
if: matrix.otp != '21' && matrix.otp != '22'
598+
working-directory: build
599+
run: |
600+
ulimit -c unlimited
485601
./src/AtomVM tests/libs/jit/test_jit.avm
486602
603+
- name: "Test: test_alisp.avm with valgrind"
604+
if: matrix.library-arch == ''
605+
timeout-minutes: 20
606+
working-directory: build
607+
run: |
608+
ulimit -c unlimited
609+
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/alisp/test_alisp.avm
610+
487611
- name: "Test: test_alisp.avm"
488612
timeout-minutes: 10
489613
working-directory: build
490614
run: |
491615
ulimit -c unlimited
492-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/alisp/test_alisp.avm
493616
./src/AtomVM ./tests/libs/alisp/test_alisp.avm
494617
618+
- name: "Test: Tests.avm (Elixir) with valgrind"
619+
if: matrix.library-arch == ''
620+
timeout-minutes: 20
621+
working-directory: build
622+
run: |
623+
ulimit -c unlimited
624+
if command -v elixirc >/dev/null 2>&1 && command -v elixir >/dev/null 2>&1
625+
then
626+
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/exavmlib/Tests.avm
627+
else
628+
echo "Elixir not installed, skipping Elixir tests"
629+
fi
630+
495631
- name: "Test: Tests.avm (Elixir)"
496632
timeout-minutes: 10
497633
working-directory: build
498634
run: |
499635
ulimit -c unlimited
500636
if command -v elixirc >/dev/null 2>&1 && command -v elixir >/dev/null 2>&1
501637
then
502-
valgrind --error-exitcode=1 ./src/AtomVM ./tests/libs/exavmlib/Tests.avm
503638
./src/AtomVM ./tests/libs/exavmlib/Tests.avm
504639
else
505640
echo "Elixir not installed, skipping Elixir tests"

CMakeModules/BuildErlang.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ macro(pack_archive avm_name)
5353
COMMENT "Packing archive ${avm_name}.avm"
5454
VERBATIM
5555
)
56+
# Create emu target for source beams only
5657
add_custom_target(
57-
${avm_name} ALL
58+
${avm_name}_emu
5859
DEPENDS ${avm_name}.avm
5960
)
61+
# Create main target (will be updated by pack_precompiled_archive if needed)
62+
add_custom_target(
63+
${avm_name} ALL
64+
DEPENDS ${avm_name}_emu
65+
)
6066
endmacro()
6167

6268
macro(pack_precompiled_archive avm_name)
@@ -110,6 +116,9 @@ macro(pack_precompiled_archive avm_name)
110116
${avm_name}_${jit_target_arch} ALL
111117
DEPENDS ${avm_name}-${jit_target_arch}.avm
112118
)
119+
# Ensure source beams are built before precompilation
120+
add_dependencies(${avm_name}_${jit_target_arch} ${avm_name}_emu)
121+
# Make main target depend on precompiled targets
113122
add_dependencies(${avm_name} ${avm_name}_${jit_target_arch})
114123
endforeach()
115124
endif()

0 commit comments

Comments
 (0)