Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdenv: bootstrap riscv64 (Step 2) #147942

Merged
merged 2 commits into from
Dec 23, 2021

Conversation

oxalica
Copy link
Contributor

@oxalica oxalica commented Nov 29, 2021

Motivation for this change

Follows #115406
Related: #101651

Add bootstrap files from https://hydra.nixos.org/build/159891432 and https://hydra.nixos.org/build/159891436

Currently the two URLs starting with http://tarballs.nixos.org are dangling. They should be uploaded before this PR being merged. @grahamc

Test steps:
  1. (Before two files being uploaded) Fetch bootstrap files built by Hydra and re-add them as FODs to skip currently dangling URLs. They are already available on https://cache.nixos.org
nix store add-path --name busybox $(nix-store -r /nix/store/2k7r16bgfglv4ygrkmprk611my6n62x7-busybox)
nix store add-file --name bootstrap-tools.tar.xz $(nix-store -r /nix/store/g9vs803cwl3mx5w2fk0sdfmf977vyp9p-bootstrap-tools.tar.xz)
  1. (If you don't have a native RV machine) Enable binfmt for riscv64-linux on your building machine. And apply the binfmt-QEMU patch nixos/binfmt: Add QEMU wrapper to preserve argv[0] #143060. It's required to pass all coreutils tests.
  2. Bootstrap riscv64-linux stdenv.
nix-build . -A stdenv --argstr system riscv64-linux
  1. Playing around with the new stdenv. Or optionally, try to re-bootstrap bootstrap files to confirm the new stdenv is fully functional. Note that this would take a long time since QEMU is far slower than cross compilation.
nix-build pkgs/stdenv/linux/make-bootstrap-tools.nix -A build --argstr localSystem riscv64-linux
Things done

I built the new stdenv successfully.

Note that currently some basic packages including nix and systemd won't evaluate due to the usage of outdated boost, it would be fixed by #138309 (still in staging).

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Nov 29, 2021
@zhaofengli zhaofengli mentioned this pull request Nov 29, 2021
@zhaofengli
Copy link
Member

Haven't tested, but I think the -fopenmp problem described here still exists. Could you confirm? I have a naive fix but would be nice if we can find a better way.

RiscV has an individual STARTFILE_PREFIX_SPEC macro which also need to
be patched.
@oxalica
Copy link
Contributor Author

oxalica commented Nov 30, 2021

Haven't tested, but I think the -fopenmp problem described here still exists.

It should be fixed now.

For test: nix shell -f . gcc --argstr system riscv64-linux --command gcc -fopenmp test.c (requires binfmt)
The built gcc is also available in https://riscv64.cachix.org, or you can build it yourself.

Copy link
Member

@zhaofengli zhaofengli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm that I was able to bootstrap stdenv using the bootstrap tools built by Hydra (tree). Let's get this uploaded to tarballs.nixos.org 🚀

bootstrap-files URLs
{
  # https://hydra.nixos.org/build/159891432
  # https://cache.nixos.org/2k7r16bgfglv4ygrkmprk611my6n62x7.narinfo
  busybox = import <nix/fetchurl.nix> {
    name = "busybox";
    url = "https://cache.nixos.org/nar/0vs8nzcvmcvi80bi5grzl3vbv97qxxx2yc01rfmlv48zqzp2y90s.nar.xz";
    sha256 = "sha256-b2GRL5S8TvKH0f9IqVIe0WvQfY2Ox3XkcfMsZNNGWD0=";
    unpack = true;
    executable = true;
  };

  # https://hydra.nixos.org/build/159891436
  # https://cache.nixos.org/g9vs803cwl3mx5w2fk0sdfmf977vyp9p.narinfo
  bootstrapTools = import <nix/fetchurl.nix> {
    name = "bootstrap-tools.tar.xz";
    url = "https://cache.nixos.org/nar/0j6rz95gzdissszgn51y50syzh84p8hdhkqdr0sx2s4swrwsgahz.nar.xz";
    sha256 = "sha256-YTZMmHm/Z91IXHzZuMkN/rACorn+cu9IVBNAsDNp6jg=";
    unpack = true;
  };
}

@vcunat
Copy link
Member

vcunat commented Dec 8, 2021

Oh, I now recalled that @lovesegfault can also upload tarballs. (Graham tends to be busy, understandably.)

@vcunat
Copy link
Member

vcunat commented Dec 15, 2021

@lovesegfault: so can you upload these two files? I think the PR text describes this well.

(Perhaps you thought I was just confirming the ability to do so.)

@lovesegfault
Copy link
Member

@lovesegfault: so can you upload these two files? I think the PR text describes this well.

(Perhaps you thought I was just confirming the ability to do so.)

I can, just need another day or so, I've been traveling and my availability has been spotty.

Everything going well I should get home tomorrow :)

@vcunat
Copy link
Member

vcunat commented Dec 22, 2021

@lovesegfault: ping

@lovesegfault
Copy link
Member

I'm working on this, I'm away from home and don't have access to my normal computer, where I kept WIP script to upload tarballs. I now need to re-learn how to do it. Hopefully documenting it well this time, I think I left some breadcrumbs on Matrix with instructions which I'm chasing after.

@lovesegfault
Copy link
Member

Alright, I've recovered the knowledge.

I need:

  1. The commit hash that was used to generate the bootstrap tools
  2. The store path of the bootstrap tools
  3. The sha256sum of all the on-server components:
$ sha256sum /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/*
6fae5d5db226ea8eace94f2d0221a947a48c7ef7e7fd515c6604c705eb49662b  /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/bootstrap-tools.cpio.bz2
78df72595b11e55ab198a6508cd9fa6702baee33e9631d6f0614cf08052f88f3  /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/bzip2
467a81602423f7f8e73b59b5ae080235795aebbbcb19a4fb81c9706153615394  /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/cpio
6f9673b2e44bfa524068965da0ee5520f2c27f02f7dc3585ffe828356fb46eb1  /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/mkdir
865d209fe8fb0fb457983f0208bb5febe87990b800a378ecf5f1a1cd5574b65b  /nix/store/9h4d7s313wv3gkfwi493yr1wvdsz9lf2-stdenv-bootstrap-tools/on-server/sh

(I use this last bit to double check that the intended thing is being uploaded)

@oxalica
Copy link
Contributor Author

oxalica commented Dec 22, 2021

Alright, I've recovered the knowledge.

I need:

  1. The commit hash that was used to generate the bootstrap tools

  2. The store path of the bootstrap tools

  3. The sha256sum of all the on-server components:

(I use this last bit to double check that the intended thing is being uploaded)

  1. 9bd3cf0 (merge commit of step 1, stdenv: bootstrap riscv64-linux (Step 1) #115406)
  2. /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu (https://hydra.nixos.org/build/159891438)
  3. Only two files need uploading.
> sha256sum /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/*
5466b19288e980125fc62ebb864d09908ffe0bc50cebe52cfee89acff14d5b9f  /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/bootstrap-tools.tar.xz
cdbd841abd2364270c5abb5b2e35154760d7ff47d9ac0878dd1b83ace9c575c7  /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/busybox

Notes:

  1. Due to later changes of nixpkgs, bootstrap tools are rebuilt several times. Here I choose the earliest, usable, and well-tested one, which is also the one written in this PR description.
  2. Remind that sha256sum of busybox is not the same as the NAR hash in this PR diff. They are both correct.

@lovesegfault
Copy link
Member

@oxalica Done, let me know if it's working AOK:

$ aws s3 cp --recursive --acl public-read /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/ s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6
upload: ../../../../nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/busybox to s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/busybox
upload: ../../../../nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/bootstrap-tools.tar.xz to s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/bootstrap-tools.tar.xz
$ aws s3 ls s3://nixpkgs-tarballs/stdenv-linux/riscv64/                                                                                                                                                                              
                           PRE 9bd3cf0063b80428bd85a286205adab4b6ffcbd6/
$ aws s3 ls s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/
2021-12-23 17:12:51   19850552 bootstrap-tools.tar.xz
2021-12-23 17:12:51     601696 busybox
$ aws s3 cp --recursive s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6 ./                                                                                                      
download: s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/busybox to ./busybox
download: s3://nixpkgs-tarballs/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/bootstrap-tools.tar.xz to ./bootstrap-tools.tar.xz
$ sha256sum ./bootstrap-tools.tar.xz ./busybox                                                                     
5466b19288e980125fc62ebb864d09908ffe0bc50cebe52cfee89acff14d5b9f  ./bootstrap-tools.tar.xz
cdbd841abd2364270c5abb5b2e35154760d7ff47d9ac0878dd1b83ace9c575c7  ./busybox
$ sha256sum /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/*
5466b19288e980125fc62ebb864d09908ffe0bc50cebe52cfee89acff14d5b9f  /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/bootstrap-tools.tar.xz
cdbd841abd2364270c5abb5b2e35154760d7ff47d9ac0878dd1b83ace9c575c7  /nix/store/9qk7md1d9qjan0c4dzs201ic3v9yj08v-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/busybox

@oxalica
Copy link
Contributor Author

oxalica commented Dec 23, 2021

@lovesegfault

Done, let me know if it's working AOK:

The two FOD URLs are alive now, and hashes are expected. I tested building them on a new machine and it can correctly fetch it.
I think this PR is ready to merge now.

@lovesegfault lovesegfault merged commit ba3cc46 into NixOS:master Dec 23, 2021
@oxalica oxalica deleted the test/riscv-bootstrap-tools branch December 23, 2021 21:41
zhaofengli added a commit to zhaofengli/nixpkgs that referenced this pull request Jan 9, 2022
zhaofengli added a commit to zhaofengli/nixpkgs that referenced this pull request Jan 9, 2022
veprbl pushed a commit that referenced this pull request Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants