-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
rust: bootstrap from source #85542
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
base: staging
Are you sure you want to change the base?
rust: bootstrap from source #85542
Conversation
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.
Very nice! Great work! 👍
I've attempted this once before but ran into issue building the first "real" rustc with mrustc.
I left a few comments on parts that did stick out to me. We are likely also going to have the whole bootstrap story around rustc. It is a fairly long bootstrap chain. Probably hours on modern computers. That being said: we totally should bootstrap more stuff without needing external binaries.
If we give this a bit more polishing this could probably go in.
aarch64-unknown-linux-gnu = "79ddfb5e2563d0ee09a567fbbe121a2aed3c3bc61255b2787f2dd42183a10f27"; | ||
i686-apple-darwin = "628134b3fbaf5c0e7a25bd9a2b8d25f6e68bb256c8b04a3332ec979f5a1cd339"; | ||
x86_64-apple-darwin = "b6504003ab70b11f278e0243a43ba9d6bf75e8ad6819b4058a2b6e3991cc8d7a"; | ||
bootstrapRustPackages = { |
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.
IIRC mrustc did not support all the platforms we wanted to support. We should perhaps use binary bootstrapping on all of those platforms that we can't use mrustc on.
}: | ||
|
||
let | ||
inherit (stdenv.lib) optionals optional optionalString; | ||
inherit (darwin.apple_sdk.frameworks) Security; | ||
|
||
llvmSharedForBuild = pkgsBuildBuild.llvm_9.override { enableSharedLibraries = true; }; |
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.
I do not think this change here is wise. This likely breaks cross-compilation.
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.
hmm indeed, I didn't notice this. Should I replace this with a "selector" function, like pkgs: pkgs.llvm_7
?
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.
I am not entirely sure I can see what you are saying. Can you draft an example here?
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.
https://gist.github.com/ProgVal/da945eab4ec04f55123411b4063de001
It's a pattern I noticed these files already use (selectRustPackage
)
0fe3747
to
0b9697e
Compare
We have a larger aarch64 community builder that you can use for such purposes: https://github.com/nix-community/aarch64-build-box |
I added @alyssais to reviewers as we had previous conversations about this topic. I expect they might have something to add/own experiences to share. |
At first I tried being more modular; by replacing most of mrustc's makefiles with nix expressions; but it ended up as a complete mess that didn't even work because multiple .so and .rlib paths were conflicting with each other, causing either missing files, wrong rust version or "possibly newer crate" errors. Was this your issue too? |
0b9697e
to
5bc3d80
Compare
No, I did the last attempt during December and IIRC this issue contains most of my story: thepowersgang/mrustc#132 |
5bc3d80
to
95a888f
Compare
95a888f
to
0d48bb8
Compare
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.
This is amazing! I’m so excited for it!
pkgs/development/compilers/mrustc/patches/0001-use-shared-mrustc-minicargo.patch
Show resolved
Hide resolved
My experience was basically the same — I didn’t get very far. |
0d48bb8
to
c27a821
Compare
I just gave this a shot on aarch64 and ran into this: |
Would anyone object if I rebased and separately submitted the mrustc init commit? It seems like there are still some open questions here about the bootstrapping, but maybe we can save the mrustc nix expression from bitrot and work on darwin support in the meantime. |
ping #113817 |
Worth noting that mrustc was updated to support bootstrapping Rust 1.39: https://github.com/thepowersgang/mrustc/. |
I'm working on a patch on top of #113817 to support it |
Does this PR still need to stay open? |
Also, you might be interested in #123095 which is about bootstrapping the trusted binary seed fully from source (down from an 130 MB uncompressed tarball). |
I wonder if we can avoid the full stage2 bootstrap for each intermediate rustc binary - i.e. use https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html#stages-of-bootstrapping |
Even half the bootstrap chain is still too much in my opinion. |
I still don't see the problem of just adding this as a separate way of building rust, with the goal using it to create the bootstrap binaries. That doesn't wreck rebuild critical path length. What's the problem then? |
I marked this as stale due to inactivity. → More info |
Still important. mrustc got closer to latest but there have been some more releases since. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
That's not a reason to close this. The interesting part of this PR is actually using it to bootstrap rust, not the package itself. I'm going to mark this as a draft though as this hasn't seen activity in a while and needs broader consensus and/or more confidence in mrustc's ability to keep up with upstream rust so that we don't need to have an insanely long bootstrap chain with dozens of rustcs. Edit: Was a draft anyways. |
Motivation for this change
Fully building Rust from source instead of starting with a binary download.
Resolves #72606.
Things done
Discussion
I am not sure this is something you want in Nixpkgs; as it significantly increases the resources needed to build the latest Rust version.
The initial build of Rust 1.29 (by mrustc) requires 2.5GB in /build and 15GB of RAM and takes about 30 minutes on a modern x86 machine. Each subsequent build of Rust (by rustc) takes about 15 minutes.
Most of the build time (especially the first one) is spent in a single compilation unit, which is
src/librustc/lib.rs
, so it is not very parallel.It also requires LLVM 7 and 8 for older Rust version, in addition to LLVM 9 for the current version. (Although all versions should support LLVM 7, if you want to reduce this.)
Tests
I tested building on x86_64 and master. I'm currently building the chain on x86_64 + staging but it's looking good so far (I'll update this text when it's done).
I'm also trying to test on aarch64, but it's taking forever as my test machine only has 4GB of RAM.
Checklist
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)