Skip to content

Commit d235f39

Browse files
committed
Add ARM cross-compilation to GitHub Actions CI
Add ARM32 (ARMv7 hard-float) and ARM64 (AArch64) cross-compilation testing to the CI workflow. This validates that libhttpserver can be built for ARM targets using cross-compilation toolchains. Changes: - Add arm32 and arm64 matrix entries with appropriate toolchains - Add step to install ARM cross-compilation toolchains - Add separate libmicrohttpd cross-compilation steps with caching - Update configure step to use --host flag for cross-compilation - Skip tests and cppcheck for cross-compilation builds (binaries cannot execute on x86_64 runners) The existing COND_CROSS_COMPILE logic in configure.ac automatically handles test exclusion during cross-compilation. Closes #131
1 parent 3be9e7c commit d235f39

File tree

1 file changed

+77
-9
lines changed

1 file changed

+77
-9
lines changed

.github/workflows/verify-build.yml

Lines changed: 77 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,35 @@ 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+
if [ "${{ matrix.build-type }}" = "arm32" ]; then
575+
./configure --host=arm-linux-gnueabihf --disable-examples --disable-doc
576+
else
577+
./configure --host=aarch64-linux-gnu --disable-examples --disable-doc
578+
fi
579+
make
580+
if: ${{ matrix.compiler-family == 'arm-cross' && steps.cache-libmicrohttpd-arm.outputs.cache-hit != 'true' }}
581+
582+
- name: Install cross-compiled libmicrohttpd
583+
run: |
584+
cd libmicrohttpd-0.9.77-${{ matrix.build-type }}
585+
sudo make install
586+
if: ${{ matrix.compiler-family == 'arm-cross' }}
587+
526588
- name: Refresh links to shared libs
527589
run: sudo ldconfig ;
528590
if: ${{ matrix.os-type == 'ubuntu' }}
@@ -549,7 +611,13 @@ jobs:
549611
./bootstrap ;
550612
mkdir build ;
551613
cd build ;
552-
if [ "$LINKING" = "static" ]; then
614+
if [ "${{ matrix.compiler-family }}" = "arm-cross" ]; then
615+
if [ "${{ matrix.build-type }}" = "arm32" ]; then
616+
../configure --host=arm-linux-gnueabihf --disable-fastopen;
617+
else
618+
../configure --host=aarch64-linux-gnu --disable-fastopen;
619+
fi
620+
elif [ "$LINKING" = "static" ]; then
553621
../configure --enable-static --disable-fastopen;
554622
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
555623
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
@@ -611,14 +679,14 @@ jobs:
611679
run: |
612680
cd build ;
613681
make check;
614-
if: ${{ matrix.build-type != 'iwyu' }}
615-
682+
if: ${{ matrix.build-type != 'iwyu' && matrix.compiler-family != 'arm-cross' }}
683+
616684
- name: Print tests results
617685
shell: bash
618686
run: |
619687
cd build ;
620688
cat test/test-suite.log ;
621-
if: ${{ failure() && matrix.build-type != 'iwyu' }}
689+
if: ${{ failure() && matrix.build-type != 'iwyu' && matrix.compiler-family != 'arm-cross' }}
622690

623691
- name: Run Valgrind checks
624692
run: |
@@ -639,7 +707,7 @@ jobs:
639707
run: |
640708
cd src/ ;
641709
cppcheck --error-exitcode=1 . ;
642-
if: ${{ matrix.os-type == 'ubuntu' }}
710+
if: ${{ matrix.os-type == 'ubuntu' && matrix.compiler-family != 'arm-cross' }}
643711

644712
- name: Run performance tests (select)
645713
run: |

0 commit comments

Comments
 (0)