2021-12-12 20:27:04 +01:00
#!/usr/bin/env bash
2021-10-01 12:10:22 +02:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2020-06-10 13:41:28 +02:00
2020-06-11 13:18:07 +02:00
set -ex
2020-06-10 13:41:28 +02:00
info( ) { echo -e " \033[33;1m $1 \033[0m " ; }
2020-06-11 13:18:07 +02:00
fatal( ) { echo >& 2 -e " \033[31;1m $1 \033[0m " ; exit 1; }
2020-06-10 13:41:28 +02:00
success( ) { echo >& 2 -e " \033[32;1m $1 \033[0m " ; }
ARGS = (
"--optimization=0"
"--optimization=s"
2021-12-24 11:50:37 +01:00
"--optimization=3 -Db_lto=true -Ddns-over-tls=false"
2020-06-11 14:21:02 +02:00
"--optimization=3 -Db_lto=false"
2021-02-17 09:56:59 +01:00
"--optimization=3 -Ddns-over-tls=openssl"
2021-05-05 21:07:36 +02:00
"--optimization=3 -Dfexecve=true -Dstandalone-binaries=true -Dstatic-libsystemd=true -Dstatic-libudev=true"
2020-06-10 13:41:28 +02:00
"-Db_ndebug=true"
)
PACKAGES = (
cryptsetup-bin
2020-06-10 20:51:15 +02:00
expect
fdisk
2020-06-10 13:41:28 +02:00
gettext
iputils-ping
isc-dhcp-client
itstool
kbd
libblkid-dev
2021-12-03 16:30:56 +01:00
libbpf-dev
2020-06-10 13:41:28 +02:00
libcap-dev
libcurl4-gnutls-dev
2020-06-10 20:51:15 +02:00
libfdisk-dev
2020-10-21 16:28:22 +02:00
libfido2-dev
2020-06-10 13:41:28 +02:00
libgpg-error-dev
liblz4-dev
liblzma-dev
libmicrohttpd-dev
libmount-dev
2020-06-10 20:51:15 +02:00
libp11-kit-dev
libpwquality-dev
2020-06-10 13:41:28 +02:00
libqrencode-dev
2020-06-10 20:51:15 +02:00
libssl-dev
2020-12-20 22:27:36 +01:00
libtss2-dev
2020-06-10 13:41:28 +02:00
libxkbcommon-dev
2020-10-21 16:17:29 +02:00
libxtables-dev
2020-10-21 16:28:22 +02:00
libzstd-dev
2020-06-10 13:41:28 +02:00
mount
net-tools
perl
python3-evdev
2021-05-17 10:36:30 +02:00
python3-jinja2
2021-12-03 16:30:56 +01:00
python3-lxml
2020-06-10 13:41:28 +02:00
python3-pip
python3-pyparsing
python3-setuptools
quota
strace
unifont
util-linux
2020-06-10 20:51:15 +02:00
zstd
2020-06-10 13:41:28 +02:00
)
2020-06-11 13:18:07 +02:00
COMPILER = " ${ COMPILER : ? } "
COMPILER_VERSION = " ${ COMPILER_VERSION : ? } "
2021-12-10 18:28:33 +01:00
LINKER = " ${ LINKER : ? } "
2021-12-24 11:50:37 +01:00
CRYPTOLIB = " ${ CRYPTOLIB : ? } "
2020-06-10 13:41:28 +02: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 13:18:07 +02: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 21:12:42 +02:00
# ATTOW llvm-11 got into focal-updates, which conflicts with llvm-11
# provided by the apt.llvm.org repositories. Let's use the system
# llvm package if available in such cases to avoid that.
if ! apt show --quiet " llvm- $COMPILER_VERSION " & >/dev/null; then
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
2021-12-26 01:11:00 +00: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" \
" $RELEASE " " $RELEASE " " $COMPILER_VERSION " >/etc/apt/sources.list.d/llvm-toolchain.list
2021-10-11 21:12:42 +02:00
PACKAGES += ( " clang- $COMPILER_VERSION " " lldb- $COMPILER_VERSION " " lld- $COMPILER_VERSION " " clangd- $COMPILER_VERSION " )
fi
2020-06-11 13:18:07 +02:00
elif [ [ " $COMPILER " = = gcc ] ] ; then
CC = " gcc- $COMPILER_VERSION "
CXX = " g++- $COMPILER_VERSION "
AR = " gcc-ar- $COMPILER_VERSION "
# Latest gcc stack deb packages provided by
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
2021-01-25 15:49:27 +01:00
add-apt-repository -y ppa:ubuntu-toolchain-r/test
2021-09-29 19:55:24 +02:00
PACKAGES += ( " gcc- $COMPILER_VERSION " )
2020-06-11 13:18:07 +02:00
else
fatal " Unknown compiler: $COMPILER "
fi
2020-06-10 20:51:15 +02: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 15:00:15 +02:00
apt-get -y update
2020-06-11 13:18:07 +02:00
apt-get -y build-dep systemd
apt-get -y install " ${ PACKAGES [@] } "
2021-11-19 16:23:03 +00: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 15:00:15 +02: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 16:23:03 +00:00
pip3 install --user -r .github/workflows/requirements.txt --require-hashes
2020-06-11 15:00:15 +02:00
export PATH = " $HOME /.local/bin: $PATH "
2020-06-10 13:41:28 +02:00
$CC --version
2021-01-25 16:01:56 +01:00
meson --version
ninja --version
2020-06-10 13:41:28 +02:00
for args in " ${ ARGS [@] } " ; do
SECONDS = 0
2022-01-13 12:28:09 +00:00
# meson fails with
# src/boot/efi/meson.build:52: WARNING: Not using lld as efi-ld, falling back to bfd
# src/boot/efi/meson.build:52:16: ERROR: Fatal warnings enabled, aborting
# when LINKER is set to lld so let's just not turn meson warnings into errors with lld
# to make sure that the build systemd can pick up the correct efi-ld linker automatically.
if [ [ " $LINKER " != lld ] ] ; then
additional_meson_args = "--fatal-meson-warnings"
fi
2020-06-10 13:41:28 +02:00
info " Checking build with $args "
2021-09-29 19:55:24 +02:00
# shellcheck disable=SC2086
2021-12-10 18:28:33 +01:00
if ! AR = " $AR " \
CC = " $CC " CC_LD = " $LINKER " CFLAGS = "-Werror" \
CXX = " $CXX " CXX_LD = " $LINKER " CXXFLAGS = "-Werror" \
meson -Dtests= unsafe -Dslow-tests= true -Dfuzz-tests= true --werror \
2022-01-13 12:28:09 +00:00
-Dnobody-group= nogroup $additional_meson_args \
2021-12-24 11:50:37 +01:00
-Dcryptolib= " ${ CRYPTOLIB : ? } " $args build; then
2021-12-10 18:28:33 +01:00
2022-01-13 07:01:17 +00:00
cat build/meson-logs/meson-log.txt
2020-06-11 13:18:07 +02:00
fatal " meson failed with $args "
2020-06-10 13:41:28 +02:00
fi
2022-01-13 07:01:17 +00:00
if ! meson compile -C build -v; then
2021-01-25 16:01:56 +01:00
fatal " 'meson compile' failed with $args "
2020-06-10 13:41:28 +02:00
fi
2022-01-02 20:05:58 +01: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 13:41:28 +02:00
git clean -dxf
success " Build with $args passed in $SECONDS seconds "
done