Subject: [bug#50627] [PATCH 0/2] Make wayland-protocols dependency native-input.

From: Liliana Marie Prikler <[email-masked]>
Date: Fri, 17 Sep 2021 15:01:04 +0200

Hi,

Am Freitag, den 17.09.2021, 11:20 +0300 schrieb muradm:
> Regardless of comments below, I understand what you are trying to 
> point out. It is fine with me to use 'inputs instead of 'native-
> inputs, as the final result won't change. Just in my opinion, what I
> found it that, it need/should not be in 'propagated-inputs. I will be
> updating the patch to make sure that wayland-protocols are listed
> among 'inputs without propagating. It is also fine with me to close
> this issue and don't do anything if you say that it is unnecessary, I
> don't mind :)
I agree that reducing propagated-inputs is a good thing, it should just
be moved to inputs.  When you update the patch, please do use the
upstream version of gtk3-wayland-protocols-dependency.patch.

> Liliana Marie Prikler <[email-masked]> writes:
> 
> > And what kind of code is generated from them?  I would assume 
> > it's target code.  And since wayland-protocols is no tool to
> > process those XML files, but the files themselves, I'd hazard a
> > guess that it should rather be built for the target.  While
> > currently this appears to make no difference, there might well be a
> > time in which those files differ for some two architectures, which
> > then would cause problems in cross-compiling contexts were it a
> > native input.
> As with any other kind of protocol, you can implement platform 
> specific encoder/decoder, but protocol remains the same. Suppose, 
> connecting from arm, to x86 or vice versa in the context of wayland,
> should protocol change? As you mentioned wayland-scanner below, that
> would be its task to interpret protocol specification in platform
> specific way. So I would speculate that in future these
> specifications would remain the same.
> Otherwise, that would defeat the point of having protocol.
You are probably correct in that those files will likely stay the same
for all platforms, but there could be scenarios where for the sake of
performance or whatever else you might want to have some protocol
extensions.  Platforms that don't support those then wouldn't ship said
protocol extensions.

> > In that case I'd hazard a guess that it's fine, but the phrase
> > "wayland-protocols remains to be an input" is perhaps a bit 
> > weird given the change to native-input.
> Probably, I'd better put single quote in front of the word when it
> means symbol, and don't put one when it is human word :) in this 
> context it was meaning literal input (regardless of type, be it
> 'inputs, 'native-inputs or 'propagated-inputs).
In my personal experience people don't pronounce quotes, so it's better
to be explicit rather than implicit.

> > > There are two things which are being changed. First as you
> > > pointing out is the way Guix treats it, i.e. reducing closure, 
> > > etc.  Second is propagation of inputs. Currently (without this 
> > > patch), since it is listed in propagated-inputs (and also
> > > advertised in .pc files), wayland-protocols as requirement,
> > > needlessly, getting pushed down then hierarchy.
> > We ought to move it from propagated-inputs to inputs and either 
> > (if we can) ignore pkg-config or patch the pkg-config
> > files.  W.r.t. pkg-config I do wonder whether Requires.private
> > needs propagation, though, it normally should be just Requires.
> I suppose, it is not in Guix's hands to control how pkg-config 
> files are authored by software owners and/or interpreted by build
> tools. 
> What Guix's can do, it to fix what is already there. This patch 
> illustrates this point.
The point of authoring is a weird one when Guix can absolutely still
patch the file *and* you supplied a patch that was accepted upstream. 
A patch, which mind you is arguably more correct than the one you've
supplied for Guix, patching the build files themselves rather than
generated sources.

For other packages with similar issues without an upstream fix, you
could on the other hand simply substitute* the .pc file.

> > > Let's take 4 cases that we have here (I do not pretend to be
> > > complete, of course, there are might be more levels/combinations,
> > > just attempting to illustrate current case in
> > > simple words/terms):
> > > 
> > > 1. wayland compositor (weston, wlroots/sway, etc.)
> > > 2. wayland client application (grim, mpv, etc. applications
> > > directly interacting with wayland interfaces)
> > > 3. wayland client library (qt or gtk+ in this case, also 
> > > directly
> > > interacts with wayland to abstract it for user applications)
> > > 4. user application of wayland client library (in this case 
> > > some
> > > gtk+ based application)
> > > 
> > > For 1 and 2, both types should have to specify wayland in 
> > > inputs (or propagated-inputs), and wayland-protocols in native-
> > > inputs.
> > Why?
> One implements the protocol, the other uses it. I.e. both need 
> stubs generated from specification to agree. Which is not the case
> for anything beyond 4. Otherwise, we would defeat whole point of
> introducing abstractions.
This still doesn't explain the *native*-inputs assertion.

> > > One of purposes to have layer 3, is to abstract from 1 and 2.
> > > i.e. when I write gtk application, as user I should not be 
> > > aware of where/how this application is going to run, via xorg or 
> > > wayland. Then why I should be aware of wayland/wayland-protocols
> > > and make sure that it is provided as build input for my
> > > application?
> > IIUC you don't need to be aware when gtk propagates the input? 
> > It's similar to how you still need an Xorg server to test your GTK
> > application.
> From application using gtk stand point, it does not matter what is
> behind gtk. As you point out, of course me, as user launching
> application, I have to provide some environment which could be
> either xorg or wayland. But application's source should not be
> aware of that fact.
This and that are different matters.  Application source code continues
to be blissfully unaware of the fact, but the toolchains to build your
application are not.  Think of it like this: When you use pkg-config
(or older -config binaries), they spit out a number of compiler and
linker flags to supply to gcc or ld.  You as the application programmer
are typically unaware of those flags and their values, especially if
you turn down the verbosity of your build system, but that doesn't mean
they're not supplied.

> [...]
> > >           When cross-compiling, dependencies listed in ‘inputs’ 
> > >           are built for the _target_ architecture; conversely,
> > >           dependencies listed in ‘native-inputs’ are built for 
> > >           the architecture of the _build_ machine.
> > This is the distinction to make here.  "Typically used to list 
> > tools" here means that the package provides a tool (i.e. a binary)
> > that you invoke at some point of your recipe.  This can be a
> > compiler like GCC, a tool to create Makefiles like automake, or an
> > X server to launch tests in.  The only thing in that regard when
> > talking about wayland would be the wayland-scanner tool provided by
> > the wayland package.
> > 
> > Notice the contrast to what you said before with wayland being 
> > an input and wayland-protocols being a native one.  If you need 
> > wayland-scanner for you build, it should be a native-input (as well
> > as an input, probably).  If this does become a problem later on, a
> > bin/lib split for wayland might make sense.
> I understand what you are saying, however as far as I am aware, 
> people being or not on the same page, tend to use simpler definitions
> for referencing something. I was assuming that in this mailing list
> we are on the same page, and free to choose to how reference things.
> I suppose it would be fine to say "not runtime dependency", "build 
> time" or "dependency for host platform when crosscompiling" in
> reference to 'native-inputs. For instance when explaining this to one
> who sees Guix for the first time, I would say "run time" for 'inputs
> and "build time" for 'native-inputs, not mentioning "crosscompiling"
> at all on day one.
> Any way, I believe it is more like philosophical subject, than 
> technical.
I think it is important to acknowledge that people come from different
backgrounds, and knowing that to do our best to curb misunderstandings.
Comparing Guix' package definitions to other package managers makes it
obvious as to why that is the case.  Let me pick Gentoo ebuilds as an
example (it's quicker to explain than whatever Debian has).
There are five (as opposed to three in Guix) kinds of dependencies:
- DEPEND, aka build-time dependencies,
- RDEPEND, aka run-time dependencies,
- BDEPEND, aka native build-time dependencies,
- IDEPEND, aka native install-time dependenices, and
- PDEPEND, aka what the fuck, I think I just introduced a cycle
somewhere.  
When you say "build-time dependencies go into native inputs", someone
with a shallow understanding might think that *all* build time
dependencies are native inputs, when in fact only build time tools
(i.e. BDEPEND in Gentoo parlance) would go there.

In other systems, it might be acceptable to have a package depend on
some other package without said dependency being present at build time.
Consider a shell script that wraps youtube-dl.  Since youtube-dl exists
at some point between installation and first use, your shell script
works™ whether or not youtube-dl is present at build.  Some packages in
Guix do work that way, though it's a pretty rare occurrence.  GStreamer
is one with a legitimate excuse, for example.  Other than that, *all*
"dependencies" (actually inputs) are present at build time, so it makes
no sense to distinguish between build time and run time.  Guix knows
which packages it can delete from the store by tracking references. 
What Guix needs to distinguish is whether the package is invoked at
build time (native-inputs) or whether it needs to be installed
alongside the package being built (propagated-inputs) against none of
the two (regular inputs).

So the next time you try to explain things to a first-timer, be clear
that native-inputs is for tools like compilers, linkers, code
generators *invoked* at build time.  It will be less confusing to learn
it correctly the first time round rather than having to argue in the
mailing lists when submitting some patch.  I understand that keeping
one piece of extra information in mind can be hard at times and the
temptation to simplify is always there, but in the long term no one
benefits from oversimplification.

Sorry for making you read this huge wall of text and happy hacking :)