]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Switch to O0 and disable FORTIFY_SOURCE
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 17 Apr 2024 14:10:26 +0000 (16:10 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 17 Apr 2024 15:36:33 +0000 (17:36 +0200)
-Og still causes a lot of "<optimized out>" in GDB so let's use -O0
instead and disable FORTIFY_SOURCE as it doesn't work without
optimizations enabled.

mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot
mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot
mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot

index fb8558036023efdf7f23d1a4d0866eece81affca..8eebd62b047badf0887d99aed42217ef8287aaa3 100755 (executable)
@@ -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 <<EOF
-CFLAGS="$CFLAGS -Og"
+CFLAGS="$CFLAGS -O0 -Wp,-D_FORTIFY_SOURCE=0"
 OPTIONS=(
     docs
     !libtool
index 81613f3954a31a4c1418313dd9f5319366e18fcc..0cba71bf7a7231ac60c5f6b654a8015f7825385e 100755 (executable)
@@ -31,7 +31,8 @@ DIST="$(rpm --eval %dist)"
 ARCH="$(rpm --eval %_arch)"
 SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
 
-EXTRA_CFLAGS="-Og"
+# TODO: Drop -D_FORTIFY_SOURCE when we switch to CentOS Stream 10.
+EXTRA_CFLAGS="-O0 -Wp,-D_FORTIFY_SOURCE=0"
 if ((WITH_DEBUG)); then
     EXTRA_CFLAGS="$EXTRA_CFLAGS -ffile-prefix-map=../src=$SRCDEST"
 fi
@@ -71,6 +72,7 @@ rpmbuild \
     --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
     --define "__script_requires %{nil}" \
     --define "_find_debuginfo_dwz_opts %{nil}" \
+    --define "_fortify_level 0" \
     --undefine _lto_cflags \
     --noclean \
     "pkg/$ID/systemd.spec"
index 3a89e49c5bb0dfe3190a0527edede831a365342b..a8775d05f14df6e2d0c56d1068daa2ac428f399d 100755 (executable)
@@ -46,15 +46,15 @@ build() {
         $( ((WITH_TESTS)) || echo nocheck) \
         $( ((WITH_DOCS)) || echo nodoc) \
         $( ((WITH_DEBUG)) || echo nostrip) \
-        terse
+        terse \
         optimize=-lto \
+        noopt \
     " \
     DEB_BUILD_PROFILES="\
         $( ((WITH_TESTS)) || echo nocheck) \
         $( ((WITH_DOCS)) || echo nodoc) \
         pkg.systemd.upstream \
     " \
-    DEB_CFLAGS_APPEND="-Og" \
     DPKG_FORCE="unsafe-io" \
     DPKG_DEB_COMPRESSOR_TYPE="none" \
     DH_MISSING="--fail-missing" \