From 7195c668ce3a926bfbc41aa1a31a375a0b79fd9f Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 29 May 2026 14:47:41 +0100 Subject: [PATCH 1/5] sysupdate: fix bogus return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-05-29T13:44:48.7158429Z In file included from ../src/basic/../fundamental/assert-util.h:8, 2026-05-29T13:44:48.7159224Z from ../src/basic/assert-util.h:4, 2026-05-29T13:44:48.7159990Z from ../src/basic/basic-forward.h:17, 2026-05-29T13:44:48.7160337Z from ../src/basic/alloc-util.h:6, 2026-05-29T13:44:48.7161366Z from ../src/sysupdate/sysupdate-transfer.c:9: 2026-05-29T13:44:48.7169020Z ../src/sysupdate/sysupdate-transfer.c: In function ‘transfer_acquire_instance’: 2026-05-29T13:44:48.7169957Z ../src/basic/../fundamental/macro.h:190:37: error: ‘r’ may be used uninitialized [-Werror=maybe-uninitialized] 2026-05-29T13:44:48.7170483Z 190 | default: __builtin_llabs((long long) (a))) 2026-05-29T13:44:48.7171001Z | ^~~~~~~~~~~~~~~ 2026-05-29T13:44:48.7171435Z ../src/basic/log.h:32:46: note: in expansion of macro ‘ABS’ 2026-05-29T13:44:48.7171800Z 32 | #define ERRNO_VALUE(val) (ABS(val) & ~(1 << 30)) 2026-05-29T13:44:48.7172134Z | ^~~ 2026-05-29T13:44:48.7172528Z ../src/basic/log.h:188:28: note: in expansion of macro ‘ERRNO_VALUE’ 2026-05-29T13:44:48.7173003Z 188 | : -ERRNO_VALUE(_e); \ 2026-05-29T13:44:48.7173317Z | ^~~~~~~~~~~ 2026-05-29T13:44:48.7173779Z ../src/basic/log.h:208:17: note: in expansion of macro ‘log_full_errno_zerook’ 2026-05-29T13:44:48.7174204Z 208 | log_full_errno_zerook(level, (int)_error, __VA_ARGS__); \ 2026-05-29T13:44:48.7174528Z | ^~~~~~~~~~~~~~~~~~~~~ 2026-05-29T13:44:48.7174917Z ../src/basic/log.h:233:41: note: in expansion of macro ‘log_full_errno’ 2026-05-29T13:44:48.7175401Z 233 | #define log_error_errno(error, ...) log_full_errno(LOG_ERR, error, __VA_ARGS__) 2026-05-29T13:44:48.7175799Z | ^~~~~~~~~~~~~~ 2026-05-29T13:44:48.7176318Z ../src/sysupdate/sysupdate-transfer.c:1346:32: note: in expansion of macro ‘log_error_errno’ 2026-05-29T13:44:48.7176931Z 1346 | return log_error_errno(r, "SHA256 checksum not known for download '%s', refusing.", i->path); 2026-05-29T13:44:48.7177514Z | ^~~~~~~~~~~~~~~ 2026-05-29T13:44:48.7178157Z ../src/sysupdate/sysupdate-transfer.c:1270:13: note: ‘r’ was declared here 2026-05-29T13:44:48.7178501Z 1270 | int r; Follow-up for 43cc7a3ef4f6a89946e7ffd6a3112a0c1740b1ef --- src/sysupdate/sysupdate-transfer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c index 27756298fa2..bb984915926 100644 --- a/src/sysupdate/sysupdate-transfer.c +++ b/src/sysupdate/sysupdate-transfer.c @@ -1343,7 +1343,7 @@ int transfer_acquire_instance(Transfer *t, Instance *i, InstanceMetadata *f, Tra * download. */ if (!i->metadata.sha256sum_set) - return log_error_errno(r, "SHA256 checksum not known for download '%s', refusing.", i->path); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "SHA256 checksum not known for download '%s', refusing.", i->path); digest = hexmem(i->metadata.sha256sum, sizeof(i->metadata.sha256sum)); if (!digest) From b3f50b9515bf70e64e576b594d92ee5c3c395fa6 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 29 May 2026 14:16:34 +0100 Subject: [PATCH 2/5] core: fix maybe-uninitialized warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-05-29T13:14:20.8990848Z arm-linux-gnueabihf-gcc -Isrc/core/libsystemd-core-261.a.p -Isrc/core -I../src/core -Isrc/shared -I../src/shared -Isrc/bpf -I../src/bpf -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-common -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-future -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -Isrc/libsystemd/sd-journal -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-json -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-path -I../src/libsystemd/sd-resolve -I../src/libsystemd/sd-varlink -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -Isrc/version -I../src/version -I/usr/include/uuid -I/usr/include/json-c -I/usr/include/blkid -I/usr/include/libmount -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=gnu17 -O0 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-nonnull-compare -Warray-bounds -Warray-bounds=2 -Wdate-time -Wendif-labels -Werror=bool-compare -Werror=discarded-qualifiers -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=missing-declarations -Werror=missing-prototypes -Werror=overflow -Werror=override-init -Werror=pointer-sign -Werror=return-type -Werror=sequence-point -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=strict-flex-arrays -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wzero-length-bounds -fdiagnostics-show-option -fexcess-precision=standard -fno-common -fstack-protector -fstack-protector-strong -fstrict-flex-arrays=3 -fno-math-errno --param=ssp-buffer-size=4 -Wno-unused-result -Werror=shadow -O2 -pipe -g -feliminate-unused-debug-types -fPIC -fno-strict-aliasing -fstrict-flex-arrays=1 -fvisibility=hidden -fno-omit-frame-pointer -include config.h -isystem../src/include/glibc -isystem../src/include/override -isystemsrc/include/override -isystem../src/include/uapi -fvisibility=default -MD -MQ src/core/libsystemd-core-261.a.p/unit.c.o -MF src/core/libsystemd-core-261.a.p/unit.c.o.d -o src/core/libsystemd-core-261.a.p/unit.c.o -c ../src/core/unit.c 2026-05-29T13:14:20.9001764Z ../src/core/unit.c: In function ‘unit_start_on_termination_deps’: 2026-05-29T13:14:20.9002500Z ../src/core/unit.c:2367:21: error: ‘job_mode’ may be used uninitialized [-Werror=maybe-uninitialized] 2026-05-29T13:14:20.9004088Z 2367 | r = manager_add_job(u->manager, JOB_START, other, job_mode, &error, /* ret= */ NULL); 2026-05-29T13:14:20.9004619Z | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026-05-29T13:14:20.9005147Z ../src/core/unit.c:2341:17: note: ‘job_mode’ was declared here 2026-05-29T13:14:20.9005458Z 2341 | JobMode job_mode; 2026-05-29T13:14:20.9005673Z | ^~~~~~~~ 2026-05-29T13:14:20.9005898Z cc1: all warnings being treated as errors Follow-up for 9faeb2d024540ac4b94dedb00a13606ec262cc31 --- src/core/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/unit.c b/src/core/unit.c index d66f813a9a3..670f84fc15f 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2338,7 +2338,7 @@ static void retroactively_stop_dependencies(Unit *u) { void unit_start_on_termination_deps(Unit *u, UnitDependencyAtom atom) { const char *dependency_name = NULL; - JobMode job_mode; + JobMode job_mode = _JOB_MODE_INVALID; unsigned n_jobs = 0; int r; From 0fd7b5ea5f1744468ba2ce39acebea2b648f62e9 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 29 May 2026 17:08:28 +0100 Subject: [PATCH 3/5] test: avoid false maybe-uninitialized warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-05-29T16:05:02.6627742Z In file included from ../src/basic/../fundamental/assert-util.h:8, 2026-05-29T16:05:02.6628349Z from ../src/basic/assert-util.h:4, 2026-05-29T16:05:02.6628722Z from ../src/basic/basic-forward.h:17, 2026-05-29T16:05:02.6629044Z from ../src/libsystemd/sd-common/sd-forward.h:6, 2026-05-29T16:05:02.6629361Z from ../src/shared/shared-forward.h:6, 2026-05-29T16:05:02.6629648Z from ../src/shared/crypto-util.h:4, 2026-05-29T16:05:02.6631153Z from ../src/test/test-crypto-util.c:3: 2026-05-29T16:05:02.6634148Z ../src/test/test-crypto-util.c: In function ‘test_digest_size’: 2026-05-29T16:05:02.6634986Z ../src/basic/../fundamental/macro.h:95:41: error: ‘size’ is used uninitialized [-Werror=uninitialized] 2026-05-29T16:05:02.6635470Z 95 | #define _unlikely_(x) (__builtin_expect(!!(x), 0)) 2026-05-29T16:05:02.6635764Z | ^~~~~ 2026-05-29T16:05:02.6636287Z ../src/basic/../fundamental/assert-util.h:59:21: note: in expansion of macro ‘_unlikely_’ 2026-05-29T16:05:02.6636963Z 59 | if (_unlikely_(!(expr))) \ 2026-05-29T16:05:02.6637344Z | ^~~~~~~~~~ 2026-05-29T16:05:02.6637864Z ../src/basic/../fundamental/assert-util.h:65:25: note: in expansion of macro ‘assert_message_se’ 2026-05-29T16:05:02.6638339Z 65 | #define assert_se(expr) assert_message_se(expr, #expr) 2026-05-29T16:05:02.6638642Z | ^~~~~~~~~~~~~~~~~ 2026-05-29T16:05:02.6639066Z ../src/test/test-crypto-util.c:136:17: note: in expansion of macro ‘assert_se’ 2026-05-29T16:05:02.6639450Z 136 | assert_se(size == t->size); 2026-05-29T16:05:02.6639704Z | ^~~~~~~~~ 2026-05-29T16:05:02.6640063Z ../src/test/test-crypto-util.c:132:16: note: ‘size’ declared here 2026-05-29T16:05:02.6640590Z 132 | size_t size; 2026-05-29T16:05:02.6640794Z | ^~~~ --- src/test/test-crypto-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-crypto-util.c b/src/test/test-crypto-util.c index a2fd090ed3f..989905ab0f8 100644 --- a/src/test/test-crypto-util.c +++ b/src/test/test-crypto-util.c @@ -129,7 +129,7 @@ static const struct { }; TEST(digest_size) { - size_t size; + size_t size = 0; /* avoid false maybe-uninitialized warning */ FOREACH_ELEMENT(t, digest_size_table) { assert(openssl_digest_size(t->alg, &size) >= 0); From 595d3d593cfd2e6a2353b207a5c3e094a18a5665 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 29 May 2026 14:13:20 +0100 Subject: [PATCH 4/5] test: skip test-execute and ukify addon test when cross-compiling These tests run native tools on foreign ELF files, so they fail, just skip them when cross-compiling --- src/test/meson.build | 1 + src/ukify/test/meson.build | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/meson.build b/src/test/meson.build index 03635c2efc7..21b1f435f46 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -547,6 +547,7 @@ executables += [ core_test_template + { 'sources' : files('test-execute.c'), 'dependencies' : common_test_dependencies, + 'type' : meson.is_cross_build() ? 'manual' : '', 'timeout' : 360, }, core_test_template + { diff --git a/src/ukify/test/meson.build b/src/ukify/test/meson.build index 68be54e2282..a5c7bbb37c3 100644 --- a/src/ukify/test/meson.build +++ b/src/ukify/test/meson.build @@ -12,10 +12,15 @@ if want_ukify and want_tests != 'false' args += ['--flakes'] endif + efi_addon_for_test = '' + if not meson.is_cross_build() and efi_addon.length() > 0 + efi_addon_for_test = efi_addon[0].full_path() + endif + test('test-ukify', files('test_ukify.py'), args: args, - env : test_env + {'EFI_ADDON' : efi_addon.length() > 0 ? efi_addon[0].full_path() : ''}, + env : test_env + {'EFI_ADDON' : efi_addon_for_test}, timeout : 120, suite : 'ukify', depends : efi_addon) From 31540f323578f70eb3d874041d37c14de9102637 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 29 May 2026 13:42:24 +0100 Subject: [PATCH 5/5] ci: add build/unit-test coverage for armv7 arm64 hosts support running armv7 (armhf) binaries, so we can cross compile and run the unit tests without performance issues. armv7 (armhf) is a primary architecture on Ubuntu, so build regressions block new version updates, and adding coverage helps to avoid introducing regressions. --- .github/workflows/armhf-clang.cross | 21 ++++++++ .github/workflows/armhf-gcc.cross | 21 ++++++++ .github/workflows/build-test.sh | 77 +++++++++++++++++++++-------- .github/workflows/build-test.yml | 3 ++ .github/workflows/unit-tests.sh | 40 +++++++++++---- .github/workflows/unit-tests.yml | 14 ++++-- 6 files changed, 143 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/armhf-clang.cross create mode 100644 .github/workflows/armhf-gcc.cross diff --git a/.github/workflows/armhf-clang.cross b/.github/workflows/armhf-clang.cross new file mode 100644 index 00000000000..1da21afd1f6 --- /dev/null +++ b/.github/workflows/armhf-clang.cross @@ -0,0 +1,21 @@ +[binaries] +c = ['clang', '--target=arm-linux-gnueabihf'] +cpp = ['clang++', '--target=arm-linux-gnueabihf'] +ar = 'arm-linux-gnueabihf-ar' +nm = 'arm-linux-gnueabihf-nm' +strip = 'arm-linux-gnueabihf-strip' +pkgconfig = 'pkg-config' + +[properties] +needs_exe_wrapper = false +pkg_config_libdir = '/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig' +c_args = ['-O2', '-pipe', '-g', '-feliminate-unused-debug-types'] +c_link_args = ['-fuse-ld=bfd', '-Wl,-O1', '-Wl,--hash-style=gnu', '-Wl,--as-needed', '-Wl,-z,relro,-z,now,-z,noexecstack'] +cpp_args = [] +cpp_link_args = ['-fuse-ld=bfd', '-Wl,-O1', '-Wl,--hash-style=gnu', '-Wl,--as-needed', '-Wl,-z,relro,-z,now,-z,noexecstack'] + +[host_machine] +system = 'linux' +cpu_family = 'arm' +cpu = 'armv7' +endian = 'little' diff --git a/.github/workflows/armhf-gcc.cross b/.github/workflows/armhf-gcc.cross new file mode 100644 index 00000000000..8fd2bf76708 --- /dev/null +++ b/.github/workflows/armhf-gcc.cross @@ -0,0 +1,21 @@ +[binaries] +c = 'arm-linux-gnueabihf-gcc' +cpp = 'arm-linux-gnueabihf-g++' +ar = 'arm-linux-gnueabihf-gcc-ar' +nm = 'arm-linux-gnueabihf-gcc-nm' +strip = 'arm-linux-gnueabihf-strip' +pkgconfig = 'pkg-config' + +[properties] +needs_exe_wrapper = false +pkg_config_libdir = '/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig' +c_args = ['-O2', '-pipe', '-g', '-feliminate-unused-debug-types'] +c_link_args = ['-fuse-ld=bfd', '-Wl,-O1', '-Wl,--hash-style=gnu', '-Wl,--as-needed', '-Wl,-z,relro,-z,now,-z,noexecstack'] +cpp_args = [] +cpp_link_args = ['-fuse-ld=bfd', '-Wl,-O1', '-Wl,--hash-style=gnu', '-Wl,--as-needed', '-Wl,-z,relro,-z,now,-z,noexecstack'] + +[host_machine] +system = 'linux' +cpu_family = 'arm' +cpu = 'armv7' +endian = 'little' diff --git a/.github/workflows/build-test.sh b/.github/workflows/build-test.sh index 3d3a5e8bcca..784340ec450 100755 --- a/.github/workflows/build-test.sh +++ b/.github/workflows/build-test.sh @@ -19,6 +19,7 @@ ARGS=( "-Db_ndebug=true" "--auto-features=disabled -Dcompat-mutable-uid-boundaries=true" ) +# Packages that are always native (i.e.: tools that run on the host) go in this list PACKAGES=( cryptsetup-bin expect @@ -28,6 +29,26 @@ PACKAGES=( isc-dhcp-client itstool kbd + linux-tools-generic + mold + mount + net-tools + python3-evdev + python3-jinja2 + python3-lxml + python3-pefile + python3-pip + python3-pyelftools + python3-pyparsing + python3-setuptools + quota + strace + unifont + util-linux + zstd +) +# Packages that are needed for the target architecture (i.e.: libraries) go in this list +DEVEL_PACKAGES=( libarchive-dev libblkid-dev libbpf-dev @@ -47,38 +68,48 @@ PACKAGES=( libxkbcommon-dev libxtables-dev libzstd-dev - linux-tools-generic - mold - mount - net-tools - python3-evdev - python3-jinja2 - python3-lxml - python3-pefile - python3-pip - python3-pyelftools - python3-pyparsing - python3-setuptools - quota - strace - unifont - util-linux - zstd ) FEATURES=() COMPILER="${COMPILER:?}" COMPILER_VERSION="${COMPILER_VERSION:?}" LINKER="${LINKER:?}" RELEASE="$(lsb_release -cs)" +CROSS_ARCH="${CROSS_ARCH:-}" +CROSS_FILE=() -if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "x86_64" ]; then - PACKAGES+=(libxen-dev) +if [[ -z "$CROSS_ARCH" ]] && [[ "$(uname -m)" =~ ^(aarch64|x86_64)$ ]]; then + DEVEL_PACKAGES+=(libxen-dev) fi +# If CROSS_ARCH is set, append : to the packages so they get installed for the target +PACKAGES+=("${DEVEL_PACKAGES[@]/%/${CROSS_ARCH:+:$CROSS_ARCH}}") + # Note: As we use postfixed clang/gcc binaries, we need to override $AR # as well, otherwise meson falls back to ar from binutils which # doesn't work with LTO -if [[ "$COMPILER" == clang ]]; then +if [[ -n "$CROSS_ARCH" ]]; then + if [[ "$COMPILER" != gcc ]]; then + fatal "$CROSS_ARCH cross builds are only supported with gcc" + fi + + case "$CROSS_ARCH" in + armhf) + triplet=arm-linux-gnueabihf + ;; + *) + fatal "Unsupported cross architecture: $CROSS_ARCH" + ;; + esac + + CC="$triplet-gcc" + CXX="$triplet-g++" + AR="$triplet-gcc-ar" + CFLAGS="-Wno-maybe-uninitialized" + CXXFLAGS="" + CROSS_FILE=(--cross-file ".github/workflows/$CROSS_ARCH-gcc.cross") + FEATURES+=(-Ddbus-interfaces-dir=no -Dsbat-distro=) + PACKAGES+=("crossbuild-essential-$CROSS_ARCH") +elif [[ "$COMPILER" == clang ]]; then CC="clang-$COMPILER_VERSION" CXX="clang++-$COMPILER_VERSION" AR="llvm-ar-$COMPILER_VERSION" @@ -142,8 +173,11 @@ else sudo sed -i "s/Types: deb/Types: deb deb-src/g" "$f" done fi +if [[ -n "$CROSS_ARCH" ]]; then + sudo dpkg --add-architecture "$CROSS_ARCH" +fi sudo apt-get -y update -sudo apt-get -y build-dep systemd +sudo apt-get -y build-dep systemd ${CROSS_ARCH:+--host-architecture=$CROSS_ARCH} sudo apt-get -y install "${PACKAGES[@]}" # Install more or less recent meson and ninja with pip, since the distro versions don't # always support all the features we need (like --optimization=). Since the build-dep @@ -179,6 +213,7 @@ for args in "${ARGS[@]}"; do -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror \ -Dnobody-group=nogroup -Ddebug=false \ "${FEATURES[@]}" \ + "${CROSS_FILE[@]}" \ $args build; then cat build/meson-logs/meson-log.txt diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 5325954031f..2596b3edb5e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -39,6 +39,9 @@ jobs: - env: { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "mold" } runner: [ ubuntu-24.04-arm ] python-version: '' + - env: { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "bfd", CROSS_ARCH: "armhf" } + runner: [ ubuntu-24.04-arm ] + python-version: '' - env: { COMPILER: "clang", COMPILER_VERSION: "18", LINKER: "lld" } runner: [ ubuntu-24.04-s390x ] python-version: '' diff --git a/.github/workflows/unit-tests.sh b/.github/workflows/unit-tests.sh index c87b7d2e9a3..f910e21691f 100755 --- a/.github/workflows/unit-tests.sh +++ b/.github/workflows/unit-tests.sh @@ -3,11 +3,23 @@ # shellcheck disable=SC2206 PHASES=(${@:-SETUP RUN RUN_ASAN_UBSAN CLEANUP}) +# Packages that are always native (i.e.: tools that run on the host) go in this list ADDITIONAL_DEPS=( clang expect fdisk jekyll + linux-tools-generic + python3-libevdev + python3-pip + python3-pyelftools + python3-pyparsing + python3-pytest + rpm + zstd +) +# Packages that are needed for the target architecture (i.e.: libraries) go in this list +ADDITIONAL_TARGET_DEPS=( libbpf-dev libfdisk-dev libfido2-dev @@ -18,15 +30,8 @@ ADDITIONAL_DEPS=( libtss2-dev libxkbcommon-dev libzstd-dev - linux-tools-generic - python3-libevdev - python3-pip - python3-pyelftools - python3-pyparsing - python3-pytest - rpm - zstd ) +CROSS_ARCH="${CROSS_ARCH:-}" function info() { echo -e "\033[33;1m$1\033[0m" @@ -48,6 +53,12 @@ if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "x86_64" ]; then ADDITIONAL_DEPS+=(systemd-boot-efi) fi +if [[ -n "$CROSS_ARCH" ]]; then + ADDITIONAL_DEPS+=(crossbuild-essential-$CROSS_ARCH) +fi +# Append : to the packages so they get installed for the target +ADDITIONAL_DEPS+=("${ADDITIONAL_TARGET_DEPS[@]/%/${CROSS_ARCH:+:$CROSS_ARCH}}") + # (Re)set the current oom-{score-}adj. For some reason root on GH actions is able to _decrease_ # its oom-score even after dropping all capabilities (including CAP_SYS_RESOURCE), until the # score is explicitly changed after sudo. No idea what's going on, but it breaks @@ -64,8 +75,11 @@ for phase in "${PHASES[@]}"; do for f in /etc/apt/sources.list.d/*.sources; do sed -i "s/Types: deb/Types: deb deb-src/g" "$f" done + if [[ -n "$CROSS_ARCH" ]]; then + dpkg --add-architecture "$CROSS_ARCH" + fi apt-get -y update - apt-get -y build-dep systemd + apt-get -y build-dep systemd ${CROSS_ARCH:+--host-architecture=$CROSS_ARCH} apt-get -y install "${ADDITIONAL_DEPS[@]}" pip3 install -r .github/workflows/requirements.txt --require-hashes --break-system-packages @@ -99,6 +113,14 @@ for phase in "${PHASES[@]}"; do fi fi + if [[ -n "$CROSS_ARCH" ]]; then + if [[ "$phase" =~ ^RUN_GCC ]]; then + MESON_ARGS+=(-Ddbus-interfaces-dir=no -Dsbat-distro= --cross-file ".github/workflows/$CROSS_ARCH-gcc.cross") + elif [[ "$phase" =~ ^RUN_CLANG ]]; then + MESON_ARGS+=(-Dbpf-framework=disabled -Dbootloader=disabled -Defi=false -Ddbus-interfaces-dir=no -Dsbat-distro= --cross-file ".github/workflows/$CROSS_ARCH-clang.cross") + fi + fi + # On ppc64le the workers are slower and some slow tests time out MESON_TEST_ARGS=() if [[ "$(uname -m)" != "x86_64" ]] && [[ "$(uname -m)" != "aarch64" ]]; then diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 5740d425b9a..d265c993c76 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -16,7 +16,7 @@ jobs: build: runs-on: ${{ matrix.runner }} concurrency: - group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ github.ref }}-${{ matrix.runner }} + group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ matrix.cross_arch || 'native' }}-${{ github.ref }}-${{ matrix.runner }} cancel-in-progress: true strategy: fail-fast: false @@ -27,6 +27,9 @@ jobs: - run_phase: GCC - run_phase: GCC runner: ubuntu-24.04-arm + - run_phase: GCC + runner: ubuntu-24.04-arm + cross_arch: armhf - run_phase: GCC runner: ubuntu-24.04-ppc64le - run_phase: GCC @@ -34,10 +37,15 @@ jobs: - run_phase: CLANG - run_phase: CLANG runner: ubuntu-24.04-arm + - run_phase: CLANG + runner: ubuntu-24.04-arm + cross_arch: armhf - run_phase: CLANG runner: ubuntu-24.04-ppc64le - run_phase: CLANG runner: ubuntu-24.04-s390x + env: + CROSS_ARCH: ${{ matrix.cross_arch || '' }} steps: - name: Repository checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -50,9 +58,9 @@ jobs: sudo sed -i '/^XDG_/d' /etc/environment # Pass only specific env variables through sudo, to avoid having # the already existing XDG_* stuff on the "other side" - sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit-tests.sh SETUP + sudo --preserve-env=GITHUB_ACTIONS,CI,CROSS_ARCH .github/workflows/unit-tests.sh SETUP - name: Build & test - run: sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit-tests.sh RUN_${{ matrix.run_phase }} + run: sudo --preserve-env=GITHUB_ACTIONS,CI,CROSS_ARCH .github/workflows/unit-tests.sh RUN_${{ matrix.run_phase }} build-musl: name: Build & test (musl, postmarketOS)