Subject: Re: [bug#47539]

From: Leo Famulari <[email-masked]>
Date: Sun, 6 Jun 2021 13:26:41 -0400

On Sat, Jun 05, 2021 at 09:16:36PM +0200, Xinglu Chen wrote:
> On Fri, May 21 2021, Leo Famulari wrote:
> > I notice that (most of?) the new packages use native-inputs for their
> > dependencies.
> >
> > If these dependencies are used at run-time, I would propagate them
> > instead. This way, they will be available in the build environment of
> > packages that depend on the package that is using them, which matters
> > for our go-build-system, where everything is built from scratch in each
> > package. If I remember correctly, that is...
> 
> I am not familiar with the Go ecosystem, is there a way to tell if a
> dependency is used at runtime?

Remember, Go uses static compilation, so Guix's concept of "runtime"
dependencies doesn't apply to Go like it does for other languages.

For Go, you'll know that a dependency was missing, because the build
will fail without it.

Our current go-build-system implementation rebuilds every dependency
from source when it is used while building another package
(inefficient!). 

If foo requires bar, and baz depends on foo, then bar needs to be
available when building baz. That is because foo will be rebuilt while
building baz.

We must either propagate bar from foo, or make baz depend on it.
Technically, bar is a dependency of foo, so it is correct to propagate
it from foo.

You may also check if baz also depends on bar, by checking if baz tries
to import bar. Go software imports (or declares?) its dependencies by
importing them using "import paths" [0], as shown in this example:

https://github.com/syncthing/syncthing/blob/v1.17.0/cmd/strelaypoolsrv/main.go#L5

The external or non-stdlib dependencies are named by what looks like a
URL. These URL-like "import paths" are the actual and unique names for
Go programs.

So, if baz also depends on bar, your grep in the baz source code will
return a match for the import path of bar; something like
'github.com/author/bar'.

Does that make sense? I'm happy to clarify things until it does :)

[0] https://golang.org/doc/code#Organization