Hi, On Fri, 04 Oct 2019 17:46:43 +0200 Jelle Licht <jli...@fsfe.org> wrote:
> Mathieu Othacehe <m.othac...@gmail.com> writes: > > > > > --8<---------------cut here---------------start------------->8--- > > (native-inputs > > `(,@(if (not (string-prefix? "i686" (%current-system))) > > `(("cross-gcc" ,(cross-gcc "i686-unknown-linux-gnu")) > > ("cross-binutils" ,(cross-binutils "i686-unknown-linux-gnu"))) > > '()))) > > --8<---------------cut here---------------end--------------->8--- > > > > that uses the current gcc if you're already building on an i686 system, > > or define and use a cross-gcc targeting i686 systems otherwise. > > This snippet might make a lot of sense to seasoned schemers/guixfolk, Basically just ignore the birdshit characters to understand what it does :) The first unquote is to evaluate (%current-system) at the toplevel which is what interprets the package definitions in the first place. "`(,@" is a no-op. Not sure why it's written like that. > `(("cross-gcc" ,(cross-gcc "i686-unknown-linux-gnu")) > ("cross-binutils" ,(cross-binutils "i686-unknown-linux-gnu"))) is like we always write inputs, but it's calling the "cross-gcc" function in the toplevel in order to get the package to use. > with the multiple levels of (un)quoting and what not. It does not seem > like what somebody with little experience in either would think of by > themselves. > > Would it make sense to have a section/stub in the cookbook about cross > compilation? I don't think that cross-gcc is stable API that much--and it's not common that you need it anyway. A normal user just cross compiles by using guix build --target=i686-linux pkg or better yet, uses qemu to natively compile it for a foreign system guix build --system=i686-linux pkg . The above is only necessary when for some reason your package has parts which only compile on one system and other parts which only compile on another system--that's very rare. Nowadays, packages are supposed to be cross-platform, so using cross-gcc directly is unnecessary, too. Right now cross-gcc is not documented, so I guess that counts as "not a public interface".
pgpytuANZ3Zql.pgp
Description: OpenPGP digital signature