From 8e728c14ec802059bf6b586545c4e5241b64920a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 17 Apr 2024 14:55:08 +0200 Subject: [PATCH 1/5] 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. --- .../10-centos-fedora/mkosi.build.chroot | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot index e2d20d4b87..bb6854c38f 100755 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot @@ -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}" \ From 7f1d7fed801181d7551965477c298ea083a260a4 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 17 Apr 2024 15:38:24 +0200 Subject: [PATCH 2/5] mkosi: Override build_cflags instead of _distro_extra_cflags The latter is not supported on CentOS Stream 9. --- .../system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot index bb6854c38f..a1f77bcc9b 100755 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot @@ -57,7 +57,7 @@ rpmbuild \ $( ((WITH_DEBUG)) || echo "debug_package %{nil}") \ --define "version_override $VERSION" \ --define "release_override $RELEASE" \ - --define "_distro_extra_cflags $EXTRA_CFLAGS" \ + --define "build_cflags $(rpm --eval %build_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}" \ From 42ca6c27738427b66c7e518a6777305c22c60545 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 17 Apr 2024 15:54:53 +0200 Subject: [PATCH 3/5] mkosi: Disable DWARF debug info optimization We care more about fast builds in this case so disable the DWARF debug optimization that's done by default. --- .../system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot index a1f77bcc9b..81613f3954 100755 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot @@ -70,6 +70,7 @@ rpmbuild \ --define "__brp_check_rpaths %{nil}" \ --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \ --define "__script_requires %{nil}" \ + --define "_find_debuginfo_dwz_opts %{nil}" \ --undefine _lto_cflags \ --noclean \ "pkg/$ID/systemd.spec" From 241d792c929fddeb630124ff40c53fb4250686e0 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 17 Apr 2024 16:10:26 +0200 Subject: [PATCH 4/5] mkosi: Switch to O0 and disable FORTIFY_SOURCE -Og still causes a lot of "" in GDB so let's use -O0 instead and disable FORTIFY_SOURCE as it doesn't work without optimizations enabled. --- .../system/mkosi.conf.d/10-arch/mkosi.build.chroot | 10 +++++----- .../mkosi.conf.d/10-centos-fedora/mkosi.build.chroot | 4 +++- .../mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot index fb85580360..8eebd62b04 100755 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot @@ -20,12 +20,12 @@ mount --mkdir --rbind "$PWD/pkg/$ID" "pkg/$ID/src/" # shellcheck source=/dev/null . /etc/makepkg.conf -# Override the default options. Use -Og because -O0 doesn't work with FORTIFY_SOURCE. 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. +# 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 < Date: Wed, 17 Apr 2024 16:59:08 +0200 Subject: [PATCH 5/5] mkosi: Drop workarounds With the latest Github Actions image release none of these should be required anymore (20240414.1.1). --- .github/workflows/mkosi.yml | 9 --------- mkosi.images/system/mkosi.conf.d/10-centos/mkosi.conf | 1 - 2 files changed, 10 deletions(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 2f5d5b28f5..2cffc3cf82 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -119,15 +119,6 @@ jobs: systemd.default_device_timeout_sec=180 EOF - # For erofs, we have to install linux-modules-extra-azure, but that doesn't match the running kernel - # version, so we can't load the erofs module. squashfs is a builtin module so we use that instead. - - mkdir -p mkosi.images/system/mkosi.repart/10-usr.conf.d - tee mkosi.images/system/mkosi.repart/10-usr.conf.d/squashfs.conf <