crate2nix
crate2nix copied to clipboard
Cant build compiler_builtins, can't find crate for `std`
builder for '/nix/store/g2mvz5l51iw0rnxl5lma6j7vhjf7whv6-rust_compiler_builtins-0.1.26.drv' failed with exit code 1; last 10 log lines:
patching sources
configuring
Running cd .
Building build.rs (compiler_builtins)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=4 --edition 2015 --cfg feature="compiler-builtins" --cfg feature="default" --out-dir target/build/compiler_builtins --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow --color always
error[E0463]: can't find crate for `std`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
[3 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/g2mvz5l51iw0rnxl5lma6j7vhjf7whv6-rust_compiler_builtins-0.1.26.drv' failed
Hi @deliciouslytyped,
How do I reproduce the error? Please always provide a Cargo.toml or whatever is needed to reproduce the build error.
That said, I had a similar error when I overrode the rust compiler with the mozilla overlay and replaced rustc with rustc.
That sounds about right. My stuff is all over the place right now but I'll try to follow up with a repro later. This should just be against a clone of the compiler_builtins repo with a rustc override from the mozilla overlay.
Generally, I obviously appreciate every effort into making this easy to reproduce for me. (I don't get paid for this work in any way) So please generally try to reproduce the problem from a blank slate and write down all steps along the way. Often it works if you do a simple cargo new --bin something, add some dependencies and run cargo generate. But you definitely should mention your nixpkgs/crate2nix version and even more definitely if you override the compiler.
I followed the instruction in the README: Choosing a rust version and applied this additional steps:
- change "stable" to "nightly"
- Use a recent nixpkgs because it contains necessary fixes:
niv update nixpkgs -b nixpkgs-unstable
I got this result:
❯ nix build
builder for '/nix/store/y5rlzrbnarhmza564xjlm1hdgac5kjpq-rust_using_compiler_builtins-0.1.0.drv' failed with exit code 1; last 7 log lines:
unpacking sources
unpacking source archive /nix/store/13c461a8dyycaq0zgn60108xmdf31ap3-source
source root is source
patching sources
configuring
Running cd .
/nix/store/1rah9ljqzhj9cq2jf7gqnl9jpysgd50c-rust_compiler_builtins-0.1.26-lib/env: line 1: export: `DEP_compiler_builtins_COMPILER-RT=/build/compiler-builtins-2541f27/compiler-rt': not a valid identifier
[9 built (1 failed), 18.3 MiB DL]
error: build of '/nix/store/y5rlzrbnarhmza564xjlm1hdgac5kjpq-rust_using_compiler_builtins-0.1.0.drv' failed
Basically, the build stumbles over the hyphen in the variable name.
I could "fix" it like this:
https://github.com/kolloch/nixpkgs/tree/pkolloch-buildRustCrate-quoting-env
But I don't have the time right now to do a proper pull request. Maybe you have some time to think about it and provide a proper nixpkgs fix with tests in the pkgs/build-support/rust/build-rust-crate/tests/default.nix file, @deliciouslytyped ?
In https://github.com/kolloch/crate2nix/tree/pkolloch-compiler_builtins_sample there is
a sample_projects/using_compiler_builtins directory which shows how to stich all this together.
It is not used in tests or the like and it depends on a branch in my nixpkgs fork.
Yeah, sorry about the lack of repro, I generally try to provide a minimal example, just had too much stuff going on at once and wanted to make sure an issue at least /exists/.
Yeah, sorry about the lack of repro, I generally try to provide a minimal example, just had too much stuff going on at once and wanted to make sure an issue at least /exists/.
No worries.