Skip to content
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

OS X example build failed #27

Closed
MrRobb opened this issue Oct 28, 2019 · 12 comments
Closed

OS X example build failed #27

MrRobb opened this issue Oct 28, 2019 · 12 comments

Comments

@MrRobb
Copy link

MrRobb commented Oct 28, 2019

Hello, I am trying the example:

#[macro_use]
extern crate em;
use em::*;

#[gpu_use]
fn main() {
    let mut x = vec![0.0; 1000];

    gpu_do!(load(x)); // move data to the GPU
    
    gpu_do!(launch()); // off-load to run on the GPU

    for i in 0..1000 {
        x[i] = x[i] * 10.0;
    }

    gpu_do!(read(x)); // move data back from the GPU
    
    println!("{:?}", x);
}

Here's the error.

   ...
   Compiling emu_macro v0.1.0
error[E0277]: the trait bound `syn::Expr: std::convert::From<quote::__rt::TokenStream>` is not satisfied
   --> /Users/mrrobb/.cargo/registry/src/github.com-1ecc6299db9ec823/emu_macro-0.1.0/src/passing.rs:337:50
    |
337 |                     let gpu_ident = quote! {gpu}.into();
    |                                                  ^^^^ the trait `std::convert::From<quote::__rt::TokenStream>` is not implemented for `syn::Expr`
    |
    = help: the following implementations were found:
              <syn::Expr as std::convert::From<syn::ExprArray>>
              <syn::Expr as std::convert::From<syn::ExprAssign>>
              <syn::Expr as std::convert::From<syn::ExprAssignOp>>
              <syn::Expr as std::convert::From<syn::ExprAsync>>
            and 35 others
    = note: required because of the requirements on the impl of `std::convert::Into<syn::Expr>` for `quote::__rt::TokenStream`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `emu_macro`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Am I doing something wrong? Thank you.

@calebwin
Copy link
Owner

Hi,

This is similar to the issue described here on the Gitter chat. The solution was updating Rust to latest version.

Let me know if that works for you!

@Micael106
Copy link

Micael106 commented Nov 1, 2019

the latest version of rust is 1.38.0? doens't work here, in macos high sierra.

Compiling emu_macro v0.1.0
error[E0277]: the trait bound `syn::Expr: std::convert::From<quote::__rt::TokenStream>` is not satisfied
   --> /Users/labmint2/.cargo/registry/src/github.com-1ecc6299db9ec823/emu_macro-0.1.0/src/passing.rs:337:50
    |
337 |                     let gpu_ident = quote! {gpu}.into();
    |                                                  ^^^^ the trait `std::convert::From<quote::__rt::TokenStream>` is not implemented for `syn::Expr`
    |
    = help: the following implementations were found:
              <syn::Expr as std::convert::From<syn::ExprArray>>
              <syn::Expr as std::convert::From<syn::ExprAssign>>
              <syn::Expr as std::convert::From<syn::ExprAssignOp>>
              <syn::Expr as std::convert::From<syn::ExprAsync>>
            and 35 others
    = note: required because of the requirements on the impl of `std::convert::Into<syn::Expr>` for `quote::__rt::TokenStream`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

@calebwin
Copy link
Owner

calebwin commented Nov 1, 2019

I've tried compiling on Windows and Linux on Rust 1.38.0 and build has been successful.

stable-x86_64-pc-windows-msvc unchanged - rustc 1.38.0 (625451e37 2019-09-23)
stable-x86_64-unknown-linux-gnu updated - rustc 1.38.0 (625451e37 2019-09-23)

@MrRobb are you also on MacOS?

However, interestingly, when I look at the docs the error message seems correct. From<proc_macro2::TokenStream> is implemented but not From<quote::__rt::TokenStream>.

I'll try to switch to proc_macro2::TokenStream and see if that can be done without regression when I get a chance.

@Micael106
Copy link

I tried several versions of rust and got the same error, older versions and nightly

@calebwin
Copy link
Owner

calebwin commented Nov 1, 2019

I've replicated the issue and I'm really not sure how to resolve it. Digging into quote source code, it seems like there is a runtime.rs module that makes a pub use proc_macro2::*. So somehow that seems to be creating 2 copies of proc_macro2 and that's causing type mismatch errors which the .into() then fails to convert into the correct type.

I don't actually have that much experience with Rust so it would be great if someone could git clone this, change em/Cargo.toml's emu_macro = 0.1.0 to emu_macro = { path = "../emu_macro" }, and try to fix the type mismatch error.

Or, if anyone has ideas for how to fix this, please let me know.

@MrRobb
Copy link
Author

MrRobb commented Nov 2, 2019

@calebwin I am using MacOS Catalina and Rust 1.38.0.

@Micael106
Copy link

unfortunately I also know very little about rust to help solve, I started learning this week for a college GPU job. I will use version 0.2.0, which compiled here.

This version uses quote 0.6.13

@calebwin
Copy link
Owner

calebwin commented Nov 3, 2019

@MrRobb @Micael106 I think I fixed the issue; the fix is pushed to the dev branch.

Would you mind cloning it and testing it out? If it works fine, I will probably pull it into the master branch and then publish the fix.

@Micael106
Copy link

it's working now. thank you!
Screen Shot 2019-11-02 at 22 38 09

@calebwin
Copy link
Owner

calebwin commented Nov 3, 2019

Yay! I'll pull into master and publish an update when I get a chance.

@jkelleyrtp
Copy link

Not sure if you've had a chance to pull it in yet, just reporting in that the dev branch works but not master for me

@calebwin
Copy link
Owner

calebwin commented Feb 3, 2020 via email

StevenLu2004 added a commit to StevenLu2004/emu that referenced this issue Apr 1, 2021
Bumped crate quote from ^1.0.2 to ^1.0.3
Replaced quote::__rt with quote::__private
Changed crate syn from ^1.0.5 to =1.0.5
calebwin added a commit that referenced this issue Apr 1, 2021
Fix compile failure issues #27 and #36
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants