crate2nix icon indicating copy to clipboard operation
crate2nix copied to clipboard

Cant build compiler_builtins, can't find crate for `std`

Open deliciouslytyped opened this issue 5 years ago • 7 comments

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

deliciouslytyped avatar Apr 12 '20 02:04 deliciouslytyped

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.

kolloch avatar Apr 12 '20 21:04 kolloch

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.

deliciouslytyped avatar Apr 12 '20 21:04 deliciouslytyped

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:

  1. change "stable" to "nightly"
  2. 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.

kolloch avatar Apr 13 '20 09:04 kolloch

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 ?

kolloch avatar Apr 13 '20 10:04 kolloch

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.

kolloch avatar Apr 13 '20 10:04 kolloch

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/.

deliciouslytyped avatar Apr 13 '20 12:04 deliciouslytyped

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.

kolloch avatar Apr 13 '20 13:04 kolloch