mkosi: Set up -ffile-prefix-map= correctly when building debuginfo packages

This makes sure that the debuginfo files contain source files pointing
to the source files shipped by the debugsource package.

Normally this should be done automatically by rpm invoking debugedit
but for some unknown reason debugedit refuses to rewrite the source
files in our binaries.

Given that debugedit is completely undebugable (does not generate any
logs at all, and its source code is ridiculously obtuse), let's set
-ffile-prefix-map= when building instead which achieves the same
effect.
This commit is contained in:
Daan De Meyer
2024-04-17 15:21:01 +02:00
parent d398a2e004
commit 8e728c14ec
@@ -24,6 +24,18 @@ tee --append /usr/lib/rpm/redhat/macros <<'EOF'
%{nil}
EOF
VERSION="$(cat meson.version)"
RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")"
DIST="$(rpm --eval %dist)"
ARCH="$(rpm --eval %_arch)"
SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
EXTRA_CFLAGS="-Og"
if ((WITH_DEBUG)); then
EXTRA_CFLAGS="$EXTRA_CFLAGS -ffile-prefix-map=../src=$SRCDEST"
fi
IFS=
# TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
# https://github.com/mesonbuild/meson/pull/12835 is available.
@@ -43,9 +55,9 @@ rpmbuild \
--define "_binary_payload w.ufdio" \
$( ((WITH_DEBUG)) || echo --define) \
$( ((WITH_DEBUG)) || echo "debug_package %{nil}") \
--define "version_override $(cat meson.version)" \
--define "release_override $(date "+%Y%m%d%H%M%S" --date "@$TS")" \
--define "_distro_extra_cflags -Og" \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
--define "_distro_extra_cflags $EXTRA_CFLAGS" \
--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}" \