denzp / rust-ptx-builder

Convenient `build.rs` helper for NVPTX crates
MIT License
53 stars 9 forks source link

Error building chapter-1: can't find crate for compiler_builtins #3

Closed dbeckwith closed 6 years ago

dbeckwith commented 6 years ago

Not sure what to do about this error. I believe I have everything set up correctly, I have xargo and ptx-linker installed. But when I tried to build the example in chapter 1 I get this error:

$ cargo bench
   Compiling backtrace-sys v0.1.16
   Compiling clap v2.31.2
   Compiling criterion-plot v0.1.3
   Compiling criterion-stats v0.1.3
   Compiling synstructure v0.6.1
   Compiling syn v0.12.15
   Compiling simplelog v0.4.4
   Compiling png v0.7.0
   Compiling failure_derive v0.1.1
   Compiling backtrace v0.3.5
   Compiling error-chain v0.11.0
   Compiling failure v0.1.1
   Compiling serde_derive_internals v0.22.2
   Compiling ptx-builder v0.3.1
   Compiling chapter-1 v0.1.0 (file://$HOME/Downloads/rust-inline-cuda-tutorial/chapter-1/host)
   Compiling serde_derive v1.0.36
error: failed to run custom build command for `chapter-1 v0.1.0 (file://$HOME/Downloads/rust-inline-cuda-tutorial/chapter-1/host)`
process didn't exit successfully: `$HOME/Downloads/rust-inline-cuda-tutorial/target/release/build/chapter-1-f9e9b6b73dea461b/build-script-build` (exit code: 1)
--- stderr
[PTX] Unable to build a PTX crate!
[PTX]     Updating git repository `https://github.com/nagisa/math.rs.git`
[PTX]     Updating registry `https://github.com/rust-lang/crates.io-index`
[PTX]    Compiling cty v0.1.5
[PTX]    Compiling nvptx-builtins v0.1.0
[PTX] error[E0463]: can't find crate for `compiler_builtins`
[PTX] 
[PTX] error: aborting due to previous error
[PTX] 
[PTX] For more information about this error, try `rustc --explain E0463`.
[PTX] error: Could not compile `cty`.
[PTX] warning: build failed, waiting for other jobs to finish...
[PTX] error[E0463]: can't find crate for `compiler_builtins`
[PTX] 
[PTX] error: aborting due to previous error
[PTX] 
[PTX] For more information about this error, try `rustc --explain E0463`.
[PTX] error: Could not compile `nvptx-builtins`.
[PTX] 
[PTX] To learn more, run the command again with --verbose.

warning: build failed, waiting for other jobs to finish...
error: build failed

This is with ptx-linker 0.5.1 and rustc 1.27.0-nightly (7360d6dd6 2018-04-15). Any ideas?

I love this project BTW, hope you continue the tutorial!

denzp commented 6 years ago

I remember I had a similar problem, can be related to xargo#212. Cou you please try to update your xargo?

denzp commented 6 years ago

Btw, unfortunately, I can't build it myself on latest nightly rustc 1.27.0-nightly (7f3444e1b 2018-04-26)

LLVM ERROR: Cannot select: intrinsic %llvm.nvvm.read.ptx.sreg.nctaid.x
error: Could not compile `chapter-1-kernel`.
warning: build failed, waiting for other jobs to finish...
LLVM ERROR: Cannot select: intrinsic %llvm.nvvm.read.ptx.sreg.nctaid.x
error: Could not compile `chapter-1-kernel`.
warning: build failed, waiting for other jobs to finish...
error: build failed

This is a tough error, I'm going to check for LLVM changes regarding to NVPTX...

Anyways, there should be possible to build the tutorial, until you update your Rust ;)

Edit: Oh, shame on me... I accidentally ran build on project root, and I was building everything for my host target... It works perfectly on latest nightly :)

dbeckwith commented 6 years ago

Also I realized I meant to file this on https://github.com/denzp/rust-inline-cuda-tutorial, oops...

Yeah I had the same problem, first I was building from the project root and got something similar to that. The output above was from building in chapter-1/host though. My version of xargo should be pretty new, but I can try updating it later tonight. I'm fairly new to Rust so I'm not quite sure about something though, does the current default rustup toolchain make a difference when I cargo install something? If so, which toolchain should I use to install xargo?

denzp commented 6 years ago

No problem the issue is related to the project as well ;)

When you do cargo install NAME, the binary is being built with your default toolchain. And after that, it won't be rebuilt unless you run cargo install -f NAME to update the application to the latest version.

Probably you can build xargo with stable toolchain (if it doesn't depend on unstable features). But to use it, unfortunately, you'll need a nightly toolchain anyways.

dbeckwith commented 6 years ago

Ah, okay I see. I will try out updating xargo and see if that helps. Could you comment with the versions of xargo and rustc that you used?

denzp commented 6 years ago

Perhaps, I'll add versions validation to the ptx-builder crate.

My versions are:

$ rustc -V
rustc 1.27.0-nightly (7f3444e1b 2018-04-26)

$ xargo -V
xargo 0.3.12
cargo 1.27.0-nightly (0a1add2d8 2018-04-20)
dbeckwith commented 6 years ago

So before I had

$ xargo --version
xargo 0.3.7
cargo 1.26.0-nightly (008c36908 2018-04-13)

and now I have

$ xargo --version
xargo 0.3.12
cargo 1.27.0-nightly (0a1add2d8 2018-04-20)

and it works! Thanks for the help! Some version checking on ptx-builder might be a good idea yeah.

denzp commented 6 years ago

I'm glad it helped!

BTW, version checking is implemented and published in ptx-builder v0.3.2.