Subject: Re: bug#40272: linux-module-build-system don't support an inferior package as a kernel

From: Danny Milosavljevic <[email-masked]>
Date: Mon, 2 Aug 2021 21:03:21 +0200

Hi,

On Sun, 01 Aug 2021 18:46:00 +0200
Ludovic Courtès <[email-masked]> wrote:

> Brice Waegeneire <[email-masked]> skribis:
> 
> > In guix/build-system/linux-module.scm:
> >    132:22  3 (lower "ddcci-driver-linux-0.3.3" #:source _ #:inputs _ #:native-inputs _ #:outputs _ #:system _ #:target _ #:linux _ . _)
> > In ice-9/boot-9.scm:
> >   1685:16  2 (raise-exception _ #:continuable? _)
> >   1685:16  1 (raise-exception _ #:continuable? _)
> >   1685:16  0 (raise-exception _ #:continuable? _)
> >
> > ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> > In procedure %package-native-inputs-real: Wrong type argument: #<inferior-package [email-masked] 7f4ddef23bd0>  
> 
> In this case, the problem is that (@ (guix build-system linux-module)
> lower) assumes that ‘linux’ is a <package>:
> 
>     (build-inputs `(,@(if source
>                           `(("source" ,source))
>                           '())
>                     ,@native-inputs
>                     ;; TODO: Remove "gmp", "mpfr", "mpc" since they are
>                     ;; only needed to compile the gcc plugins.  Maybe
>                     ;; remove "flex", "bison", "elfutils", "perl",
>                     ;; "openssl".  That leaves very little ("bc", "gcc",
>                     ;; "kmod").
>                     ,@(package-native-inputs linux)   ;<----- HERE
> 
> I suppose you could add a special-case for (inferior-package? linux).
> Not pretty, but it’d do the job.

Or, as the comment says, it might be enough just to not get the
package-native-inputs from the package ever, but do hard-code
bc, gcc and kmod.  Maybe add a comment why :)

The reason I hadn't done that back then is because it's slightly less
maintenance to not have Linux's native-inputs copy&pasted like this
(one day, Linux could switch the GCC version they use).
But really, we should be good for years anyway.
I'm not sure whether Linux checks whether it's being compiled with the
right compiler, though.  If not, that could cause some nasty silent
miscompilations in the future.