diff mbox series

[bug#49565,core-updates,v2] gnu: bootstrap: Use %current-target-system to decide bootstrap path

Message ID 20210720000133.1619640-1-bauermann@kolabnow.com
State New
Headers show
Series [bug#49565,core-updates,v2] gnu: bootstrap: Use %current-target-system to decide bootstrap path | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Thiago Jung Bauermann July 20, 2021, 12:01 a.m. UTC
When cross-building a non-x86 gcc-toolchain on an x86 machine,
‘%current-target’ has the x86 system value and Guix tries to use the
mesboot packages for the bootstrap – which don’t work because they’re
currently x86-only.

So introduce the ‘current-target-nix-system’ procedure which looks at
‘%current-target-system’ first (converting it to a Nix system string) and
use it to decide the bootstrap path. The procedure is factored out from
‘glibc-dynamic-linker’.

Also use it in ‘package-from-tarball’, which needs to take the target
system into account as well – thanks to Maxime Devos for pointing it out.

* gnu/packages/bootstrap.scm (package-from-tarball): Pass result of
‘current-target-nix-system’ to ‘source’ procedure.
(glibc-dynamic-linker): Use result of ‘current-target-nix-system’ as
default value for ‘system’ argument.
(%bootstrap-inputs): Use ‘current-target-nix-system’ to decide whether to
use the mesboot path.
* gnu/packages/commencement.scm (%bootstrap-inputs+toolchain): Likewise.
* guix/utils.scm (current-target-nix-system): Define.
---
 gnu/packages/bootstrap.scm    | 8 +++-----
 gnu/packages/commencement.scm | 2 +-
 guix/utils.scm                | 7 +++++++
 3 files changed, 11 insertions(+), 6 deletions(-)

Hi,

This is the new version of this patch. Thank you Maxime Devos for reviewing the
previous version and pointing out the change needed in ‘package-from-tarball’.

This version makes that change, and also defines a helper function in
`(guix utils)` which returns the Nix system identifier for the current target
– regardless of whether we are cross-building or not.

Before the patch, these are the derivations that Guix tries to build when
cross-compiling gcc-toolchain@11. Note the ‘mesboot’ packages:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --target=powerpc64le-linux-gnu gcc-toolchain@11
substitute: atualizando substitutos de "https://ci.guix.gnu.org"... 100.0%
substitute: atualizando substitutos de "https://bordeaux.guix.gnu.org"... 100.0%
The following derivations will be built:
   /gnu/store/3hrzq7fxj0cxgxkjybki2yi7dj70sgg8-gcc-toolchain-11.1.0.drv
   /gnu/store/2xpiffvzzizrjx48ghqac3rgh1cnljv7-linux-libre-headers-5.10.35.drv
   /gnu/store/4xlm78m6wl56gn4gpifvy8721amhi81j-binutils-2.36.1.drv
   /gnu/store/05lnycy4lmn0768r41sgikg795zk9mqg-binutils-cross-boot0-2.36.1.drv
   /gnu/store/1q62fcaj2gc9mnwvv6cicch6gc7qrnp0-binutils-mesboot-2.20.1a.drv
   /gnu/store/1yjrfb846y1mnc7mgab38jbv7pv0hgbh-tar-boot0-1.34.drv
   /gnu/store/9c7a2p899ivz16636prf44q0q61i4376-patch-mesboot-2.5.9.drv
   /gnu/store/9rmnv55i966wfkx0di4h6p8197hy2836-grep-mesboot-2.0.drv
   /gnu/store/advn8cgpcf9fi6424l8bs16r5mvfqs04-gcc-mesboot-wrapper-4.9.4.drv
   /gnu/store/bpghw1m585q2wjc0z4in9w0hcpxgiidw-gzip-mesboot-1.2.4.drv
   /gnu/store/bx9lr1bg5491dc9i5p2b6zgsq0ahajxb-gcc-mesboot-4.9.4.drv
   /gnu/store/dfijxa9mnlymzmsl571qlxx0qc65kxzi-tar-mesboot-1.22.drv
   /gnu/store/hp2f5sw9d189p7z930b63wr8k3j9k6j0-coreutils-mesboot-8.32.drv
   /gnu/store/i584nxkb39n67vzq5r3yh6spqppzrj43-bzip2-mesboot-1.0.8.drv
   /gnu/store/j1accym68y6l8pxz8095jpkwgp3ciphi-gawk-mesboot-3.1.8.drv
   /gnu/store/jlwyxh3k6hvpmy60g0ygwnncq66kn590-gash-utils-boot-0.1.0.drv
   /gnu/store/9mxvccmf0b8fwq0k7lw0ndsdsbz9y8vn-gash-boot-0.2.0.drv
   /gnu/store/p43yklj8d615y68jhcvycg9i3k3bqj2g-xz-mesboot-5.0.0.drv
   /gnu/store/rxn5c166a6p0p3y2hlyk67f91a504kfa-make-mesboot-3.82.drv
   /gnu/store/sgwdni3iwwrb4ahsnwm43528fzr5csiv-sed-mesboot-4.0.6.drv
   /gnu/store/xxaccspqlg90v3cxrbvslva6s8gwxzi9-make-boot0-4.3.drv
   /gnu/store/zghmr1xyw5ip3wpi1qw2ysc7p6i75d54-glibc-mesboot-2.16.0.drv
   /gnu/store/64cway6pvw5fk7csym2k9i77rhp1pl46-coreutils-boot0-8.32.drv
   /gnu/store/7hvyky0i1hf3xbd698rr305br881pwz6-diffutils-boot0-3.7.drv
   /gnu/store/hq1lijdac3vqx811jzsg0wizsbgwgpaa-gawk-boot0-5.1.0.drv
   /gnu/store/i173n23qpssi7idck4jn7399bfkldlfs-sed-boot0-4.8.drv
   /gnu/store/l8kbhm6m9rbwkxn7zv1d06wbl2gi88wp-findutils-boot0-4.8.0.drv
   /gnu/store/pfq7g9jx16jlk3829312h88n0k1jnfns-patch-boot0-2.7.6.drv
   /gnu/store/qp3yg441ybh6bv44lrcxyp6rzyf0djii-file-boot0-5.39.drv
   /gnu/store/x4m7lff1ps5mas719815d54x6x1zwcv3-bzip2-boot0-1.0.8.drv
   /gnu/store/h5hwcnr7z57hb9b8bhhx7s22kfawqr0d-ld-wrapper-boot0-0.drv
   /gnu/store/v9p5fm974mj4d99vdpp9dhrvpwd4kfgs-glibc-2.33.drv
   /gnu/store/0kjyjcxzk5mv6zm86x8f18sbsb9m48k8-bash-static-5.1.8.drv
   /gnu/store/6h220skb9ak8ppv5417i8cbry1byv73a-glibc-intermediate-2.33.drv
   /gnu/store/rwczga96661d70jcqds8w8pr5s084mh4-gcc-cross-boot0-10.3.0.drv
   /gnu/store/cglgsds6hxy9swdyymgam9l3rfwizyfr-libstdc++-boot0-4.9.4.drv
   /gnu/store/c63lqgh0x2rx1az0ds4b2ma9vgiry31j-gcc-11.1.0.drv
   /gnu/store/f4fwnxsha5h2pk750r2p09cnhbhc3nm3-ld-wrapper-0.drv
   /gnu/store/605p0jq8wv879n3y6fbqxvaiww1kjaql-libunistring-0.9.10.drv
   /gnu/store/5irbp0c5zzvs50wlznpfxcxr8mfndwy9-gcc-10.3.0.drv
   /gnu/store/byfbnlkwj9pjwnkx69fi2ycnqdvz2znv-ld-wrapper-boot3-0.drv
   /gnu/store/fbm3gv13nggw2qcvxmlccqgi0izzgdwn-libstdc++-10.3.0.drv
   /gnu/store/vhwmw9p8l3sysqlm8bh14xkfw1afqqcj-zlib-1.2.11.drv
   /gnu/store/60jiv5k1lg2krj3b0f9x7f26ywrda0mw-bash-minimal-5.1.8.drv
   /gnu/store/i0lk6zd2vwqqlhn8kkf0529x896lnzr1-guile-3.0.7.drv
   /gnu/store/r25wjwjbb13yk8yc4bm77dxxcq9qvx9y-libatomic-ops-7.6.10.drv
   /gnu/store/ry3zxxjsnhpdphvnnr991x9yk7gljxy9-libffi-3.3.drv
   /gnu/store/y26kx37mkidni8jj4sjn0ryy1wq1pqvs-libgc-8.0.4.drv
   /gnu/store/v9p5fm974mj4d99vdpp9dhrvpwd4kfgs-glibc-2.33.drv
--8<---------------cut here---------------end--------------->8---

These are the derivations built after the patch is applied. Note that there
is no ‘mesboot’ package:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --target=powerpc64le-linux-gnu gcc-toolchain@11
substitute: atualizando substitutos de "https://ci.guix.gnu.org"... 100.0%
substitute: atualizando substitutos de "https://bordeaux.guix.gnu.org"... 100.0%
The following derivations will be built:
   /gnu/store/wnllxi9hz868ymmhl9y1izry825azal7-gcc-toolchain-11.1.0.drv
   /gnu/store/3mzbrsijxql7np8zzgs5z6svl4iw3si8-ld-wrapper-0.drv
   /gnu/store/2qbrgj46x4ywkl5icxl13iqalzy1y464-libgc-8.0.4.drv
   /gnu/store/0d3sx0dvn32afifnhsz28yvf9p8shh49-findutils-boot0-4.8.0.drv
   /gnu/store/c497lf15zqz2xx75idh091sp4i3il5zh-make-boot0-4.3.drv
   /gnu/store/dnycxgnzfpj1vc8aaxgnb4gj1m8cv2fa-diffutils-boot0-3.7.drv
   /gnu/store/11z204mvwgimbwifvwd7di76k49kwh1n-tar-boot0-1.34.drv
   /gnu/store/2ykvg2wms8f5bqgqn0fw28grssmkx43f-libatomic-ops-7.6.10.drv
   /gnu/store/3lyp33ib5v3zmykgk53m3plmm7n122j0-file-boot0-5.39.drv
   /gnu/store/4942syn0qn16cg97x27l26rddv5pf297-gawk-boot0-5.1.0.drv
   /gnu/store/5jzrc7l0yjd3wagbfkgdb29jb7cxl97i-bash-minimal-5.1.8.drv
   /gnu/store/7ivfiaav5af41jcpij0lg8ig2vhl46cz-patch-boot0-2.7.6.drv
   /gnu/store/975bjay86c67q0agahxjbalbphd6i2dn-ld-wrapper-boot0-0.drv
   /gnu/store/gbzc67364szqynv0k8ncgvb4r9v0s8gl-binutils-cross-boot0-2.36.1.drv
   /gnu/store/aa1pb63rgm7mgmljq4nqxw5dxlgf1x0k-coreutils-boot0-8.32.drv
   /gnu/store/i33n2m4883668c26kfbcn4r6k5mb6i3q-bzip2-boot0-1.0.8.drv
   /gnu/store/rdigl19v5302arib6i0ic2nhdl8588yv-sed-boot0-4.8.drv
   /gnu/store/d407z0m02m85hbrgf6c0bbvbc72v9wp8-gcc-10.3.0.drv
   /gnu/store/6qy66x2s6izvkiggild5bwi7b1p3i14c-zlib-1.2.11.drv
   /gnu/store/rfji2zr6yicw3vjcksjzk7zc7hxmh0pa-glibc-2.33.drv
   /gnu/store/1knbpbymgj1rggdlkdpz2k9i2sh1hjwk-bash-static-5.1.8.drv
   /gnu/store/05667q3f8yl7fbny1sxkli66rcl8gyrf-glibc-intermediate-2.33.drv
   /gnu/store/5lmmwvhf8gjzw31a0fv7gkl9zcaj76r6-gcc-cross-boot0-10.3.0.drv
   /gnu/store/wkmp9i5il6afhrn6d3lkzf7wminx6rax-libstdc++-boot0-4.9.4.drv
   /gnu/store/b2bjf70ks7f55z1ady9ng34m7iyk8w5a-binutils-2.36.1.drv
   /gnu/store/dqgshra3sbikll475m95slnyqzkmagsn-libstdc++-10.3.0.drv
   /gnu/store/fr2q75l4rdymmcy6wdmjc560vn4l7lxi-ld-wrapper-boot3-0.drv
   /gnu/store/c7i6v0w124ckyvb6pizbg4fqhgwf6gi5-guile-3.0.7.drv
   /gnu/store/ar81shvadvhzkyq4ygln66gpy7xrvjy4-libffi-3.3.drv
   /gnu/store/w8p9y4llj6a91blrf574yjns09vbnkbl-libunistring-0.9.10.drv
   /gnu/store/c63lqgh0x2rx1az0ds4b2ma9vgiry31j-gcc-11.1.0.drv
   /gnu/store/rfji2zr6yicw3vjcksjzk7zc7hxmh0pa-glibc-2.33.drv
--8<---------------cut here---------------end--------------->8---

This is all on today's core-updates branch, at commit:

db5962c68099 gnu: ghostscript: Improve reproducibility of PDF document generation

Comments

Thiago Jung Bauermann July 20, 2021, 1:16 p.m. UTC | #1
Hello,

Em segunda-feira, 19 de julho de 2021, às 21:01:33 -03,
Thiago Jung Bauermann escreveu:
> Before the patch, these are the derivations that Guix tries to build when
> cross-compiling gcc-toolchain@11. Note the ‘mesboot’ packages:

One thing I forgot to mention, and which significance only dawned on me
later: there was a change in Guix behavior between versions of core-updates
since I posted v1 of this patch.

Before, I was getting a Guix exception during the build of glibc-mesboot,
as detailed in the first message in this issue. Now, the mesboot packages
build fine and the command below goes all the way to the gcc-11 package
just like when this patch is applied.

> --8<---------------cut here---------------start------------->8---
> $ ./pre-inst-env guix build --target=powerpc64le-linux-gnu gcc-toolchain@11
> substitute: atualizando substitutos de "https://ci.guix.gnu.org"... 100.0% 
> substitute: atualizando substitutos de "https://bordeaux.guix.gnu.org"... 100.0%
> The following derivations will be built:
> /gnu/store/3hrzq7fxj0cxgxkjybki2yi7dj70sgg8-gcc-toolchain-11.1.0.drv
> /gnu/store/2xpiffvzzizrjx48ghqac3rgh1cnljv7-linux-libre-headers-5.10.35.drv
> /gnu/store/4xlm78m6wl56gn4gpifvy8721amhi81j-binutils-2.36.1.drv
> /gnu/store/05lnycy4lmn0768r41sgikg795zk9mqg-binutils-cross-boot0-2.36.1.drv
> /gnu/store/1q62fcaj2gc9mnwvv6cicch6gc7qrnp0-binutils-mesboot-2.20.1a.drv
> /gnu/store/1yjrfb846y1mnc7mgab38jbv7pv0hgbh-tar-boot0-1.34.drv
> /gnu/store/9c7a2p899ivz16636prf44q0q61i4376-patch-mesboot-2.5.9.drv
> /gnu/store/9rmnv55i966wfkx0di4h6p8197hy2836-grep-mesboot-2.0.drv
> /gnu/store/advn8cgpcf9fi6424l8bs16r5mvfqs04-gcc-mesboot-wrapper-4.9.4.drv
> /gnu/store/bpghw1m585q2wjc0z4in9w0hcpxgiidw-gzip-mesboot-1.2.4.drv
> /gnu/store/bx9lr1bg5491dc9i5p2b6zgsq0ahajxb-gcc-mesboot-4.9.4.drv
> /gnu/store/dfijxa9mnlymzmsl571qlxx0qc65kxzi-tar-mesboot-1.22.drv
> /gnu/store/hp2f5sw9d189p7z930b63wr8k3j9k6j0-coreutils-mesboot-8.32.drv
> /gnu/store/i584nxkb39n67vzq5r3yh6spqppzrj43-bzip2-mesboot-1.0.8.drv
> /gnu/store/j1accym68y6l8pxz8095jpkwgp3ciphi-gawk-mesboot-3.1.8.drv
> /gnu/store/jlwyxh3k6hvpmy60g0ygwnncq66kn590-gash-utils-boot-0.1.0.drv
> /gnu/store/9mxvccmf0b8fwq0k7lw0ndsdsbz9y8vn-gash-boot-0.2.0.drv
> /gnu/store/p43yklj8d615y68jhcvycg9i3k3bqj2g-xz-mesboot-5.0.0.drv
> /gnu/store/rxn5c166a6p0p3y2hlyk67f91a504kfa-make-mesboot-3.82.drv
> /gnu/store/sgwdni3iwwrb4ahsnwm43528fzr5csiv-sed-mesboot-4.0.6.drv
> /gnu/store/xxaccspqlg90v3cxrbvslva6s8gwxzi9-make-boot0-4.3.drv
> /gnu/store/zghmr1xyw5ip3wpi1qw2ysc7p6i75d54-glibc-mesboot-2.16.0.drv
> /gnu/store/64cway6pvw5fk7csym2k9i77rhp1pl46-coreutils-boot0-8.32.drv
> /gnu/store/7hvyky0i1hf3xbd698rr305br881pwz6-diffutils-boot0-3.7.drv
> /gnu/store/hq1lijdac3vqx811jzsg0wizsbgwgpaa-gawk-boot0-5.1.0.drv
> /gnu/store/i173n23qpssi7idck4jn7399bfkldlfs-sed-boot0-4.8.drv
> /gnu/store/l8kbhm6m9rbwkxn7zv1d06wbl2gi88wp-findutils-boot0-4.8.0.drv
> /gnu/store/pfq7g9jx16jlk3829312h88n0k1jnfns-patch-boot0-2.7.6.drv
> /gnu/store/qp3yg441ybh6bv44lrcxyp6rzyf0djii-file-boot0-5.39.drv
> /gnu/store/x4m7lff1ps5mas719815d54x6x1zwcv3-bzip2-boot0-1.0.8.drv
> /gnu/store/h5hwcnr7z57hb9b8bhhx7s22kfawqr0d-ld-wrapper-boot0-0.drv
> /gnu/store/v9p5fm974mj4d99vdpp9dhrvpwd4kfgs-glibc-2.33.drv
> /gnu/store/0kjyjcxzk5mv6zm86x8f18sbsb9m48k8-bash-static-5.1.8.drv
> /gnu/store/6h220skb9ak8ppv5417i8cbry1byv73a-glibc-intermediate-2.33.drv
> /gnu/store/rwczga96661d70jcqds8w8pr5s084mh4-gcc-cross-boot0-10.3.0.drv

Also, inspecting this gcc-cross-boot0 derivation, I see the following
derivations mentioned in it:

/gnu/store/034y7d9d36986pin4b5plx2ryda1h8i5-glibc-cross-powerpc64le-linux-gnu-2.33.drv
/gnu/store/0gihg5kfh4m09hmc45kwf7kjnv1m84gz-gcc-cross-powerpc64le-linux-gnu-10.3.0.drv
/gnu/store/4ld0jqb2q0di90nizv1vvfngnm39mhln-binutils-cross-powerpc64le-linux-gnu-2.36.1.drv
/gnu/store/m7ddjasnrl290002kql8szh7ahjvl2ir-linux-libre-headers-cross-powerpc64le-linux-gnu-5.10.35.drv

And looking at the gcc-11 build directory, I see:

```
$ find /tmp/guix-build-gcc-11.1.0.drv-0 -name '*.o' -exec file '{}' ';' | cut -d: -f2 | sort | uniq -c
      3  ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (GNU/Linux), with debug_info, not stripped
    235  ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped
   1496  ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), with debug_info, not stripped
    118  ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
     14  ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
```

Which is the exact same output I see with the failed gcc-11 build directory
when this patch is applied.

So now I wonder whether these mesboot derivations are just used to bootstrap
x86_64 packages which are then used to build the cross-toolchain, in which
case this patch isn’t actually necessary?

> /gnu/store/cglgsds6hxy9swdyymgam9l3rfwizyfr-libstdc++-boot0-4.9.4.drv
> /gnu/store/c63lqgh0x2rx1az0ds4b2ma9vgiry31j-gcc-11.1.0.drv
> /gnu/store/f4fwnxsha5h2pk750r2p09cnhbhc3nm3-ld-wrapper-0.drv
> /gnu/store/605p0jq8wv879n3y6fbqxvaiww1kjaql-libunistring-0.9.10.drv
> /gnu/store/5irbp0c5zzvs50wlznpfxcxr8mfndwy9-gcc-10.3.0.drv
> /gnu/store/byfbnlkwj9pjwnkx69fi2ycnqdvz2znv-ld-wrapper-boot3-0.drv
> /gnu/store/fbm3gv13nggw2qcvxmlccqgi0izzgdwn-libstdc++-10.3.0.drv
> /gnu/store/vhwmw9p8l3sysqlm8bh14xkfw1afqqcj-zlib-1.2.11.drv
> /gnu/store/60jiv5k1lg2krj3b0f9x7f26ywrda0mw-bash-minimal-5.1.8.drv
> /gnu/store/i0lk6zd2vwqqlhn8kkf0529x896lnzr1-guile-3.0.7.drv
> /gnu/store/r25wjwjbb13yk8yc4bm77dxxcq9qvx9y-libatomic-ops-7.6.10.drv
> /gnu/store/ry3zxxjsnhpdphvnnr991x9yk7gljxy9-libffi-3.3.drv
> /gnu/store/y26kx37mkidni8jj4sjn0ryy1wq1pqvs-libgc-8.0.4.drv
> /gnu/store/v9p5fm974mj4d99vdpp9dhrvpwd4kfgs-glibc-2.33.drv
> --8<---------------cut here---------------end--------------->8---
Thiago Jung Bauermann July 21, 2021, 8:30 p.m. UTC | #2
Hi again,

Em terça-feira, 20 de julho de 2021, às 10:16:12 -03, Thiago Jung Bauermann 
escreveu:
> Em segunda-feira, 19 de julho de 2021, às 21:01:33 -03,
> 
> Thiago Jung Bauermann escreveu:
> > Before the patch, these are the derivations that Guix tries to build
> > when
> > cross-compiling gcc-toolchain@11. Note the ‘mesboot’ packages:
> One thing I forgot to mention, and which significance only dawned on me
> later: there was a change in Guix behavior between versions of
> core-updates since I posted v1 of this patch.
> 
> Before, I was getting a Guix exception during the build of glibc-mesboot,
> as detailed in the first message in this issue. Now, the mesboot
> packages build fine and the command below goes all the way to the gcc-11
> package just like when this patch is applied.

Now, this is very weird. I tried again with core-updates from today and
I’m back to the original problem in this bug report:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --target=powerpc64le-linux-gnu gcc-toolchain@11
substitute: atualizando substitutos de "https://ci.guix.gnu.org"... 100.0%
substitute: atualizando substitutos de "https://bordeaux.guix.gnu.org"... 100.0%
The following derivations will be built:
   /gnu/store/8p847f47i8b7si24ybcah8936i698v0h-gcc-toolchain-11.1.0.drv
   /gnu/store/2qq0qdrkz6920gyn3xl4ppjqiijf8qh2-ld-wrapper-0.drv
   /gnu/store/59v10rbcl25bcbvgh1xip2k4b8dfrs8s-libatomic-ops-7.6.10.drv
   /gnu/store/2vv32wdv72734d54r85ahlxzddc37gdb-tar-boot0-1.34.drv
   /gnu/store/5h6sjkz0cw5yn77lf2x5i05wina2c2s1-sed-mesboot-4.0.6.drv
   /gnu/store/9baisja0i8z81cpx9bs8dp6bgwbf5hg2-gzip-mesboot-1.2.4.drv
   /gnu/store/aw84y6dbh7av5077dp9cgj3acqwychvs-xz-mesboot-5.0.0.drv
   /gnu/store/d9f9mqjpb0n8fplzplayc5fz9pwvka7f-grep-mesboot-2.0.drv
   /gnu/store/nkmmlizfwvxf1xsyiy2p5wbmxyw2s2kj-make-mesboot-3.82.drv
   /gnu/store/wjmv6b603jd2wfbd43nmlkvlhj5lnwi8-tar-mesboot-1.22.drv
   /gnu/store/xd8bmgimslbaj6gwwllikbqrmcmj4m7b-make-boot0-4.3.drv
   /gnu/store/xnk3pczdfksqhih4qzz1grdj177fasfd-glibc-mesboot-2.16.0.drv
   /gnu/store/y5cpc3sbw8xljd7vck5c77k8qxm1mlb9-patch-mesboot-2.5.9.drv
   /gnu/store/3k1yrgg2qvczabgrnjg1x5gka4slzz6q-glibc-2.33.drv
   /gnu/store/87na4l0i3kxkac9cfdfr267c9n8fg5bp-patch-boot0-2.7.6.drv
   /gnu/store/bpmzfb3mhyr23jxn9mzsivxs1qyprqpp-gcc-cross-boot0-10.3.0.drv
   /gnu/store/dlvzaib6lv85jzs0yifkadfjmm9yg45b-findutils-boot0-4.8.0.drv
   /gnu/store/gbah6yk2pbjl9hjsnd3k72xf7v55149c-diffutils-boot0-3.7.drv
   /gnu/store/ikdrcn12xib71lzsj1dvg0iyv1xn21f1-binutils-cross-boot0-2.36.1.drv
   /gnu/store/n5kz2jyyvd1n361x8fa9p9hndjm302pn-gawk-boot0-5.1.0.drv
   /gnu/store/nxjzb1rnx5f9hfplc3bh4a16i2gqycv3-sed-boot0-4.8.drv
   /gnu/store/qfm8pxwnnlg2s6ck1x2ic1skdbvg3743-bzip2-boot0-1.0.8.drv
   /gnu/store/vbhsj51c26g0wgp1xkjx2dfbbcyz2m9p-file-boot0-5.39.drv
   /gnu/store/zd2gkcb1jmil3q8md33mi03y33hhj0mx-coreutils-boot0-8.32.drv
   /gnu/store/sny8h00brxndd2k2bx867jq7d3x7cdwh-libstdc++-boot0-4.9.4.drv
   /gnu/store/ih5isqwnjpgf9b4nisjyw09xlfdcdm0v-bash-static-5.1.8.drv
   /gnu/store/n94hr5rpx5ihhyicwgxzr73nvd1fbriv-glibc-intermediate-2.33.drv
   /gnu/store/zk5xicfviplfdfqkcxw6pfl6layqj9ai-ld-wrapper-boot0-0.drv
   /gnu/store/7qb2850v8r3lqm2gnj0h8xsmka92ms01-bash-minimal-5.1.8.drv
   /gnu/store/d2rivj2hbqg8z25y82ib4yvygyn84jsf-ld-wrapper-boot3-0.drv
   /gnu/store/hwnfh1c22ysff1j0x1yinil639vpdrjr-binutils-2.36.1.drv
   /gnu/store/h49mll58fg5bqz7n5wv1cq9cf40087ss-gcc-10.3.0.drv
   /gnu/store/3d6cx841pa97g8v30ngrvs9cxyx24ylp-libstdc++-10.3.0.drv
   /gnu/store/qa9znr53yar1z621ay7shvwqrdlymm1h-zlib-1.2.11.drv
   /gnu/store/877vdmhr0jf19q898s7rhr828vsb9jxr-guile-3.0.7.drv
   /gnu/store/dc7fpzizg3ffib0grmg8khm8rvf5ig3p-libunistring-0.9.10.drv
   /gnu/store/h6nrxxs4amnqpqmzdycx3p46dzaygdl8-libgc-8.0.4.drv
   /gnu/store/kch00sjjmn7348vwq9bzzy1q6jyxff3g-libffi-3.3.drv
   /gnu/store/3k1yrgg2qvczabgrnjg1x5gka4slzz6q-glibc-2.33.drv
   /gnu/store/ygky86azk6wgrcswvv9zzv0rglhlmpkf-gcc-11.1.0.drv
   /gnu/store/azfr3647s4frasr208ay7rhdzcqi99jh-libstdc++-headers-10.3.0.drv
   /gnu/store/paysivrjqdai8v69xdxsmpiplj09bpvl-libelf-0.8.13.drv
building /gnu/store/xnk3pczdfksqhih4qzz1grdj177fasfd-glibc-mesboot-2.16.0.drv...
    ⋮
<snip lots of output>
    ⋮
phase `patch-source-shebangs' succeeded after 0.6 seconds
starting phase `setenv'
error: in phase 'setenv': uncaught exception:
wrong-type-arg "string-append" "Wrong type (expecting ~A): ~S" ("string" #f) (#f)
phase `setenv' failed after 0.0 seconds
Backtrace:
In ice-9/boot-9.scm:
 157: 15 [catch #t #<catch-closure c93c40> ...]
In unknown file:
   ?: 14 [apply-smob/1 #<catch-closure c93c40>]
In ice-9/boot-9.scm:
  63: 13 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 12 [eval # #]
In ice-9/boot-9.scm:
2320: 11 [save-module-excursion #<procedure cc1b00 at ice-9/boot-9.scm:3961:3 ()>]
3966: 10 [#<procedure cc1b00 at ice-9/boot-9.scm:3961:3 ()>]
1645: 9 [%start-stack load-stack #<procedure cc2ba0 at ice-9/boot-9.scm:3957:10 ()>]
1650: 8 [#<procedure cc8db0 ()>]
In unknown file:
   ?: 7 [primitive-load "/gnu/store/wy882br3mdvkdzc8ql4msbk2qklr8y8h-glibc-mesboot-2.16.0-builder"]
In ice-9/boot-9.scm:
 157: 6 [catch srfi-34 ...]
In srfi/srfi-1.scm:
 616: 5 [for-each #<procedure 1502380 at guix/build/gnu-build-system.scm:909:14 (expr)> ...]
In ice-9/boot-9.scm:
 171: 4 [with-throw-handler #t ...]
In guix/build/gnu-build-system.scm:
 925: 3 [#<procedure 19a1400 at guix/build/gnu-build-system.scm:924:21 ()>]
In ice-9/eval.scm:
 411: 2 [eval # #]
In unknown file:
   ?: 1 [string-append " -L " ...]
In ice-9/boot-9.scm:
 106: 0 [#<procedure 19a13c0 at ice-9/boot-9.scm:97:6 (thrown-k . args)> wrong-type-arg ...]

ice-9/boot-9.scm:106:20: In procedure #<procedure 19a13c0 at ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: In procedure string-append: Wrong type (expecting string): #f
builder for `/gnu/store/xnk3pczdfksqhih4qzz1grdj177fasfd-glibc-mesboot-2.16.0.drv' failed with exit code 1
build of /gnu/store/xnk3pczdfksqhih4qzz1grdj177fasfd-glibc-mesboot-2.16.0.drv failed
View build log at '/var/log/guix/drvs/xn/k3pczdfksqhih4qzz1grdj177fasfd-glibc-mesboot-2.16.0.drv.bz2'.
cannot build derivation `/gnu/store/ikdrcn12xib71lzsj1dvg0iyv1xn21f1-binutils-cross-boot0-2.36.1.drv': 1 dependencies couldn't be built
--8<---------------cut here---------------end--------------->8---

This is with the following commit:

$ git log --oneline -n1
c3e33474b965 (HEAD -> core-updates, origin/core-updates) gnu: biber: Update to 2.16.

I forgot to mention in my previous email which was the commit that worked.
It’s this one:

$ git log --oneline -n1
b15c3dd9b0e9 (HEAD) gnu: meson: Update to 0.59.0.

I just tested it again, and it does work if I revert back to it.
Ludovic Courtès July 21, 2021, 10:01 p.m. UTC | #3
Hi!

Thiago Jung Bauermann <bauermann@kolabnow.com> skribis:

> $ ./pre-inst-env guix build --target=powerpc64le-linux-gnu gcc-toolchain@11
> substitute: atualizando substitutos de "https://ci.guix.gnu.org"... 100.0%
> substitute: atualizando substitutos de "https://bordeaux.guix.gnu.org"... 100.0%
> The following derivations will be built:
>    /gnu/store/8p847f47i8b7si24ybcah8936i698v0h-gcc-toolchain-11.1.0.drv
>    /gnu/store/2qq0qdrkz6920gyn3xl4ppjqiijf8qh2-ld-wrapper-0.drv
>    /gnu/store/59v10rbcl25bcbvgh1xip2k4b8dfrs8s-libatomic-ops-7.6.10.drv
>    /gnu/store/2vv32wdv72734d54r85ahlxzddc37gdb-tar-boot0-1.34.drv
>    /gnu/store/5h6sjkz0cw5yn77lf2x5i05wina2c2s1-sed-mesboot-4.0.6.drv
>    /gnu/store/9baisja0i8z81cpx9bs8dp6bgwbf5hg2-gzip-mesboot-1.2.4.drv
>    /gnu/store/aw84y6dbh7av5077dp9cgj3acqwychvs-xz-mesboot-5.0.0.drv
>    /gnu/store/d9f9mqjpb0n8fplzplayc5fz9pwvka7f-grep-mesboot-2.0.drv

I think you hit a corner with ‘gcc-toolchain’.  The packages in
commencement.scm (*-boot0, *-mesboot, etc.) should never be
cross-compiled; they’re not meant to.  If you find a command that ends
up trying to cross-compile them, it means there’s a problem.

What you want in this case is:

  ./pre-inst-env guix build -e '(@ (gnu packages gcc) gcc-11)' \
     --target=powerpc64le-linux-gnu -n

That is going to build the right thing.

Why is ‘gcc-toolchain’ a special case?  Precisely because it pulls in
things from commencement.scm: ‘binutils-final’, ‘glibc-final’, etc.

And why does it pull these ‘-final’ variants instead of the ‘binutils’,
‘glibc’, etc. you ask?  :-)  That’s to save space; that way, you don’t
end up downloading/building another toolchain when you run
‘guix install gcc-toolchain’.

I hope this clarifies things a bit!

Ludo’.
Thiago Jung Bauermann July 22, 2021, 12:32 a.m. UTC | #4
Hi Ludo’,

Em quarta-feira, 21 de julho de 2021, às 19:01:07 -03, Ludovic Courtès
escreveu:
> Thiago Jung Bauermann <bauermann@kolabnow.com> skribis:
> > $ ./pre-inst-env guix build --target=powerpc64le-linux-gnu
> > gcc-toolchain@11 substitute: atualizando substitutos de
> > "https://ci.guix.gnu.org"... 100.0% substitute: atualizando
> > substitutos de "https://bordeaux.guix.gnu.org"... 100.0%> 
> > The following derivations will be built:
> >    /gnu/store/8p847f47i8b7si24ybcah8936i698v0h-gcc-toolchain-11.1.0.drv
> >    /gnu/store/2qq0qdrkz6920gyn3xl4ppjqiijf8qh2-ld-wrapper-0.drv
> >    /gnu/store/59v10rbcl25bcbvgh1xip2k4b8dfrs8s-libatomic-ops-7.6.10.drv
> >    /gnu/store/2vv32wdv72734d54r85ahlxzddc37gdb-tar-boot0-1.34.drv
> >    /gnu/store/5h6sjkz0cw5yn77lf2x5i05wina2c2s1-sed-mesboot-4.0.6.drv
> >    /gnu/store/9baisja0i8z81cpx9bs8dp6bgwbf5hg2-gzip-mesboot-1.2.4.drv
> >    /gnu/store/aw84y6dbh7av5077dp9cgj3acqwychvs-xz-mesboot-5.0.0.drv
> >    /gnu/store/d9f9mqjpb0n8fplzplayc5fz9pwvka7f-grep-mesboot-2.0.drv
> 
> I think you hit a corner with ‘gcc-toolchain’.  The packages in
> commencement.scm (*-boot0, *-mesboot, etc.) should never be
> cross-compiled; they’re not meant to.  If you find a command that ends
> up trying to cross-compile them, it means there’s a problem.

My doubt was whether they were being cross-compiled, or Guix was building
them natively as an intermediary step in the path to obtain a
cross-toolchain.

This patch:

https://issues.guix.gnu.org/49565#11

allows gcc-toolchain@11 to be cross-compiled without going through mesboot
packages – or it would if bug 49600 didn’t get in the way. Do you think
it is correct?

> What you want in this case is:
> 
>   ./pre-inst-env guix build -e '(@ (gnu packages gcc) gcc-11)' \
>      --target=powerpc64le-linux-gnu -n
> 
> That is going to build the right thing.

Nice! I should have thought of it.

> Why is ‘gcc-toolchain’ a special case?  Precisely because it pulls in
> things from commencement.scm: ‘binutils-final’, ‘glibc-final’, etc.
> 
> And why does it pull these ‘-final’ variants instead of the ‘binutils’,
> ‘glibc’, etc. you ask?  :-)  That’s to save space; that way, you don’t
> end up downloading/building another toolchain when you run
> ‘guix install gcc-toolchain’.
> 
> I hope this clarifies things a bit!

It does! Thank you very much for these clarifications. The pieces are still
falling into place in my mind.
diff mbox series

Patch

diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index 5a8028a4652c..d1493e4c7ec7 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -266,7 +266,7 @@  or false to signal an error."
     (inputs
      `(("tar" ,(bootstrap-executable "tar" (%current-system)))
        ("xz"  ,(bootstrap-executable "xz" (%current-system)))
-       ("tarball" ,(bootstrap-origin (source (%current-system))))))
+       ("tarball" ,(bootstrap-origin (source (current-target-nix-system))))))
     (source #f)
     (synopsis description)
     (description description)
@@ -299,9 +299,7 @@  or false to signal an error."
                                  package-with-bootstrap-guile)))))
 
 (define* (glibc-dynamic-linker
-          #:optional (system (or (and=> (%current-target-system)
-                                        gnu-triplet->nix-system)
-                                 (%current-system))))
+          #:optional (system (current-target-nix-system)))
   "Return the name of Glibc's dynamic linker for SYSTEM."
   ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
   (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
@@ -927,7 +925,7 @@  exec ~a/bin/.gcc-wrapped -B~a/lib \
 (define (%bootstrap-inputs)
   ;; The initial, pre-built inputs.  From now on, we can start building our
   ;; own packages.
-  (match (%current-system)
+  (match (current-target-nix-system)
     ((or "i686-linux" "x86_64-linux")
      `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
        ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index a04bb83c3d2d..030dfad970a7 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -2396,7 +2396,7 @@  exec " gcc "/bin/" program
 (define (%bootstrap-inputs+toolchain)
   ;; The traditional bootstrap-inputs.  For the i686-linux, x86_64-linux
   ;; Scheme-only bootstrap the actual reduced set with bootstrapped toolchain.
-  (match (%current-system)
+  (match (current-target-nix-system)
     ((or "i686-linux" "x86_64-linux")
      (%boot-mesboot6-inputs))
     (_
diff --git a/guix/utils.scm b/guix/utils.scm
index c5a3a52f9dbc..0d438a00ce00 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -85,6 +85,7 @@ 
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            current-target-nix-system
             package-name->name+version
             target-linux?
             target-hurd?
@@ -630,6 +631,12 @@  returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define (current-target-nix-system)
+  "Return the Nix system identifier for the current target, whether we are
+cross-building or not."
+  (or (and=> (%current-target-system) gnu-triplet->nix-system)
+      (%current-system)))
+
 (define* (package-name->name+version spec
                                      #:optional (delimiter #\@))
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"