• Bug#1088320: libdpkg-perl: Enable generation of sframes.

    From Sebastian Andrzej Siewior@1:229/2 to All on Tue Nov 26 23:50:01 2024
    XPost: linux.debian.bugs.dist
    From: [email protected]

    Package: libdpkg-perl
    Version: 1.22.11
    Severity: normal
    Tags: sid patch

    SFrame is a stack trace format.
    https://sourceware.org/binutils/wiki/sframe

    This can be generated since binutils 2.41.
    There are patches against the Linux kernel to let perf use the new
    format
    https://lore.kernel.org/all/[email protected]/

    It would be nice if the compiled binaries could create the additional
    sframe so it is there and can be used to generate backtraces. This can
    coexist with the eh_frame.

    Sebastian

    From: Sebastian Andrzej Siewior <[email protected]>
    Date: Tue, 26 Nov 2024 23:22:58 +0100
    Subject: [PATCH] Enable SFrame generation if supported.

    SFrame is a stack trace format.
    https://sourceware.org/binutils/wiki/sframe

    This can be generated since binutils 2.41.
    There are patches against the Linux kernel to let perf use the new
    format
    https://lore.kernel.org/all/[email protected]/

    It would be nice if the compiled binaries could create the additional
    sframe so it is there and can be used to generate backtraces. This can
    coexist with the eh_frame.

    Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
    ---
    scripts/Dpkg/Vendor/Debian.pm | 12 ++++++++++++
    1 file changed, 12 insertions(+)

    diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index edf94bc199163..44a6fb328dd05 100644
    --- a/scripts/Dpkg/Vendor/Debian.pm
    +++ b/scripts/Dpkg/Vendor/Debian.pm
    @@ -647,6 +647,18 @@ sub add_build_flags {
    }
    }

    + # Enable S-Frame support on supported architectures.
    + my $arch = Dpkg::Arch::get_host_arch();
    + if (any { $arch eq $_ } qw(amd64 arm64)) {
    + my $flag = '-Wa,--gsframe';
    +
    + $flags->append('ASFLAGS', '--gsframe');
    + $flags->append('CFLAGS', $flag);
    + $flags->append('CXXFLAGS', $flag);
    + $flags->append('OBJCFLAGS', $flag);
    + $flags->append('OBJCXXFLAGS', $flag);
    + }
    +
    # XXX: Handle *_FOR_BUILD flags here until we can properly initialize them.
    require Dpkg::Arch;

    --
    2.45.2

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Guillem Jover@1:229/2 to Sebastian Andrzej Siewior on Tue Dec 17 02:30:01 2024
    XPost: linux.debian.bugs.dist
    From: [email protected]

    Control: tag -1 moreinfo

    Hi!

    On Tue, 2024-11-26 at 23:45:26 +0100, Sebastian Andrzej Siewior wrote:
    Package: libdpkg-perl
    Version: 1.22.11
    Severity: normal
    Tags: sid patch

    SFrame is a stack trace format.
    https://sourceware.org/binutils/wiki/sframe

    This can be generated since binutils 2.41.
    There are patches against the Linux kernel to let perf use the new
    format
    https://lore.kernel.org/all/[email protected]/

    It would be nice if the compiled binaries could create the additional
    sframe so it is there and can be used to generate backtraces. This can coexist with the eh_frame.

    Thanks for the patch! This would involve the usual procedure to add
    flags to the default set, as mentioned here:

    https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_Can_we_add_support_for_new_default_build_flags_to_dpkg-buildflags.3F

    Notice that not all are supposed to be requirements, which depends on
    the expected effect of the flags at hand.

    In this case though my first questions would be:

    * Why are these not enabled by default in binutils upstream?
    * How much bigger do objects get after this?
    * Can this increase linker times substantially?
    * Is there any downside, like backwards compat issues or similar?

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Sebastian Andrzej Siewior@1:229/2 to Guillem Jover on Fri Dec 20 22:20:01 2024
    XPost: linux.debian.bugs.dist
    From: [email protected]

    Control: tag -1 - moreinfo

    On 2024-12-17 02:19:30 [+0100], Guillem Jover wrote:

    Hi!
    Hi,

    Thanks for the patch! This would involve the usual procedure to add
    flags to the default set, as mentioned here:

    https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_Can_we_add_support_for_new_default_build_flags_to_dpkg-buildflags.3F

    Thank you for pointer.

    Notice that not all are supposed to be requirements, which depends on
    the expected effect of the flags at hand.

    In this case though my first questions would be:

    * Why are these not enabled by default in binutils upstream?

    This is debug functionality, I guess same story as with "-g" or the
    frame pointer functionality in general.

    * How much bigger do objects get after this?

    It is always referred to as "low overhead stack straces". Here is a dpkg example. I rebuilt 1.22.11 with and without the sframe.

    orig sframe + % +bytes file
    322576 359512 ~11.5 36936 usr/bin/dpkg
    174624 203368 ~16.5 28744 usr/bin/dpkg-deb
    162584 187232 ~15.5 24648 usr/bin/dpkg-divert
    166672 195416 ~17.2 28744 usr/bin/dpkg-query
    55632 63896 ~14.9 8264 usr/bin/dpkg-realpath
    137712 158264 ~14.9 20552 usr/bin/dpkg-split
    72192 80456 ~11.4 8264 usr/bin/dpkg-statoverride
    92656 105016 ~13.3 12360 usr/bin/dpkg-trigger
    59712 63880 ~ 7.0 4168 usr/bin/update-alternatives
    44464 48632 ~ 9.4 4168 usr/sbin/start-stop-daemon

    For dpkg, I also noticed
    470336 normal usr/lib/debug/.build-id/99/9b34fb6dabbe5d09befb4cae69906981259a2d.debug
    508248 sframe usr/lib/debug/.build-id/73/79b3f024323c03b3133329de18f56b66d9fa47.debug

    37912 byte increase in the debug file. So I guess the other debug files increase in a similar fashion. Not sure why…

    * Can this increase linker times substantially?
    I don't think so since it some metadata. I am however not in the
    position to make guesses. Is there a way to make a test?

    * Is there any downside, like backwards compat issues or similar?
    Not that I am aware of. It was added in binutils initially as version 1
    and then replaced with version 2 (current bintuils) in a backwards
    compatible way. Version 3 is in development and should follow the same
    way.

    Thanks,
    Guillem

    Sebastian

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)