Source: binutils
Version: 2.43.50.20250108-1
Tags: patch
X-Debbugs-Cc: [email protected], [email protected]

Hi Matthias,

I recently mentioned binutils multiarch problem to you and promised a
patch. With much delay, here we go.

Let me start from where I saw the problem and then move into the messy
details. If you build targeted cross binutils (i.e. nothing a buildd
would ever do), you receive binutils-<targettriplet> and
binutils-for-host:<targetarch>. The latter depends on the former and
both depend on binutils-common. While the former can satisfy its
dependency from the host, the latter cannot and thus binutils-for-host
becomes uninstallable. This is unfortunate.

Fundamentally, there are two ways out of this misery. One is making
binutils-common Multi-Arch: foreign (and thus also reusing the host's)
and the other is also building it. To figure this out, we need a bit of
history. I am the one who originally added the binutils-common binary
package. The reason was that both binutils and binutils-<triplet> need
to refer to manual pages and locales and they as binutils was about to
depend on binutils-<triple>, binutils-<triplet> could no longer depend
on binutils. I originally proposed it as Arch:all, but Matthias kindly
pointed out that if buildds would finish at different times, buildds
would break for not being able to install build-essential and thus
Matthias changed to Arch:any before it could cause any harm. Eventually
it became M-A:same rather than M-A:foreign. Now we could simply change
it to M-A:foreign, right?

No. Back then all architectures would support gold, but gold is
deprecated and e.g. riscv64 doesn't support gold. As a result, the
riscv64 binutils-common package lacks locales for gold. Later, gprofng
was added and binutils-common includes its manual pages on amd64 and
arm64 but not on armel nor armhf. So unfortunately, binutils-common is
no longer M-A:foreign as its content varies per architecture.

I then looked into building binutils-common and that turned out to be a
problem. If building binutils-common:amd64, we'd want to include the
gprofng bits of course (or it would be unreproducible), but the upstream
configure requires that both host and target are amd64 (or arm64) in
order for it to actually build gprofng. Therefore, we'd have to add
gcc-x86-64-linux-gnu [armel armhf ...] to Build-Depends and those
packages do not exist nor do we want the native binutils build to depend
on cross toolchains. So no we cannot.

So it seems like we really cannot fix this. I reached out to Colin and
Johannes for ideas and in those discussions it became clear that
binutils-<triplet> actually does not reliably provide gprofng. For
instance, binutils-x86-64-linux-gnu:arm64 would miss gprofng. Actually,
providing gprofng in a non-native setting doesn't make much sense in the
first place, but that really means that it should not be part of
binutils-<triplet> ever. It already is not in the cross case, so what I
am proposing now is removing gprofng from binutils-<triplet> (and as a
result from binutils-common). The right package to put it to likely is
plain binutils, which still exists as a container of symlinks presently,
but there is little reason for it not to carry gprofng.

I'm attaching a patch that performs this move. Once this patch has been
accepted, we can move forward with the other problems. We may then build
a -common package that contains gold even on riscv64 or we may produce a
-common package as part of the targeted cross binutils build. I'm not
sure which of these is better at this time, but both variants require
that we move gprofng out of there.

What this patch also does is remove the triplet-prefixed gprofng as
arguably it can only be used natively in the first place. I performed
test builds of binutils on amd64, arm64, armel, armhf, i386, ran
lintian, piuparts and autopkgtests (including those for rdeps). I looked
into some of the autopkgtest failures, but the sample I looked at where
not caused by my change or already reported. Before applying the patch,
you should sed -i -e 's/\(999:\)\?0TODO/$actual_binutils_version/' on
the patch file. The addition of binutils-dbg incurs a trip through NEW.

Helmut
diff --minimal -Nru binutils-2.43.50.20250108/debian/binutils-common.conffiles 
binutils-2.43.50.20250108/debian/binutils-common.conffiles
--- binutils-2.43.50.20250108/debian/binutils-common.conffiles  2022-09-29 
11:39:27.000000000 +0200
+++ binutils-2.43.50.20250108/debian/binutils-common.conffiles  2025-01-17 
18:09:28.000000000 +0100
@@ -1 +1 @@
-/etc/gprofng.rc
+remove-on-upgrade /etc/gprofng.rc
diff --minimal -Nru binutils-2.43.50.20250108/debian/binutils.conffiles 
binutils-2.43.50.20250108/debian/binutils.conffiles
--- binutils-2.43.50.20250108/debian/binutils.conffiles 1970-01-01 
01:00:00.000000000 +0100
+++ binutils-2.43.50.20250108/debian/binutils.conffiles 2022-09-29 
11:39:27.000000000 +0200
@@ -0,0 +1 @@
+/etc/gprofng.rc
diff --minimal -Nru binutils-2.43.50.20250108/debian/binutils.preinst 
binutils-2.43.50.20250108/debian/binutils.preinst
--- binutils-2.43.50.20250108/debian/binutils.preinst   1970-01-01 
01:00:00.000000000 +0100
+++ binutils-2.43.50.20250108/debian/binutils.preinst   2025-01-17 
18:09:28.000000000 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if test "$1" = upgrade &&
+       test -e /etc/gprofng.rc.dpkg-old &&
+       ! test -e /etc/gprofng.rc &&
+       dpkg --compare-cversions "$2" lt "999:0TODO"
+then
+       # Moving gprofng.rc from binutils-common to binutils.
+       mv /etc/gprofng.rc.dpkg-old /etc/gprofng.rc
+fi
+
+exit 0
diff --minimal -Nru binutils-2.43.50.20250108/debian/changelog 
binutils-2.43.50.20250108/debian/changelog
--- binutils-2.43.50.20250108/debian/changelog  2025-01-09 00:34:21.000000000 
+0100
+++ binutils-2.43.50.20250108/debian/changelog  2025-01-17 18:09:28.000000000 
+0100
@@ -1,3 +1,10 @@
+binutils (2.43.50.20250108-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Move gprofng to binutils. (Closes: #-1)
+
+ -- Helmut Grohne <[email protected]>  Fri, 17 Jan 2025 18:09:28 +0100
+
 binutils (2.43.50.20250108-1) unstable; urgency=medium
 
   * New upstream snapshot, taken from the trunk.
diff --minimal -Nru binutils-2.43.50.20250108/debian/control 
binutils-2.43.50.20250108/debian/control
--- binutils-2.43.50.20250108/debian/control    2024-12-30 12:46:20.000000000 
+0100
+++ binutils-2.43.50.20250108/debian/control    2025-01-17 18:09:28.000000000 
+0100
@@ -65,11 +65,30 @@
   binutils-multiarch (<< 2.27-8)
 Provides: elf-binutils, ${gold:Provides}
 Suggests: binutils-doc (>= ${source:Version}), gprofng-gui
+Breaks:
+ binutils-aarch64-linux-gnu (<< 0TODO),
+ binutils-i686-linux-gnu (<< 0TODO),
+ binutils-riscv64-linux-gnu (<< 0TODO),
+ binutils-x86-64-linux-gnu (<< 0TODO),
+Replaces:
+ binutils-common (<< 999:0TODO),
+ binutils-aarch64-linux-gnu (<< 999:0TODO),
+ binutils-i686-linux-gnu (<< 999:0TODO),
+ binutils-riscv64-linux-gnu (<< 999:0TODO),
+ binutils-x86-64-linux-gnu (<< 999:0TODO),
 Description: GNU assembler, linker and binary utilities
  The programs in this package are used to assemble, link and manipulate
  binary and object files.  They may be used in conjunction with a compiler
  and various libraries to build programs.
 
+Package: binutils-dbg
+Section: debug
+Priority: optional
+Architecture: amd64 arm64 i386 riscv64
+Depends: binutils (= ${binary:Version}), ${binutils:native}-dbg (= 
${binary:Version})
+Description: GNU assembler, linker and binary utilities(debug symbols)
+ This package provides debug symbols for binutils.
+
 Package: libctf-nobfd0
 Architecture: any
 Multi-Arch: same
diff --minimal -Nru binutils-2.43.50.20250108/debian/control.in 
binutils-2.43.50.20250108/debian/control.in
--- binutils-2.43.50.20250108/debian/control.in 2024-12-30 12:44:18.000000000 
+0100
+++ binutils-2.43.50.20250108/debian/control.in 2025-01-17 18:09:28.000000000 
+0100
@@ -65,11 +65,30 @@
   binutils-multiarch (<< 2.27-8)
 Provides: elf-binutils, ${gold:Provides}
 Suggests: binutils-doc (>= ${source:Version}), gprofng-gui
+Breaks:
+ binutils-aarch64-linux-gnu (<< 0TODO),
+ binutils-i686-linux-gnu (<< 0TODO),
+ binutils-riscv64-linux-gnu (<< 0TODO),
+ binutils-x86-64-linux-gnu (<< 0TODO),
+Replaces:
+ binutils-common (<< 999:0TODO),
+ binutils-aarch64-linux-gnu (<< 999:0TODO),
+ binutils-i686-linux-gnu (<< 999:0TODO),
+ binutils-riscv64-linux-gnu (<< 999:0TODO),
+ binutils-x86-64-linux-gnu (<< 999:0TODO),
 Description: GNU assembler, linker and binary utilities
  The programs in this package are used to assemble, link and manipulate
  binary and object files.  They may be used in conjunction with a compiler
  and various libraries to build programs.
 
+Package: binutils-dbg
+Section: debug
+Priority: optional
+Architecture: amd64 arm64 i386 riscv64
+Depends: binutils (= ${binary:Version}), ${binutils:native}-dbg (= 
${binary:Version})
+Description: GNU assembler, linker and binary utilities(debug symbols)
+ This package provides debug symbols for binutils.
+
 Package: libctf-nobfd0
 Architecture: any
 Multi-Arch: same
diff --minimal -Nru binutils-2.43.50.20250108/debian/rules 
binutils-2.43.50.20250108/debian/rules
--- binutils-2.43.50.20250108/debian/rules      2024-12-04 17:12:57.000000000 
+0100
+++ binutils-2.43.50.20250108/debian/rules      2025-01-17 18:09:28.000000000 
+0100
@@ -456,7 +456,7 @@
        rm -rf stamps
        find . -name \*.gmo -o -name \*~ -o -name \*.info ! -name sysroff.info 
| xargs -r rm -f
        rm -f test-summary*
-       rm -rf $(d_bin) $(d_com) $(d_lib) $(d_lib)-dbg $(d_nat) $(d_nat)-dbg \
+       rm -rf $(d_bin) $(d_bin)-dbg $(d_com) $(d_lib) $(d_lib)-dbg $(d_nat) 
$(d_nat)-dbg \
          $(d_hst) $(d_dev) $(d_mul) $(d_mul)-dbg $(d_mdev) $(d_doc) \
          $(d_hppa64) $(d_hppa64)-dbg $(d_src) $(d_bld) \
          $(d_ctf) $(d_ctf)-dbg $(d_ctfn) $(d_ctfn)-dbg $(d_gpng) $(d_gpng)-dbg 
\
@@ -1012,10 +1012,13 @@
        mv $(d_bin)/$(PF)/lib/$(DEB_HOST_MULTIARCH)/ldscripts \
                $(d_nat)/$(PF)/lib/$(DEB_HOST_MULTIARCH)/.
 
-       $(install_dir) $(d_com)/$(PF)/share/man
-       mv $(d_bin)/$(PF)/share/man/man1 $(d_com)/$(PF)/share/man/.
-       for f in $(d_com)/$(PF)/share/man/man1/*.1; do \
+       $(install_dir) $(d_com)/$(PF)/share/man/man1
+       set -e; for f in $(d_bin)/$(PF)/share/man/man1/*.1; do \
          sed -i -e '/^\.TH /s/[0-9]*-[0-9]*-[0-9]*/$(BUILD_DAY)/' $$f; \
+         case "$$f" in \
+           *gprofng*) ;; \
+           *) mv "$$f" '$(d_com)/$(PF)/share/man/man1/' ;; \
+          esac;        \
        done
 
 ifeq ($(with_gprofng),yes)
@@ -1254,11 +1257,6 @@
        rmdir $(d_bin)/$(PF)/include/
 
 ifeq ($(with_gprofng),yes)
-       $(install_dir) $(d_com)/etc
-       mv $(d_bin)/etc/gprofng.rc $(d_com)/etc/.
-endif
-
-ifeq ($(with_gprofng),yes)
        : # Remove the gp-* compat symlinks
        rm -f $(PF)/bin/gp-*
 endif
@@ -1277,6 +1275,9 @@
        done
 ifeq ($(with_native),yes)
        $(call strip_package, $(p_nat), $(d_nat))
+  ifeq ($(with_gprofng),yes)
+       $(call strip_package, $(p_bin), $(d_bin))
+  endif
 endif
 ifeq ($(with_multiarch),yes)
        for i in \
@@ -1605,7 +1606,8 @@
 endif
 
        : # install maintainer scripts
-       $(install_dir) $(d_bin)/DEBIAN
+       $(install_dir) $(d_bin)/DEBIAN $(d_bin)-dbg/DEBIAN
+       $(install_script) debian/binutils.preinst $(d_bin)/DEBIAN/preinst
 
        $(install_dir) $(d_lib)/DEBIAN $(d_lib)-dbg/DEBIAN
        $(install_file) debian/binutils.triggers $(d_lib)/DEBIAN/triggers
@@ -1621,13 +1623,15 @@
        $(install_file) debian/libctf-nobfd0.shlibs $(d_ctfn)/DEBIAN/shlibs
        $(install_file) debian/libctf-nobfd0.symbols $(d_ctfn)/DEBIAN/symbols
 
+       $(install_dir) $(d_com)/DEBIAN
+       $(install_file) debian/binutils-common.conffiles 
$(d_com)/DEBIAN/conffiles
+
 ifeq ($(with_gprofng),yes)
        $(install_dir) $(d_gpng)/DEBIAN $(d_gpng)-dbg/DEBIAN
        $(install_file) debian/binutils.triggers $(d_gpng)/DEBIAN/triggers
        $(install_file) debian/libgprofng0.shlibs $(d_gpng)/DEBIAN/shlibs
 
-       $(install_dir) $(d_com)/DEBIAN
-       $(install_file) debian/binutils-common.conffiles 
$(d_com)/DEBIAN/conffiles
+       $(install_file) debian/binutils.conffiles $(d_bin)/DEBIAN/conffiles
 endif
        $(install_dir) $(d_sfrm)/DEBIAN $(d_sfrm)-dbg/DEBIAN
        $(install_file) debian/binutils.triggers $(d_sfrm)/DEBIAN/triggers
@@ -1753,10 +1757,16 @@
        find $(d_com)/$(PF)/share/doc/$(p_bin)/ -type f ! -name bbconv.pl | 
xargs gzip -9n
        gzip -9n $(d_com)/$(PF)/share/doc/$(p_com)/changelog.Debian
        gzip -9n $(d_com)/$(PF)/share/man/man1/*.1
+ifeq ($(with_gprofng),yes)
+       gzip -9n $(d_bin)/$(PF)/share/man/man1/*.1
+endif
 
        gzip -9n $(d_sfrm)/$(PF)/share/doc/$(p_sfrm)/changelog.Debian
 
        : # Finish it all up
+ifeq ($(with_gprofng),yes)
+       find $(d_bin) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs 
dpkg-shlibdeps
+endif
        dpkg-gencontrol -P$(d_bin) -p$(p_bin) \
                $(CONFLICTS_TARGET_$(DEB_HOST_ARCH)) $(gold_provides) \
                -Vbinutils:native=$(p_nat)
@@ -1797,6 +1807,8 @@
        cd $(d_gpng) && find -type f  ! -regex './DEBIAN/.*' -printf '%P\n' | 
LC_ALL=C sort | xargs md5sum > DEBIAN/md5sums
        dpkg-gencontrol -P$(d_gpng)-dbg -p$(p_gpng)-dbg
        cd $(d_gpng)-dbg && find -type f  ! -regex './DEBIAN/.*' -printf '%P\n' 
| LC_ALL=C sort | xargs md5sum > DEBIAN/md5sums
+       dpkg-gencontrol -P$(d_bin)-dbg -p$(p_bin)-dbg -Vbinutils:native=$(p_nat)
+       cd $(d_bin)-dbg && find -type f  ! -regex './DEBIAN/.*' -printf '%P\n' 
| LC_ALL=C sort | xargs md5sum > DEBIAN/md5sums
 endif
 
        rm -f debian/substvars
@@ -1866,14 +1878,17 @@
                xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
        $(DPKG_DEB) --build $(d_ctfn)-dbg ..
 ifeq ($(with_gprofng),yes)
-       $(CHOWN) -R root:root $(d_gpng) $(d_gpng)-dbg
-       chmod -R go=rX  $(d_gpng) $(d_gpng)-dbg
+       $(CHOWN) -R root:root $(d_gpng) $(d_gpng)-dbg $(d_bin)-dbg
+       chmod -R go=rX  $(d_gpng) $(d_gpng)-dbg $(d_bin)-dbg
        find $(d_gpng) -depth -newermt '$(BUILD_DATE)' -print0 | \
                xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
        $(DPKG_DEB) --build $(d_gpng) ..
        find $(d_gpng)-dbg -depth -newermt '$(BUILD_DATE)' -print0 | \
                xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
        $(DPKG_DEB) --build $(d_gpng)-dbg ..
+       find $(d_bin)-dbg -depth -newermt '$(BUILD_DATE)' -print0 | \
+               xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
+       $(DPKG_DEB) --build $(d_bin)-dbg ..
 endif
        find $(d_sfrm) -depth -newermt '$(BUILD_DATE)' -print0 | \
                xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
diff --minimal -Nru binutils-2.43.50.20250108/debian/rules.defs 
binutils-2.43.50.20250108/debian/rules.defs
--- binutils-2.43.50.20250108/debian/rules.defs 2024-11-26 13:02:34.000000000 
+0100
+++ binutils-2.43.50.20250108/debian/rules.defs 2025-01-17 18:09:28.000000000 
+0100
@@ -34,10 +34,6 @@
 
 binutils_programs = addr2line ar as c++filt elfedit gprof ld ld.bfd
 binutils_programs += nm objcopy objdump ranlib readelf size strings strip
-ifeq ($(with_gprofng),yes)
-  binutils_programs += gprofng gprofng-collect-app gprofng-archive
-  binutils_programs += gprofng-display-html gprofng-display-src 
gprofng-display-text
-endif
 ifeq ($(with_gold),yes)
   binutils_programs += gold ld.gold dwp
 endif

Reply via email to