guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question: wrap-program without #:sh can be ok even when cross-compil


From: Leo Prikler
Subject: Re: Question: wrap-program without #:sh can be ok even when cross-compiling?
Date: Sun, 06 Jun 2021 12:57:49 +0200
User-agent: Evolution 3.34.2

Am Sonntag, den 06.06.2021, 12:14 +0200 schrieb Maxime Devos:
> Leo Prikler schreef op zo 06-06-2021 om 09:39 [+0200]:
> > I think we might want to export a utility procedure
> >     (patch-shebangs files inputs)
> 
> This procedure already exists, but is undocumented and
> unexported. It is in (guix build gnu-build-system).
> 
> (define* (patch-shebangs #:key inputs outputs (patch-shebangs? #t)
>                          #:allow-other-keys)
>   [...])
This patch-shebangs doesn't take a list of files as arguments, it
instead just iterates over all the files.  I don't think this is
particularly helpful in a cross-compiling context, where you want some
files (most notably scripts, that don't get wrapped) to have its
shebang drawn from inputs rather than native-inputs.

You could use the patch-shebang primitive from (guix build utils), but
you'd have to wrap it in something like

(let ((path (search-path-as-list '("bin" "sbin") (map cdr INPUTS))))
  (for-each (cute patch-shebang <> path) (find-files ...)))

where INPUTS are inputs or native-inputs, whichever you want.  Not very
friendly imo.
> > so that files used during build (e.g. configure, Makefile, etc.)
> > can do
> > (patch-shebangs build-stuff native-inputs) and the rest implicitly
> > gets
> > (patch-shebangs files inputs) during the patch-shebangs
> > phase.  WDYT?
> 
> Looking at %standard-phases, we have
> 
> (define %standard-phases
>   ;; Standard build phases, as a list of symbol/procedure pairs.
>   [...]
>     (phases [...] unpack bootstrap patch-usr-bin-file
>             patch-source-shebangs configure patch-generated-file-
> shebangs
>             build check install
>             patch-shebangs [...]))
> 
> Here, patch-source-shebangs calls patch-shebang for every file
> in the source code. As #:path is not set, $PATH is used. Thus,
> when cross-compiling, native-inputs (+ some implicit inputs) is used,
> and when compiling natively, the union of native-inputs and inputs (+
> some implicit inputs) is used (*).
> 
> Thus, the files used during build (configure, Makefile, ...) already
> get a ‘good’ interpreter. (Unless I'm mistaken, I didn't test this.)
I agree, that's the status quo.  We want that to be retained, but we
also want our cross-compilation story to be better.  Hence imo allowing
to pass files, constructing path from inputs and exporting this
procedure might make sense.

> (*) I looked into separating 'native-inputs' and 'inputs' even when
> compiling
>     natively but it turned out to be more complicated than first
> expected.
Fair enough, nobody expects you to do everything at once.

Regards,
Leo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]