-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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-linux (Step 1) #115406
Conversation
cc @r-burns |
Any progress on this? Would be great if a trusted member could produce an official bootstrap tools tarball on https://tarballs.nixos.org |
@Ericson2314 |
@oxalica I don't mind adding to the the bootstrap tools. Long term, I am hoping the bootstrap tools can just be the tools, statically linked, and we bootstrap all the run-time libraries up from |
044425e
to
0413a5c
Compare
Rebased and rebuilt the seed. |
Gentle poke. Now that a basic NixOS system is running on riscv64, I'm really looking forward to seeing this PR merged in the near future. This script starts a simple qemu-system-riscv64 VM and should help with natively building the bootstrap tools for maintainers without access to RISC-V hardware. |
Hmm, I have a problem. The GCC in stdenv doesn't seem to be able to find spec files:
The same commands work fine on an x86-64 host. |
Still kind of confused though there's a solution. Here is the list of paths that gcc on x86-64 searched:
The same applies on aarch64. However, on riscv64 it tries the following before giving up:
At first glance we may want to link |
I've tested a naive fix which does make |
0413a5c
to
66d9511
Compare
Rebased and re-bootstrapped with QEMU VM now. PR description is also updated. I hope bootstrap tools can be uploaded and this PR can be merged soon to make fundamental PS: I'm not sure who is the right person to ask for uploading bootstrap tools. Please cc them if anyone knows. |
I left a comment in #141448 (comment) about this, basically I think non-reproducible bootstrap tools might be a no-go, and we're best off trying to generate bootstrap tools on hydra so there's no leap of faith for the tarball uploader. This could mean either:
|
I don't state that bootstrap tools are non-reproducible. They should, since the gcc issue is already resolved. I give the steps and final hash mainly for others to reproduce the same result.
I assume you mean binfmt + qemu user-mode. I tried it and it works for all packages except some
Do you mean to just use cross-compiled bootstrap tools without another bootstrapping? This means I just need to revert the last commit here. It absolutely works. I doesn't run into the issue you mentioned, since I use the cross-compiled bootstrap tools (stage0) to get native bootstrap tools (stage1). And stage1 is still able to build stage2 bootstrap tools. Thus I built If we need hydra to perform the build, what should I do here? |
@@ -81,6 +81,8 @@ let | |||
else if targetPlatform.system == "aarch64-linux" then "${sharedLibraryLoader}/lib/ld-linux-aarch64.so.1" | |||
else if targetPlatform.system == "powerpc-linux" then "${sharedLibraryLoader}/lib/ld.so.1" | |||
else if targetPlatform.isMips then "${sharedLibraryLoader}/lib/ld.so.1" | |||
# `ld-linux-riscv{32,64}-<abi>.so.1` | |||
else if targetPlatform.isRiscV then "${libc_lib}/lib/ld-linux-riscv*.so.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "shared library loader" like the others.
Right I misspoke, I just meant it might be easier to get someone to mirror a hydra-built trusted-by-default artifact than something that is trusted-if-verified.
Oh, that's great! I would just say to revert the last commit then.
I don't think we need to do anything else then, we just need to get someone with infra permissions to mirror the artifact from nixpkgs:cross-trunk:bootstrapTools.riscv64.build to tarballs.nixos.org |
I'm wait for the coreutils 9.0 in staging-next #141684. Hope we can have it for linux. |
extraNativeBuildInputs = | ||
lib.optional (localSystem.isRiscV) prevStage.updateAutotoolsGnuConfigScriptsHook; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extraNativeBuildInputs = | |
lib.optional (localSystem.isRiscV) prevStage.updateAutotoolsGnuConfigScriptsHook; | |
extraNativeBuildInputs = lib.optional (localSystem.isRiscV) prevStage.updateAutotoolsGnuConfigScriptsHook; |
#143060 enables argv[0] preservation in binfmt and fixes all the argv[0]-related test failures in coreutils, however the full test suite still doesn't pass (see linked logs). |
Almost forget it. I always have my patch #118926 applied. Besides the
(1), (2) and (3) are all related to the intermediate shell script. We can fix them by,
@zhaofengli Are you interested in implementing this? I think we could enhance #143060 to fix all of these. |
@oxalica I didn't look deeper into the remaining failures - Thanks for doing that! I think for 1, one way is to build the wrappers alongside qemu, packaged as a separate output (e.g., |
It is in master now, though there were complications because of a ZFS bug. |
66d9511
to
8cf96b9
Compare
Rebased and removed commits containing binary hashes. @r-burns |
So we simply merge this and it will appear there, right? https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.riscv64.bootstrapTools (And continue in followup PRs.) |
I expect the builds to finish within a few hours: https://hydra.nixos.org/eval/1726433?filter=riscv64 |
It's done building and I can match result hashes with my own build. But how can we reference these tools by
Do we need someone manually upload build results of |
For the commit in URL it's customary to use the one that generated the bootstrap, i.e. I'd suggest preparing the PR and test that the bootstrap works locally (if you prefetch the files, nix won't attempt download). Then ping someone who can upload it manually; I'd suggest |
I've opened the following PR #147942.
I had tested building |
Motivation for this change
Fix bootstrap packages and bootstrap
stdenv
on nativeriscv64-linux
platform.Related: #101651
UPDATE 2021.11.27
Rebased and fixed. Currently it doesn't contain bootstrap binary hashes. As suggested by @r-burns #115406 (comment), we should build it on Hydra for trusted binaries.
UPDATE 2021.10.23
Rebased and re-bootstrapped with QEMU VM. Thanks @zhaofengli.
Previous attempt
Files ready to be uploaded to
tarballs.nixos.org
: (Currently on my cachix https://riscv64.cachix.org)/nix/store/yffnjz4sny3ygbm59wk69yk56ja0lyk8-busybox
Nar hash:
sha256:d67bc5ef5c550bc1e2b86b27fe20b9ffadca42b9d104ae0f27957794be62ac5f
/nix/store/gaa783s4y4w14wyc94lh5pvbpyszbvhc-bootstrap-tools.tar.xz
File hash:
sha256:541b51c0dcc4e9fb04652664ff03581c73c16e24198e4030c8ff205fc1114c3d
Steps I did
riscv64-linux
, with build platformx86_64-linux
.pkgs/stdenv/linux/bootstrap-files/riscv64.nix
.Then add fixed-output paths into store since our bootstrap file URLs are fake.
Setup a native
riscv64-linux
platform.For me, HiFive-Unleashed is used.Cross build
nix
forriscv64-linux
, copy closures to the riscv64 platform, and setup/nix
andPATH
correctly.I currently don't have any native machine, so I setup an QEMU VM for the bootstrap build.
Note that some packages like
coreutils
must be built on native machine or QEMU VM, instead of binfmt (QEMU user mode), to pass all tests . See Notes 3 below.Remote build native bootstrap tools on
riscv64-linux
with previous cross bootstrap tools.pkgs/stdenv/linux/bootstrap-files/riscv64.nix
.Notes
Bootstrap tools are currently using fake URLs. They should be uploaded first and updated to
tarballs.nixos.org
before merging this PR.All intermediate and final store paths are available on https://riscv64.cachix.org.
Using
binfmt
instead of native riscv64 platform (or QEMU VM) will make few derivations likecoreutils
fail thecheckPhase
because of changedargv[0]
and emulator behavior. Some tests expects a specific failure like "invalid cwd" from binary, but binfmt qemu fails before it which produces different error message.gcc10
uses PGO and therefore not deterministic (gcc10: build is not deterministic #108475). So bootstrap file hashs may also be not reproducible.libatomic
is required for packages linkingpthread
or using<atomic>
(likexz
) during the bootstrap.But there is another way to avoid producinglibatomic
in bootstrap tools, but re-configure these packages to disable multi-threading before newgcc
is built (like what we do withperl
)I'm not sure which way is preferred.
I just added
libatomic
to bootstrap tools.bootstrap-tools-stage2
differs frombootstrap-tools-stage1
. The differences are from glibc and gcc (cc1/cc1plus).I believe it's caused by that
-frandom-seed
is based on$out
(stdenv: introduce -frandom-seed #102251), which is hashed from all drv inputs. Here between two bootstraps, the bootstrap tools should be functionally identical but have different hash, which changesrandom-seed
of downstream packages.It should not be an issue though.
diff -r ./result-rv64-bootstrap-tools-stage{1,2}