Skip to content

Commit 42e769c

Browse files
authored
Merge pull request #363 from etr/feature/arm-cross-compilation
Add ARM cross-compilation to GitHub Actions CI
2 parents 3be9e7c + 37d31d1 commit 42e769c

File tree

1 file changed

+83
-9
lines changed

1 file changed

+83
-9
lines changed

.github/workflows/verify-build.yml

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,30 @@ jobs:
334334
debug: nodebug
335335
coverage: nocoverage
336336
linking: dynamic
337+
# ARM 32-bit cross-compilation (ARMv7 hard-float)
338+
- test-group: cross-compile
339+
os: ubuntu-latest
340+
os-type: ubuntu
341+
build-type: arm32
342+
compiler-family: arm-cross
343+
c-compiler: arm-linux-gnueabihf-gcc
344+
cc-compiler: arm-linux-gnueabihf-g++
345+
debug: nodebug
346+
coverage: nocoverage
347+
linking: dynamic
348+
shell: bash
349+
# ARM 64-bit cross-compilation (AArch64)
350+
- test-group: cross-compile
351+
os: ubuntu-latest
352+
os-type: ubuntu
353+
build-type: arm64
354+
compiler-family: arm-cross
355+
c-compiler: aarch64-linux-gnu-gcc
356+
cc-compiler: aarch64-linux-gnu-g++
357+
debug: nodebug
358+
coverage: nocoverage
359+
linking: dynamic
360+
shell: bash
337361
steps:
338362
- name: Checkout repository
339363
uses: actions/checkout@v4
@@ -386,6 +410,16 @@ jobs:
386410
run: sudo apt-get install ${{ matrix.cc-compiler }}
387411
if: ${{ matrix.compiler-family == 'gcc' && matrix.os-type == 'ubuntu' }}
388412

413+
- name: Install ARM cross-compilation toolchain
414+
run: |
415+
sudo apt-get update
416+
if [ "${{ matrix.build-type }}" = "arm32" ]; then
417+
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
418+
elif [ "${{ matrix.build-type }}" = "arm64" ]; then
419+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
420+
fi
421+
if: ${{ matrix.compiler-family == 'arm-cross' }}
422+
389423
- name: Install valgrind if needed
390424
run: sudo apt-get install valgrind
391425
if: ${{ matrix.build-type == 'valgrind' && matrix.os-type == 'ubuntu' }}
@@ -479,7 +513,7 @@ jobs:
479513
with:
480514
path: libmicrohttpd-0.9.77
481515
key: ${{ matrix.os }}-${{ matrix.c-compiler }}-libmicrohttpd-0.9.77-pre-built
482-
if: ${{ matrix.os-type != 'windows' && matrix.build-type != 'no-dauth' }}
516+
if: ${{ matrix.os-type != 'windows' && matrix.build-type != 'no-dauth' && matrix.compiler-family != 'arm-cross' }}
483517

484518
- name: Build libmicrohttpd dependency (if not cached)
485519
run: |
@@ -488,7 +522,7 @@ jobs:
488522
cd libmicrohttpd-0.9.77 ;
489523
./configure --disable-examples ;
490524
make ;
491-
if: ${{ matrix.os-type != 'windows' && matrix.build-type != 'no-dauth' && steps.cache-libmicrohttpd.outputs.cache-hit != 'true' }}
525+
if: ${{ matrix.os-type != 'windows' && matrix.build-type != 'no-dauth' && matrix.compiler-family != 'arm-cross' && steps.cache-libmicrohttpd.outputs.cache-hit != 'true' }}
492526

493527
- name: Build libmicrohttpd without digest auth (no-dauth test)
494528
run: |
@@ -501,7 +535,7 @@ jobs:
501535

502536
- name: Install libmicrohttpd
503537
run: cd libmicrohttpd-0.9.77 ; sudo make install ;
504-
if: ${{ matrix.os-type != 'windows' }}
538+
if: ${{ matrix.os-type != 'windows' && matrix.compiler-family != 'arm-cross' }}
505539

506540
- name: Verify digest auth is disabled (no-dauth test)
507541
run: |
@@ -522,7 +556,38 @@ jobs:
522556
./configure --disable-examples --enable-poll=no
523557
make
524558
make install
525-
559+
560+
- name: Fetch libmicrohttpd from cache (ARM cross-compile)
561+
id: cache-libmicrohttpd-arm
562+
uses: actions/cache@v4
563+
with:
564+
path: libmicrohttpd-0.9.77-${{ matrix.build-type }}
565+
key: ${{ matrix.os }}-${{ matrix.build-type }}-libmicrohttpd-0.9.77-cross-compiled
566+
if: ${{ matrix.compiler-family == 'arm-cross' }}
567+
568+
- name: Cross-compile libmicrohttpd for ARM
569+
run: |
570+
curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.77.tar.gz -o libmicrohttpd-0.9.77.tar.gz
571+
tar -xzf libmicrohttpd-0.9.77.tar.gz
572+
mv libmicrohttpd-0.9.77 libmicrohttpd-0.9.77-${{ matrix.build-type }}
573+
cd libmicrohttpd-0.9.77-${{ matrix.build-type }}
574+
mkdir -p ${{ github.workspace }}/arm-sysroot
575+
if [ "${{ matrix.build-type }}" = "arm32" ]; then
576+
./configure --host=arm-linux-gnueabihf --prefix=${{ github.workspace }}/arm-sysroot --disable-examples --disable-doc
577+
else
578+
./configure --host=aarch64-linux-gnu --prefix=${{ github.workspace }}/arm-sysroot --disable-examples --disable-doc
579+
fi
580+
make
581+
make install
582+
if: ${{ matrix.compiler-family == 'arm-cross' && steps.cache-libmicrohttpd-arm.outputs.cache-hit != 'true' }}
583+
584+
- name: Install cross-compiled libmicrohttpd from cache
585+
run: |
586+
cd libmicrohttpd-0.9.77-${{ matrix.build-type }}
587+
mkdir -p ${{ github.workspace }}/arm-sysroot
588+
make install
589+
if: ${{ matrix.compiler-family == 'arm-cross' && steps.cache-libmicrohttpd-arm.outputs.cache-hit == 'true' }}
590+
526591
- name: Refresh links to shared libs
527592
run: sudo ldconfig ;
528593
if: ${{ matrix.os-type == 'ubuntu' }}
@@ -549,7 +614,16 @@ jobs:
549614
./bootstrap ;
550615
mkdir build ;
551616
cd build ;
552-
if [ "$LINKING" = "static" ]; then
617+
if [ "${{ matrix.compiler-family }}" = "arm-cross" ]; then
618+
export CPPFLAGS="-I${{ github.workspace }}/arm-sysroot/include"
619+
export LDFLAGS="-L${{ github.workspace }}/arm-sysroot/lib"
620+
export PKG_CONFIG_PATH="${{ github.workspace }}/arm-sysroot/lib/pkgconfig"
621+
if [ "${{ matrix.build-type }}" = "arm32" ]; then
622+
../configure --host=arm-linux-gnueabihf --disable-fastopen;
623+
else
624+
../configure --host=aarch64-linux-gnu --disable-fastopen;
625+
fi
626+
elif [ "$LINKING" = "static" ]; then
553627
../configure --enable-static --disable-fastopen;
554628
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
555629
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
@@ -611,14 +685,14 @@ jobs:
611685
run: |
612686
cd build ;
613687
make check;
614-
if: ${{ matrix.build-type != 'iwyu' }}
615-
688+
if: ${{ matrix.build-type != 'iwyu' && matrix.compiler-family != 'arm-cross' }}
689+
616690
- name: Print tests results
617691
shell: bash
618692
run: |
619693
cd build ;
620694
cat test/test-suite.log ;
621-
if: ${{ failure() && matrix.build-type != 'iwyu' }}
695+
if: ${{ failure() && matrix.build-type != 'iwyu' && matrix.compiler-family != 'arm-cross' }}
622696

623697
- name: Run Valgrind checks
624698
run: |
@@ -639,7 +713,7 @@ jobs:
639713
run: |
640714
cd src/ ;
641715
cppcheck --error-exitcode=1 . ;
642-
if: ${{ matrix.os-type == 'ubuntu' }}
716+
if: ${{ matrix.os-type == 'ubuntu' && matrix.compiler-family != 'arm-cross' }}
643717

644718
- name: Run performance tests (select)
645719
run: |

0 commit comments

Comments
 (0)