2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 info
() { echo -e "\033[33;1m$1\033[0m"; }
7 fatal
() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; }
8 success
() { echo >&2 -e "\033[32;1m$1\033[0m"; }
12 "--optimization=s -Dgnu-efi=true -Defi-cflags=-m32 -Defi-libdir=/usr/lib32"
13 "--optimization=3 -Db_lto=true -Ddns-over-tls=false"
14 "--optimization=3 -Db_lto=false"
15 "--optimization=3 -Ddns-over-tls=openssl"
16 "--optimization=3 -Dfexecve=true -Dstandalone-binaries=true -Dstatic-libsystemd=true -Dstatic-libudev=true"
66 COMPILER
="${COMPILER:?}"
67 COMPILER_VERSION
="${COMPILER_VERSION:?}"
69 CRYPTOLIB
="${CRYPTOLIB:?}"
70 RELEASE
="$(lsb_release -cs)"
72 bash
-c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list"
74 # Note: As we use postfixed clang/gcc binaries, we need to override $AR
75 # as well, otherwise meson falls back to ar from binutils which
76 # doesn't work with LTO
77 if [[ "$COMPILER" == clang
]]; then
78 CC
="clang-$COMPILER_VERSION"
79 CXX
="clang++-$COMPILER_VERSION"
80 AR
="llvm-ar-$COMPILER_VERSION"
82 # Prefer the distro version if available
83 if ! apt
install --dry-run "llvm-$COMPILER_VERSION" >/dev
/null
; then
84 # Latest LLVM stack deb packages provided by https://apt.llvm.org/
85 # Following snippet was partly borrowed from https://apt.llvm.org/llvm.sh
86 wget
-O - https
://apt.llvm.org
/llvm-snapshot.gpg.key | gpg
--yes --dearmor --output /usr
/share
/keyrings
/apt-llvm-org.gpg
87 printf "deb [signed-by=/usr/share/keyrings/apt-llvm-org.gpg] http://apt.llvm.org/%s/ llvm-toolchain-%s-%s main\n" \
88 "$RELEASE" "$RELEASE" "$COMPILER_VERSION" >/etc
/apt
/sources.list.d
/llvm-toolchain.list
91 PACKAGES
+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION")
92 elif [[ "$COMPILER" == gcc
]]; then
93 CC
="gcc-$COMPILER_VERSION"
94 CXX
="g++-$COMPILER_VERSION"
95 AR
="gcc-ar-$COMPILER_VERSION"
97 if ! apt
install --dry-run "gcc-$COMPILER_VERSION" >/dev
/null
; then
98 # Latest gcc stack deb packages provided by
99 # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
100 add-apt-repository
-y ppa
:ubuntu-toolchain-r
/test
103 PACKAGES
+=("gcc-$COMPILER_VERSION" "gcc-$COMPILER_VERSION-multilib")
105 fatal
"Unknown compiler: $COMPILER"
108 # PPA with some newer build dependencies (like zstd)
109 add-apt-repository
-y ppa
:upstream-systemd-ci
/systemd-ci
111 apt-get
-y build-dep systemd
112 apt-get
-y install "${PACKAGES[@]}"
113 # Install more or less recent meson and ninja with pip, since the distro versions don't
114 # always support all the features we need (like --optimization=). Since the build-dep
115 # command above installs the distro versions, let's install the pip ones just
116 # locally and add the local bin directory to the $PATH.
117 pip3
install --user -r .github
/workflows
/requirements.txt
--require-hashes
118 export PATH
="$HOME/.local/bin:$PATH"
124 for args
in "${ARGS[@]}"; do
127 # The install_tag feature introduced in 0.60 causes meson to fail with fatal-meson-warnings
128 # "Project targeting '>= 0.53.2' but tried to use feature introduced in '0.60.0': install_tag arg in custom_target"
129 # It can be safely removed from the CI since it isn't actually used anywhere to test anything.
130 find .
-type f
-name meson.build
-exec sed -i '/install_tag/d' '{}' '+'
132 # mold < 1.1 does not support LTO.
133 if dpkg
--compare-versions "$(dpkg-query --showformat='${Version}' --show mold)" ge
1.1; then
134 fatal
"Newer mold version detected, please remove this workaround."
135 elif [[ "$args" == *"-Db_lto=true"* ]]; then
141 info
"Checking build with $args"
142 # shellcheck disable=SC2086
144 CC
="$CC" CC_LD
="$LD" CFLAGS
="-Werror" \
145 CXX
="$CXX" CXX_LD
="$LD" CXXFLAGS
="-Werror" \
147 -Dtests=unsafe
-Dslow-tests=true
-Dfuzz-tests=true
--werror \
148 -Dnobody-group=nogroup
-Dcryptolib="${CRYPTOLIB:?}" \
151 cat build
/meson-logs
/meson-log.txt
152 fatal
"meson failed with $args"
155 if ! meson compile
-C build
-v; then
156 fatal
"'meson compile' failed with '$args'"
159 for loader
in build
/src
/boot
/efi
/*.efi
; do
160 if sbverify
--list "$loader" |
& grep -q "gap in section table"; then
161 fatal
"$loader: Gaps found in section table"
167 success
"Build with '$args' passed in $SECONDS seconds"