attr
bash-completion
bpftrace
+ clang
coreutils
curl
diffutils
kmod
knot
less
+ lld
+ llvm
lvm2
man
mdadm
# shellcheck source=/dev/null
. /etc/makepkg.conf
+CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+if ((LLVM)); then
+ # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
+ CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+fi
+
+LDFLAGS=""
+if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
+ LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+fi
+
# Override the default options. Disable FORTIFY_SOURCE because it doesn't work with O0. We specifically
# disable "strip", "zipman" and "lto" as they slow down builds significantly. OPTIONS= cannot be overridden
# on the makepkg command line so we append to /etc/makepkg.conf instead. The rootfs is overlaid with a
# writable tmpfs during the build script so these changes don't end up in the image itself.
tee --append /etc/makepkg.conf >/dev/null <<EOF
-CFLAGS="$CFLAGS -O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+export CC="$( ((LLVM)) && echo clang || echo gcc)"
+export CXX="$( ((LLVM)) && echo clang++ || echo g++)"
+export CC_LD="$( ((LLVM)) && echo lld)"
+export CXX_LD="$( ((LLVM)) && echo lld)"
+export CFLAGS="\$CFLAGS $CFLAGS"
+export CXXFLAGS="\$CXXFLAGS $CFLAGS"
+export LDFLAGS="\$LDFLAGS $LDFLAGS"
OPTIONS=(
docs
!libtool
bind
bpf
btrfs-progs
+ compiler-rt
compsize
cryptsetup
dbus-broker
InitrdPackages=
btrfs-progs
+ compiler-rt
tpm2-tools
InitrdVolatilePackages=
ARCH="$(rpm --eval %_arch)"
SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
+COMMON_MACRO_OVERRIDES=(
+ --define "toolchain $( ((LLVM)) && echo clang || echo gcc)"
+ --define "_fortify_level 0"
+ --undefine _lto_cflags
+ # TODO: Remove once redhat-rpm-config 292 is available everywhere.
+ --define "_hardening_clang_cflags --config=/usr/lib/rpm/redhat/redhat-hardened-clang.cfg"
+ --define "_hardening_clang_ldflags --config=/usr/lib/rpm/redhat/redhat-hardened-clang-ld.cfg"
+)
+
# TODO: Drop -U_FORTIFY_SOURCE when we switch to CentOS Stream 10.
-CFLAGS="$(rpm --define "_fortify_level 0" --undefine _lto_cflags --eval %build_cflags) -O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
if ((WITH_DEBUG)); then
CFLAGS="$CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
fi
+if ((LLVM)); then
+ # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
+ CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+fi
+
+LDFLAGS=""
+if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
+ LDFLAGS="$LDFLAGS -Wl,-rpath=$(dirname "$(clang --print-file-name=libclang_rt.asan.so)")"
+fi
IFS=
# TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
# shellcheck disable=SC2046
env \
ANNOBIN="no-active-checks" \
-rpmbuild \
+CC_LD="$( ((LLVM)) && echo lld)" \
+CXX_LD="$( ((LLVM)) && echo lld)" \
+ rpmbuild \
-bb \
--build-in-place \
--with upstream \
$( ((WITH_DEBUG)) || echo "--define=debug_package %{nil}") \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
- --define "build_cflags $CFLAGS" \
+ "${COMMON_MACRO_OVERRIDES[@]}" \
+ --define "build_cflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cflags}") $CFLAGS" \
+ --define "build_cxxflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cxxflags}") $CFLAGS" \
+ --define "build_ldflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_ldflags}") $LDFLAGS" \
--define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
--define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
--define "meson_extra_configure_options -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
--define "_find_debuginfo_dwz_opts %{nil}" \
- --define "_fortify_level 0" \
--define "_fixperms true" \
- --undefine _lto_cflags \
--undefine _package_note_flags \
--noclean \
"pkg/$ID/systemd.spec"
Packages=
bind-utils
bpftool
+ compiler-rt
cryptsetup
device-mapper-event
device-mapper-multipath
cat debian/changelog >>debian/changelog.new
mv debian/changelog.new debian/changelog
+CFLAGS="-O${OPTIMIZATION:-0}"
+if ((LLVM)); then
+ # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
+ CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+fi
+
+LDFLAGS=""
+if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
+ LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+fi
+
+# TODO: Drop GENSYMBOLS_LEVEL once https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=986746 is fixed.
build() {
env \
+ CC="$( ((LLVM)) && echo clang || echo gcc)" \
+ CXX="$( ((LLVM)) && echo clang++ || echo g++)" \
+ CC_LD="$( ((LLVM)) && echo lld)" \
+ CXX_LD="$( ((LLVM)) && echo lld)" \
DEB_BUILD_OPTIONS="$(awk '$1=$1' <<<"\
$( ((WITH_TESTS)) || echo nocheck) \
$( ((WITH_DOCS)) || echo nodoc) \
$( ((WITH_DOCS)) || echo nodoc) \
pkg.systemd.upstream \
")" \
- DEB_CFLAGS_APPEND="-O${OPTIMIZATION:-0}" \
+ DEB_CFLAGS_APPEND="$CFLAGS" \
+ DEB_CXXFLAGS_APPEND="$CFLAGS" \
+ DEB_LDFLAGS_APPEND="$LDFLAGS" \
DPKG_FORCE="unsafe-io" \
DPKG_DEB_COMPRESSOR_TYPE="none" \
DH_MISSING="--fail-missing" \
CONFFLAGS_UPSTREAM="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
+ GENSYMBOLS_LEVEL="$( ((LLVM)) && echo 0 || echo 1)" \
dpkg-buildpackage \
--no-pre-clean \
--unsigned-changes \
iputils-ping
isc-dhcp-server
libcap-ng-utils
+ libclang-rt-dev
libtss2-rc0
libtss2-tcti-device0
locales
InitrdPackages=
btrfs-progs
+ libclang-rt-dev
tpm2-tools
InitrdVolatilePackages=
ARCH="$(rpm --eval %_arch)"
SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
-EXTRA_CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
if ((WITH_DEBUG)); then
- EXTRA_CFLAGS="$EXTRA_CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
+ CFLAGS="$CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
+fi
+if ((LLVM)); then
+ # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
+ CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+fi
+
+LDFLAGS="$(rpm --eval "%{?build_ldflags}") $LDFLAGS"
+if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
+ LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+fi
+
+# A macro can't have an empty body and currently opensuse does not specify any of its own linker flags so
+# set LDFLAGS to %{nil} if there are no linker flags.
+if [[ -z "${LDFLAGS// }" ]]; then
+ LDFLAGS="%{nil}"
fi
build() {
# TODO: Replace __meson_auto_features override with meson_extra_configure_options once the suse spec
# starts to use it.
# shellcheck disable=SC2046
+ env \
+ CC="$( ((LLVM)) && echo clang || echo gcc)" \
+ CXX="$( ((LLVM)) && echo clang++ || echo g++)" \
+ CC_LD="$( ((LLVM)) && echo lld)" \
+ CXX_LD="$( ((LLVM)) && echo lld)" \
rpmbuild \
-bb \
--build-in-place \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
--define "__check_files sh -c '$(rpm --define "_topdir /var/tmp" --eval %__check_files) | tee /tmp/unpackaged-files'" \
- --define "build_cflags $(rpm --eval %build_cflags) $EXTRA_CFLAGS" \
+ --define "build_cflags $(rpm --eval "%{?build_cflags}") $CFLAGS" \
+ --define "build_cxxflags $(rpm --eval "%{?build_cxxflags}") $CFLAGS" \
+ --define "build_ldflags $LDFLAGS" \
--define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
--define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
--define "__meson_auto_features auto -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
docbook-xsl-stylesheets
f2fs-tools
gawk
- git-core
gcc-c++
+ git-core
glibc-locale-base
gnutls
grep
InitrdPackages=
btrfs-progs
+ clang
kmod
libkmod2
tpm2.0-tools