2021-12-12 22:27:04 +03:00
#!/usr/bin/env bash
2021-10-01 13:10:22 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2020-06-10 14:41:28 +03:00
2020-06-11 14:18:07 +03:00
set -ex
2020-06-10 14:41:28 +03:00
info( ) { echo -e " \033[33;1m $1 \033[0m " ; }
2020-06-11 14:18:07 +03:00
fatal( ) { echo >& 2 -e " \033[31;1m $1 \033[0m " ; exit 1; }
2020-06-10 14:41:28 +03:00
success( ) { echo >& 2 -e " \033[32;1m $1 \033[0m " ; }
ARGS = (
"--optimization=0"
2023-02-26 16:09:44 +03:00
"--optimization=s -Dbootloader=true -Defi-cflags=-m32"
2021-12-24 13:50:37 +03:00
"--optimization=3 -Db_lto=true -Ddns-over-tls=false"
2020-06-11 15:21:02 +03:00
"--optimization=3 -Db_lto=false"
2021-02-17 11:56:59 +03:00
"--optimization=3 -Ddns-over-tls=openssl"
2021-05-05 22:07:36 +03:00
"--optimization=3 -Dfexecve=true -Dstandalone-binaries=true -Dstatic-libsystemd=true -Dstatic-libudev=true"
2020-06-10 14:41:28 +03:00
"-Db_ndebug=true"
)
PACKAGES = (
cryptsetup-bin
2020-06-10 21:51:15 +03:00
expect
fdisk
2020-06-10 14:41:28 +03:00
gettext
iputils-ping
isc-dhcp-client
itstool
kbd
libblkid-dev
2021-12-03 18:30:56 +03:00
libbpf-dev
2022-03-23 16:40:06 +03:00
libc6-dev-i386
2020-06-10 14:41:28 +03:00
libcap-dev
libcurl4-gnutls-dev
2020-06-10 21:51:15 +03:00
libfdisk-dev
2020-10-21 17:28:22 +03:00
libfido2-dev
2020-06-10 14:41:28 +03:00
libgpg-error-dev
liblz4-dev
liblzma-dev
libmicrohttpd-dev
libmount-dev
2020-06-10 21:51:15 +03:00
libp11-kit-dev
libpwquality-dev
2020-06-10 14:41:28 +03:00
libqrencode-dev
2020-06-10 21:51:15 +03:00
libssl-dev
2020-12-21 00:27:36 +03:00
libtss2-dev
2022-11-01 18:53:02 +03:00
libxen-dev
2020-06-10 14:41:28 +03:00
libxkbcommon-dev
2020-10-21 17:17:29 +03:00
libxtables-dev
2020-10-21 17:28:22 +03:00
libzstd-dev
2022-08-09 11:36:40 +03:00
mold
2020-06-10 14:41:28 +03:00
mount
net-tools
perl
python3-evdev
2021-05-17 11:36:30 +03:00
python3-jinja2
2021-12-03 18:30:56 +03:00
python3-lxml
2022-11-25 21:14:42 +03:00
python3-pefile
2020-06-10 14:41:28 +03:00
python3-pip
python3-pyparsing
python3-setuptools
quota
strace
unifont
util-linux
2020-06-10 21:51:15 +03:00
zstd
2020-06-10 14:41:28 +03:00
)
2020-06-11 14:18:07 +03:00
COMPILER = " ${ COMPILER : ? } "
COMPILER_VERSION = " ${ COMPILER_VERSION : ? } "
2021-12-10 20:28:33 +03:00
LINKER = " ${ LINKER : ? } "
2021-12-24 13:50:37 +03:00
CRYPTOLIB = " ${ CRYPTOLIB : ? } "
2020-06-10 14:41:28 +03:00
RELEASE = " $( lsb_release -cs) "
bash -c " echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list "
2020-06-11 14:18:07 +03:00
# 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
CC = " clang- $COMPILER_VERSION "
CXX = " clang++- $COMPILER_VERSION "
AR = " llvm-ar- $COMPILER_VERSION "
2021-10-11 22:12:42 +03:00
2022-05-21 17:35:55 +03:00
# Prefer the distro version if available
2022-02-22 16:43:40 +03:00
if ! apt install --dry-run " llvm- $COMPILER_VERSION " >/dev/null; then
2021-10-11 22:12:42 +03:00
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
2021-12-26 04:11:00 +03:00
# Following snippet was partly borrowed from https://apt.llvm.org/llvm.sh
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --yes --dearmor --output /usr/share/keyrings/apt-llvm-org.gpg
printf "deb [signed-by=/usr/share/keyrings/apt-llvm-org.gpg] http://apt.llvm.org/%s/ llvm-toolchain-%s-%s main\n" \
2022-02-22 16:43:40 +03:00
" $RELEASE " " $RELEASE " " $COMPILER_VERSION " >/etc/apt/sources.list.d/llvm-toolchain.list
2021-10-11 22:12:42 +03:00
fi
2022-05-21 17:35:55 +03:00
PACKAGES += ( " clang- $COMPILER_VERSION " " lldb- $COMPILER_VERSION " " lld- $COMPILER_VERSION " " clangd- $COMPILER_VERSION " )
2020-06-11 14:18:07 +03:00
elif [ [ " $COMPILER " = = gcc ] ] ; then
CC = " gcc- $COMPILER_VERSION "
CXX = " g++- $COMPILER_VERSION "
AR = " gcc-ar- $COMPILER_VERSION "
2022-05-07 15:40:56 +03:00
if ! apt install --dry-run " gcc- $COMPILER_VERSION " >/dev/null; then
# Latest gcc stack deb packages provided by
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi
2022-03-23 16:40:06 +03:00
PACKAGES += ( " gcc- $COMPILER_VERSION " " gcc- $COMPILER_VERSION -multilib " )
2020-06-11 14:18:07 +03:00
else
fatal " Unknown compiler: $COMPILER "
fi
2020-06-10 21:51:15 +03:00
# PPA with some newer build dependencies (like zstd)
2020-07-15 00:47:43 +03:00
add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci
2020-06-11 16:00:15 +03:00
apt-get -y update
2020-06-11 14:18:07 +03:00
apt-get -y build-dep systemd
apt-get -y install " ${ PACKAGES [@] } "
2021-11-19 19:23:03 +03:00
# 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
2020-06-11 16:00:15 +03:00
# command above installs the distro versions, let's install the pip ones just
# locally and add the local bin directory to the $PATH.
2021-11-19 19:23:03 +03:00
pip3 install --user -r .github/workflows/requirements.txt --require-hashes
2020-06-11 16:00:15 +03:00
export PATH = " $HOME /.local/bin: $PATH "
2020-06-10 14:41:28 +03:00
$CC --version
2021-01-25 18:01:56 +03:00
meson --version
ninja --version
2020-06-10 14:41:28 +03:00
for args in " ${ ARGS [@] } " ; do
SECONDS = 0
2022-04-28 04:26:04 +03:00
# The install_tag feature introduced in 0.60 causes meson to fail with fatal-meson-warnings
# "Project targeting '>= 0.53.2' but tried to use feature introduced in '0.60.0': install_tag arg in custom_target"
# It can be safely removed from the CI since it isn't actually used anywhere to test anything.
find . -type f -name meson.build -exec sed -i '/install_tag/d' '{}' '+'
2022-08-09 11:36:40 +03:00
# mold < 1.1 does not support LTO.
if dpkg --compare-versions " $( dpkg-query --showformat= '${Version}' --show mold) " ge 1.1; then
fatal "Newer mold version detected, please remove this workaround."
elif [ [ " $args " = = *"-Db_lto=true" * ] ] ; then
LD = "gold"
else
LD = " $LINKER "
fi
2020-06-10 14:41:28 +03:00
info " Checking build with $args "
2021-09-29 20:55:24 +03:00
# shellcheck disable=SC2086
2021-12-10 20:28:33 +03:00
if ! AR = " $AR " \
2022-08-09 11:36:40 +03:00
CC = " $CC " CC_LD = " $LD " CFLAGS = "-Werror" \
CXX = " $CXX " CXX_LD = " $LD " CXXFLAGS = "-Werror" \
2023-01-11 17:04:11 +03:00
meson setup \
-Dtests= unsafe -Dslow-tests= true -Dfuzz-tests= true --werror \
2022-08-10 10:47:42 +03:00
-Dnobody-group= nogroup -Dcryptolib= " ${ CRYPTOLIB : ? } " \
$args build; then
2021-12-10 20:28:33 +03:00
2022-01-13 10:01:17 +03:00
cat build/meson-logs/meson-log.txt
2020-06-11 14:18:07 +03:00
fatal " meson failed with $args "
2020-06-10 14:41:28 +03:00
fi
2022-01-13 10:01:17 +03:00
if ! meson compile -C build -v; then
2023-01-11 17:04:11 +03:00
fatal " 'meson compile' failed with ' $args ' "
2020-06-10 14:41:28 +03:00
fi
2022-01-02 22:05:58 +03:00
for loader in build/src/boot/efi/*.efi; do
if sbverify --list " $loader " | & grep -q "gap in section table" ; then
fatal " $loader : Gaps found in section table "
fi
done
2020-06-10 14:41:28 +03:00
git clean -dxf
2023-01-11 17:04:11 +03:00
success " Build with ' $args ' passed in $SECONDS seconds "
2020-06-10 14:41:28 +03:00
done