nvptx icon indicating copy to clipboard operation
nvptx copied to clipboard

Examples throw Error E0225

Open reiner-dolp opened this issue 7 years ago • 7 comments

Compiling the kernels in the examples directory using

xargo rustc \
    --manifest-path kernel/Cargo.toml \
    --release \
    --target nvptx64-nvidia-cuda \
    -- --emit=asm

I get the following error during the compilation of core64:

error[E0225]: only Send/Sync traits can be used as additional traits in a trait object
   --> C:\Users\Reiner\.cargo\git\checkouts\core64-98c99607e3b29655\0e29675\any.rs:133:27
    |
133 | impl fmt::Debug for Any + Send {
    |                           ^^^^ non-Send/Sync additional trait

error[E0225]: only Send/Sync traits can be used as additional traits in a trait object
   --> C:\Users\Reiner\.cargo\git\checkouts\core64-98c99607e3b29655\0e29675\any.rs:244:10
    |
244 | impl Any+Send {
    |          ^^^^ non-Send/Sync additional trait

error: aborting due to 2 previous errors

Any Idea what I am doing wrong?

reiner-dolp avatar Jan 16 '18 20:01 reiner-dolp

@japaric Any idea how to solve this issue? (do you need to sync your branch #13). I get the similar rustc nightly 1.27 error with:

error: `impl Trait for .. {}` is an obsolete syntax
  --> /home/ilab/.cargo/git/checkouts/core64-98c99607e3b29655/0e29675/marker.rs:51:1
   |
51 | unsafe impl Send for .. { }
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: use `auto trait Trait {}` instead

error: `impl Trait for .. {}` is an obsolete syntax
   --> /home/ilab/.cargo/git/checkouts/core64-98c99607e3b29655/0e29675/marker.rs:356:1
    |
356 | unsafe impl Sync for .. { }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `auto trait Trait {}` instead

error: `impl Trait for .. {}` is an obsolete syntax
   --> /home/ilab/.cargo/git/checkouts/core64-98c99607e3b29655/0e29675/marker.rs:571:1
    |
571 | unsafe impl Freeze for .. {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `auto trait Trait {}` instead

error[E0225]: only auto traits can be used as additional traits in a trait object
   --> /home/ilab/.cargo/git/checkouts/core64-98c99607e3b29655/0e29675/any.rs:133:27
    |
133 | impl fmt::Debug for Any + Send {
    |                           ^^^^ non-auto additional trait

error[E0225]: only auto traits can be used as additional traits in a trait object
   --> /home/ilab/.cargo/git/checkouts/core64-98c99607e3b29655/0e29675/any.rs:244:10
    |
244 | impl Any+Send {
    |          ^^^^ non-auto additional trait

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0225`.
error: Could not compile `core`.

To learn more, run the command again with --verbose.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.M2H5rCFO09xN/Cargo.toml" "--target" "nvptx64-nvidia-cuda" "-p" "core"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace

ehsanmok avatar Apr 20 '18 18:04 ehsanmok

I was able to compile somewhat by using the last toolchain to produce a successful build in the CI, but I ended up getting a panic in xargo and gave up... I would really like to be able to get this to work in the current nightly.

dbeckwith avatar Apr 23 '18 19:04 dbeckwith

FWIW someone tried to fix this in the core64 crate: https://github.com/japaric/core64/pull/4

dbeckwith avatar Apr 23 '18 19:04 dbeckwith

I could successfully build using the nightly libcore: rustc 1.27.0-nightly (0b72d48f8 2018-04-10) with some changes. My related system specs: Ubuntu 16.04, LLVM 6.0, gcc 5.4, CUDA 8

  1. Remove the following from Xargo.toml. (Xargo.toml is not needed for this example)
[dependencies.core]
git = "https://github.com/japaric/core64"
  1. You could add #![feature(abi_ptx)] to src/lib.rs but for this example, it still works without it. My src/lib.rs
#![no_std]
fn foo() {}

but be aware of this tracking issue.

  1. Modify nvptx64-nvidia-cuda.json (got it from here)
{
    "arch": "nvptx64",
    "cpu": "sm_20",
    "data-layout": "e-i64:64-v16:16-v32:32-n16:32:64",
    "linker": false,
    "linker-flavor": "ld",
    "linker-is-gnu": true,
    "dynamic-linking": true,
    "llvm-target": "nvptx64-nvidia-cuda",
    "max-atomic-width": 0,
    "os": "cuda",
    "obj-is-bitcode": true,
    "panic-strategy": "abort",
    "target-endian": "little",
    "target-c-int-width": "32",
    "target-pointer-width": "64"
}
  1. xargo +nightly rustc --target nvptx64-nvidia-cuda --release -- --emit=asm

and then cat $(find -name "*.s") outputs

//
// Generated by LLVM NVPTX Back-End
//

.version 3.2
.target sm_20
.address_size 64

ehsanmok avatar Apr 26 '18 01:04 ehsanmok

@ehsanmok what nightly version did you use?

This is what I'm currently using

Default host: x86_64-pc-windows-msvc

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)

active toolchain
----------------

nightly-x86_64-pc-windows-msvc (default)
rustc 1.27.0-nightly (e82261dfb 2018-05-03)

and get the following error

+ "rustc" "--print" "sysroot"
+ "rustc" "--print" "target-list"
+ RUSTFLAGS="--sysroot C:\\Users\\ADN\\.xargo"
+ "cargo" "+nightly" "rustc" "--target" "nvptx64-nvidia-cuda" "--release" "--" "--emit=asm" "--verbose"
   Compiling cuda v0.1.0 (https://github.com/japaric/cuda#f15863be)
error: Error loading target specification: Could not find specification for target "nvptx64-nvidia-cuda"
  |
  = help: Use `--print target-list` for a list of built-in targets

error: Could not compile `cuda`.

To learn more, run the command again with --verbose.

TGM avatar May 04 '18 07:05 TGM

@TGM I just updated my prev post. Probably you should modify the nvptx64-nvidia-cuda.json for windows! also get rid of Xargo.toml and https://github.com/japaric/ as I said before.

ehsanmok avatar May 04 '18 20:05 ehsanmok

@TGM I had the same problem as you, and cargo install --force xargo worked for me (updates xargo to latest version).

Ploppz avatar Jul 31 '18 19:07 Ploppz