Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-05-13 Thread Bastian Blank
Hi

On Sun, May 12, 2024 at 11:54:42PM +0200, Helmut Grohne wrote:
> On Sun, May 12, 2024 at 07:35:09PM +0200, Bastian Blank wrote:
> > > 1. API expectation of *-$arch-cross packages
> > I asked exactly that in
> > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065416#55
> I guess the best description is to be found in man dpkg-cross
> "Conversion process" and even that isn't entirely helpful.

This is now
https://salsa.debian.org/kernel-team/linux/-/merge_requests/1076

Not really tested however.  Until cross-toolchain-base is rebuilt, we
don't have any test subject.

> > > 4. cross-toolchain-base could drop its Build-Conflicts. This may cause
> > >further problems though.
> > >Patch: https://bugs.debian.org/1067370#17
> > 
> > The build will now see multiple architectures of headers.  So it needs
> > to handle this both for native (where build-conflicts can't be used
> > anyway) and cross the same.
> 
> I don't understand what you are trying to say here. c-t-b only builds
> Arch:all packages, so the terms native and cross appear to not apply.
> Then again we also don't know what "further problems" are. I hope
> Matthias can shed some light here.

gcc-13, the native compiler, builds fine with headers in /usr/include
and /usr/include/$multiarch.  gcc-13-cross, the cross compiler, is
reported to not build with this, however I can't verify that right now.

> > On Sun, May 12, 2024 at 01:53:33PM +0200, Helmut Grohne wrote:
> > > 2+3+6+7. linux-libc-dev could be split into linux-libc-dev-common
> > >arch:all m-a:foreign and the symlink farms could be kept in
> > >linux-libc-dev:any m-a:same retaining the size reduction.
> > 
> > This would not actually work.  linux-libc-dev-common would only contain
> > known architectures.  So the current "change config, build
> > linux-libc-dev" will not longer work as well.  This package would then
> > depend on a linux-libc-dev-common without the headers for this
> > architecture.
> 
> I agree that it is not as simple as I pictured it. I was imagining that
> a m-a:same linux-libc-dev could simply contain all the
> architecture-dependent stuff. For many architectures that would
> practically work initially, but there is no bijective mapping between
> kernel architecture names and Debian architecture names, so for
> directories like /usr/lib/linux/uapi/arm is is unclear whether it should
> be part of linux-libc-dev:armel or linux-libc-dev:armhf or
> linux-libc-dev-common.  Even for /usr/lib/linux/uapi/arm64, it is not
> clear whether that should be part of linux-libc-dev:arm64 or
> linux-libc-dev:musl-linux-arm64 or linux-libc-dev-common. You are
> implicitly resolving this to linux-libc-dev-common and conclude that
> headers would then go missing.
> 
> Given this, I fear I concur with your "This would not actually work."

linux-libc-dev is also build-essential.  This kind of rules out any
same-source all-any trickery.  Those packages will not show up at the
same time, so are prone to make the whole toolchain uninstallable.

Bastian

-- 
Vulcans believe peace should not depend on force.
-- Amanda, "Journey to Babel", stardate 3842.3



Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-05-12 Thread Bastian Blank
On Sun, May 12, 2024 at 01:53:33PM +0200, Helmut Grohne wrote:
> 2+3+6+7. linux-libc-dev could be split into linux-libc-dev-common
>arch:all m-a:foreign and the symlink farms could be kept in
>linux-libc-dev:any m-a:same retaining the size reduction.

This would not actually work.  linux-libc-dev-common would only contain
known architectures.  So the current "change config, build
linux-libc-dev" will not longer work as well.  This package would then
depend on a linux-libc-dev-common without the headers for this
architecture.

Bastian

-- 
To live is always desirable.
-- Eleen the Capellan, "Friday's Child", stardate 3498.9



Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-05-12 Thread Bastian Blank
Hi Helmut

On Sun, May 12, 2024 at 01:53:33PM +0200, Helmut Grohne wrote:
> > Care to just share what you actually found?  Where is it broken and how
> > to see this?
> > Because this whole thing started with "it is broken, but I won't tell
> > you where or what or how".
> Quite clearly, this is not a single problem, but a mesh of problems and
> in a few cases it is not obvious where to solve them.

Okay, if you re-use a bug report for different things, then problem is
not defined any more.

> > I wonder now.  How would that ever work for the native build?  Or does
> > the native build already do those symlinks?  Or are native and cross
> > configured differently?  Or is that a weird difference in gcc itself?
> Native and cross builds work quite differently indeed.

Both somehow use /usr/include and /usr/include/$multiarch in the end.
So the question remains: why can the native gcc properly use headers
from there to build, but the cross one seems to be unable?

> 1. API expectation of *-$arch-cross packages

I asked exactly that in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065416#55

> 4. cross-toolchain-base being bd-uninstallable

Which directly correlates to undocumented Build-Conflicts in the
package.  They neither show up in the changelog or the commit logs.

>I don't exactly understand why it declares them, but I guess that
>having a different set of kernel headers available in
>/usr/$DEB_HOST_GNU_TYPE would cause them to be picked up by the build
>and potentially cause misbuilds. cross-toolchain-base builds these
>packages and it also uses them during build of glibc.

So this reason is now gone.  linux-source-* and linux-libc-dev are
similar enough in almost all cases.

During the next step it could just loose the special setup for those
headers and just use them from linux-libc-dev.  Then there is not longer
a chance of mixup.

> 5. gcc-V-cross not being buildable
> 
>The gcc-V-cross package relies on -$arch-cross packages usually built
>from cross-toolchain-base and expects them to provide their
>functionality in /usr/$DEB_HOST_GNU_TYPE. The current linux-libc-dev
>provides the package names but not the expected path (this actually
>is the first problem) and as a consequence, gcc-V-cross currently
>fails to build from source.

Finally we get somewhere.

> 6. Cross bootstrap cannot tell whether linux-libc-dev supports an
>architecture

Even in the past it could not.  It could try to build the linux package
to see if it gets a working linux-libc-dev.  Or have other code to hack
around, like changing the config.

> 7. Cross bootstrap needs to deal with Arch:all packages
> 
>Until linux-libc-dev became an architecture-dependent Arch:all
>package, the entire cross bootstrap was possible by only performing
>arch-only builds and using a repository of only arch:any packages
>used in conjunction with a Debian mirror restricted to Arch:all
>packages. Now, the bootstrap repository must also be able to carry
>an Arch:all package and handle the fact that multiple versions of
>linux-libc-dev exist in a bootstrap setting one of which does not
>work (as a result of the second problem).

So now the arch:all package part of the archive already contains a
working linux-libc-dev.  At least if you ask for it first, instead of
patching packages inline.

> 8. Duplication of functionality via -$arch-cross packages
> 
>When performing cross builds, we currently need both -$arch-cross
>packages and :$arch packages for glibc and linux-libc-dev. These can
>be built from different versions and we know that using
>libc6-dev-$arch-cross packages built from a different glibc version
>than libc6-dev:$arch together causes problems (repeatedly) and hence
>glibc now declares Conflicts with old libc6-dev-$arch-cross packages.
>If gcc-V-cross were to use :$arch packages, it would have to declare
>cross-architecture dependencies, which is not currently supported by
>our buildd network. That is one reason for it still using
>-$arch-cross packages.

Actually linux-libc-dev-$arch-cross is uncommunicated and uncoordinated
duplication of exactly the same content as linux-libc-dev.

9. linux-libc-dev-*-cross provides incompatible headers to
   build-essential

   Both linux-libc-dev and linux-libc-dev-*-cross provide the linux/*
   includes that are used by the compiler but of different versions.  It
   is undefined if those can work with the (always older) asm/* provided
   by linux-libc-dev-*-cross.

   This is fixed by the unification done.

2+3+6+7. linux-libc-dev provides linux-libc-dev-$arch and remains
arch:all.  Then the API for pulling in the correct one will shift.
This also allows to build linux-libc-dev-$arch as special case for
bootstrap purposes without much chance of it showing up in the wrong
location.

The oposite is also working.  linux-libc-dev becomes not-all again, but
is empty and pulls in 

Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-05-12 Thread Helmut Grohne
Hi,

In this mail, I'll try to summarize my state of knowledge on this
matter while noting that I don't see the full picture.

On Fri, Mar 29, 2024 at 11:17:55AM +0100, Bastian Blank wrote:
> On Thu, Mar 21, 2024 at 08:48:01PM +0100, Helmut Grohne wrote:
> > I was recently working on gcc builds and this disagreement currently
> > makes stuff unbuildable. Hence I looked into solutions and/or
> > workarounds.
> 
> Care to just share what you actually found?  Where is it broken and how
> to see this?
> 
> Because this whole thing started with "it is broken, but I won't tell
> you where or what or how".

Quite clearly, this is not a single problem, but a mesh of problems and
in a few cases it is not obvious where to solve them.

> > As a result, I implemented the proposed change and am attaching it for
> > discussion here. I've implemented it in a way that if there is a sysroot
> > linux header installation, it'll be preferred. Do you see any downsides
> > of this approach?
> 
> I wonder now.  How would that ever work for the native build?  Or does
> the native build already do those symlinks?  Or are native and cross
> configured differently?  Or is that a weird difference in gcc itself?

Native and cross builds work quite differently indeed.

So let me first try to collect all relevant problems that I encountered
here. I vaguely try to list the more important ones earlier. I have
caused some of these problems and don't want to assign any blame but
look for solutions.

1. API expectation of *-$arch-cross packages

   When *-$arch-cross packages were first introduced before multiarch
   was a thing, there was (and still is) and implicit contract saying
   that their functionality is to be provided within the
   /usr/$DEB_HOST_GNU_TYPE hierarchy. In particular, this layout does
   not interfere with multiarch on a filesystem level and hence
   *-$arch-cross packages typically are arch:all m-a:foreign.

   In particular, linux-libc-dev now provides such packages without
   actually providing those paths violating this implicit contract.

2. Violation of Multi-Arch: foreign

   linux-libc-dev was changed from an Arch:any + Multi-Arch:same package
   to an Architecture:all + Multi-Arch:foreign package. It does so by
   providing the headers for all architectures in a single package via
   symlink farms. "all" architectures is debatable though. The set of
   architectures changes rather frequently with new ones being added and
   old ones being removed. Therefore, linux-libc-dev will often look
   like it provides linux-libc-dev:$somearch to dependency resolvers
   while in fact not providing the functionality - thus violating the
   promise of Multi-Arch: foreign. For example, linux-libc-dev is
   currently dysfunctional for arc, but next year it'll be a different
   architecture.

   Moreover, looking at the metadata of linux-libc-dev initially did not
   provide means of figuring out which architectures were actually
   supported and which were not. This has been changed as linux-libc-dev
   now Provides linux-libc-dev-$arch-cross packages (causing the first
   problem), but at least giving bootstrappers a means to figure out
   whether a given linux-libc-dev package is usable to them.

3. linux-libc-dev consumes much space on mirrors and installations

   linux-libc-dev originally was Arch:any and yet much of its content
   was the same across architectures albeit in different paths. Thus,
   the size of the .deb (multiplied by the number of architectures) was
   quite big and also coinstalling linux-libc-dev would result in
   duplicate files being extracted to multiple locations increasing the
   installation size in a multiarch setting.

   As a result, linux-libc-dev now is Arch:all and we only get to have
   one package. It grew from about 1.8MB (times 10 architectures) to
   about 2.2MB and its installed size grew from about 7MB (per
   architecture) to 10MB (for all architectures).

   This change caused the second problem.

4. cross-toolchain-base being bd-uninstallable

   cross-toolchain-base cannot currently be built (FTBFS #1064003 and
   #1067370) and one of the aspects is that it declares Build-Conflicts
   with linux-libc-dev-$arch-cross. The recently added Provides on
   linux-libc-dev satisfy them and thus cause cross-toolchain-base to be
   bd-uninstallable.

   I don't exactly understand why it declares them, but I guess that
   having a different set of kernel headers available in
   /usr/$DEB_HOST_GNU_TYPE would cause them to be picked up by the build
   and potentially cause misbuilds. cross-toolchain-base builds these
   packages and it also uses them during build of glibc.

5. gcc-V-cross not being buildable

   The gcc-V-cross package relies on -$arch-cross packages usually built
   from cross-toolchain-base and expects them to provide their
   functionality in /usr/$DEB_HOST_GNU_TYPE. The current linux-libc-dev
   provides the package names but not the expected path (this actually
   

Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-03-29 Thread Bastian Blank
Hi

On Thu, Mar 21, 2024 at 08:48:01PM +0100, Helmut Grohne wrote:
> I was recently working on gcc builds and this disagreement currently
> makes stuff unbuildable. Hence I looked into solutions and/or
> workarounds.

Care to just share what you actually found?  Where is it broken and how
to see this?

Because this whole thing started with "it is broken, but I won't tell
you where or what or how".

> On Tue, Mar 05, 2024 at 09:50:27AM +0100, Helmut Grohne wrote:
> > > You just said that the search path used during the build of the
> > > toolchain and the one for everything else are unrelated.  So you are
> > > free to create $BUILD/tmp-include with symlinks for asm, asm-generic,
> > > linux.
> > > 
> > > The toolchain as installed already finds all headers.  So I still don't
> > > see why we need this in the final system.
> > 
> > I find this argument fairly convincing and hope Matthias also does.
> 
> As a result, I implemented the proposed change and am attaching it for
> discussion here. I've implemented it in a way that if there is a sysroot
> linux header installation, it'll be preferred. Do you see any downsides
> of this approach?

I wonder now.  How would that ever work for the native build?  Or does
the native build already do those symlinks?  Or are native and cross
configured differently?  Or is that a weird difference in gcc itself?

Bastian

-- 
Oblivion together does not frighten me, beloved.
-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
   stardate 4770.3.



Bug#1064003: Bug#1065416: [Cross-toolchain-base-devs] Bug#1065416: linux-libc-dev claims to provide linux-libc-dev-ARCH-cross, but it doesn't do that completely

2024-03-21 Thread Helmut Grohne
Hi Bastian and Matthias,

I was recently working on gcc builds and this disagreement currently
makes stuff unbuildable. Hence I looked into solutions and/or
workarounds.

On Tue, Mar 05, 2024 at 09:50:27AM +0100, Helmut Grohne wrote:
> > You just said that the search path used during the build of the
> > toolchain and the one for everything else are unrelated.  So you are
> > free to create $BUILD/tmp-include with symlinks for asm, asm-generic,
> > linux.
> > 
> > The toolchain as installed already finds all headers.  So I still don't
> > see why we need this in the final system.
> 
> I find this argument fairly convincing and hope Matthias also does.

As a result, I implemented the proposed change and am attaching it for
discussion here. I've implemented it in a way that if there is a sysroot
linux header installation, it'll be preferred. Do you see any downsides
of this approach?

Helmut
linux-libc-dev now provides linux-libc-dev-$arch-cross without actually
providing /usr//include. Thus we symlink it to where we need it.

See also #1064003.

diff --git a/debian/rules2 b/debian/rules2
index 651d14af..6a486ffe 100644
--- a/debian/rules2
+++ b/debian/rules2
@@ -1266,6 +1266,13 @@ endif
 	  ln -sf /usr/include/$(DEB_HOST_MULTIARCH)/crypt.h \
 	$(builddir)/sys-include/crypt.h; \
 	fi
+	: # Import headers from Multi-Arch:foreign linux-libc-dev
+	set -e; for d in asm-generic linux; do \
+	  if [ -d "/usr/include/$$d" ] && ! [ -d "/usr/$(DEB_TARGET_GNU_TYPE)/include/$$d" ]; then \
+	mkdir -p '$(builddir)/sys-include'; \
+	ln -sf "/usr/include/$$d" "$(builddir)/sys-include/$$d"; \
+	  fi; \
+	done
 
 	touch $(configure_stamp)