From 88221219a3290ee20de27aa030c2b23f03d8238a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Jul 2024 17:15:43 +0200 Subject: [PATCH] mkosi: Disable unique debug source names We use -fdebug-prefix-map= because debugedit doesn't work for us (for a currently unknown reason since it's the most obtuse code I've ever had the pleasure of reading). With all the unique macros enabled, the destination directory we pass to -fdebug-prefix-map= includes the package release. The release is either the timestamp of the current commit or the current time if the working tree is dirty. This means it generally changes every time we rerun the build script. However, meson only reads compiler arguments the first time it is invoked or if --wipe is specified. This means that on a rerun -fdebug-prefix-map= will be configured wrong and the build will fail. Let's prevent this from happening by disabling the unique debug source names by overriding the --unique-debug-src-base option that is passed to find-debuginfo.sh by rpm via the _find_debuginfo_opts macro. --- .../build/mkosi.conf.d/centos-fedora/mkosi.build.chroot | 7 ++----- .../build/mkosi.conf.d/opensuse/mkosi.build.chroot | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot index dc45e25990..ce1e162ebf 100755 --- a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot @@ -31,10 +31,6 @@ fi 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" - COMMON_MACRO_OVERRIDES=( --define "toolchain $( ((LLVM)) && echo clang || echo gcc)" --define "_fortify_level 0" @@ -47,7 +43,7 @@ COMMON_MACRO_OVERRIDES=( # TODO: Drop -U_FORTIFY_SOURCE when we switch to CentOS Stream 10. MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" if ((WITH_DEBUG)); then - MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST" + MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=/usr/src/debug/systemd" fi if ((LLVM)); then # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. @@ -105,6 +101,7 @@ CXX_LD="$( ((LLVM)) && echo lld)" \ --define "__brp_check_rpaths %{nil}" \ --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \ --define "__script_requires %{nil}" \ + --define "_find_debuginfo_opts --unique-debug-src-base \"%{name}\"" \ --define "_find_debuginfo_dwz_opts %{nil}" \ --define "_fixperms true" \ --undefine _package_note_flags \ diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot index 82e81cc9d8..95d747cd93 100755 --- a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot @@ -36,13 +36,9 @@ fi 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" - MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" if ((WITH_DEBUG)); then - MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST" + MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=/usr/src/debug/systemd" fi if ((LLVM)); then # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. @@ -104,6 +100,7 @@ build() { --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \ --define "__script_requires %{nil}" \ --define "_find_debuginfo_dwz_opts %{nil}" \ + --define "_find_debuginfo_opts --unique-debug-src-base \"%{name}\"" \ --define "_fixperms true" \ --noclean \ "$@" \ -- 2.25.1