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

compiling terminfo #64

Open
pcj opened this issue Sep 29, 2018 · 11 comments
Open

compiling terminfo #64

pcj opened this issue Sep 29, 2018 · 11 comments

Comments

@pcj
Copy link

pcj commented Sep 29, 2018

I'm trying to pull in @damienmg's starlark crate and am seeing the folllowing issue.

Her is my Cargo.toml file:

[package]
name = "fake_lib"
version = "0.0.1"

[lib]
path = "lib.rs"

[dependencies]
starlark = "0.1.2"

[raze]
genmode = "Remote"
workspace_path = "//cargo"

When the terminfo dependency is compiled, I see the following error:

INFO: Analysed target //:main (1 packages loaded).
INFO: Found 1 target...
ERROR: /home/pcj/.cache/bazel/_bazel_pcj/9feaf001454c16e46c01ade0d88992bb/external/raze__terminfo__0_6_1/BUILD.bazel:23:1: error executing shell command: '/bin/bash -c set -e; if [ ! -z "${TMPDIR+x}" ]; then mkdir -p $TMPDIR; fi; rm -rf bazel-out/k8-fastbuild/bin/external/raze__terminfo__0_6_1/terminfo.deps; mkdir bazel-out/k8-fastbuild/bin/external/...' failed (Exit 101)
error: couldn't read "/home/pcj/.cache/bazel/_bazel_pcj/9feaf001454c16e46c01ade0d88992bb/sandbox/linux-sandbox/1/execroot/__main__/out_dir/names.rs": No such file or directory (os error 2)
  --> external/raze__terminfo__0_6_1/src/names.rs:15:1
   |
15 | include!(concat!(env!("OUT_DIR"), "/names.rs"));
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Any suggestions?

@damienmg
Copy link
Member

Hi Paul,

I haven't tried to build starlark with Bazel yet but I had to use terminfo on some other occasion, you need to declare that build.rs is needed in your Cargo.toml:

[raze.crates.terminfo.'0.6.0']
gen_buildrs = true

You will need that for starlark itself also:

[raze.crates.starlark.'0.1.2']
gen_buildrs = true

If you succeed, feel free to send PR to add this to the starlark documentation (or even add a Bazel build to it).

@pcj
Copy link
Author

pcj commented Sep 29, 2018

Thanks, that got me farther.

[package]
name = "fake_lib"
version = "0.0.1"

[lib]
path = "lib.rs"

[dependencies]
starlark = "0.1.2"

[raze]
genmode = "Remote"
workspace_path = "//cargo"

[raze.crates.terminfo.'0.6.0']
gen_buildrs = true

[raze.crates.starlark.'0.1.2']
gen_buildrs = true

[raze.crates.typenum.'1.10.0']
gen_buildrs = true

Any ideas about this one?

INFO: Found 1 target...
ERROR: /home/pcj/.cache/bazel/_bazel_pcj/9feaf001454c16e46c01ade0d88992bb/external/raze__thread_local__0_3_6/BUILD.bazel:21:1: error executing shell command: '/bin/bash -c set -e; if [ ! -z "${TMPDIR+x}" ]; then mkdir -p $TMPDIR; fi; rm -rf bazel-out/host/bin/external/raze__thread_local__0_3_6/thread_local.deps; mkdir bazel-out/host/bin/external/raze__th...' failed (Exit 101)
error: cannot find macro `__lazy_static_create!` in this scope
  --> external/raze__thread_local__0_3_6/src/thread_id.rs:39:1
   |
39 | / lazy_static! {
40 | |     static ref THREAD_ID_MANAGER: Mutex<ThreadIdManager> = Mutex::new(ThreadIdManager::new());
41 | | }
   | |_^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0425]: cannot find value `LAZY` in this scope
  --> external/raze__thread_local__0_3_6/src/thread_id.rs:39:1
   |
39 | / lazy_static! {
40 | |     static ref THREAD_ID_MANAGER: Mutex<ThreadIdManager> = Mutex::new(ThreadIdManager::new());
41 | | }
   | |_^ not found in this scope
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

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

@mfarrugi
Copy link
Collaborator

#41 (comment) was the answer to lazy static; the general formula is running the build_rs or replicating what it does (eg. by hardcoding flags)

@pcj
Copy link
Author

pcj commented Sep 30, 2018

Thank you! Farther again, but stuck once more. Although proc_macro2 was mentioned in the comment you referenced, applying those cfg values does not seem to resolve the issue within the syn library:

[package]
name = "fake_lib"
version = "0.0.1"

[lib]
path = "lib.rs"

[dependencies]
starlark = "0.1.2"

[raze]
genmode = "Remote"
workspace_path = "//cargo"
target = "x86_64-unknown-linux-gnu"

[raze.crates.terminfo.'0.6.1']
gen_buildrs = true

[raze.crates.starlark.'0.1.2']
gen_buildrs = true

[raze.crates.typenum.'1.10.0']
gen_buildrs = true

[raze.crates.lazy_static.'1.1.0']
additional_flags = [
  "--cfg=lazy_static_heap_impl",
]


# not helping...

[raze.crates.syn.'0.15.6']
gen_buildrs = true

[raze.crates.proc_macro2.'0.4.19']
additional_flags = [
#  "--cfg=wrap_proc_macro",
  "--cfg=use_proc_macro",
  "--cfg=slow_extend",
]

[raze.crates.proc_macro2.'0.3.8']
additional_flags = [
#  "--cfg=wrap_proc_macro",
  "--cfg=use_proc_macro",
  "--cfg=slow_extend",
]
ERROR: /home/pcj/.cache/bazel/_bazel_pcj/9feaf001454c16e46c01ade0d88992bb/external/raze__syn__0_15_6/BUILD.bazel:21:1: error executing shell command: '/bin/bash -c set -e; if [ ! -z "${TMPDIR+x}" ]; then mkdir -p $TMPDIR; fi; rm -rf bazel-out/host/bin/external/raze__syn__0_15_6/syn.deps; mkdir bazel-out/host/bin/external/raze__syn__0_15_6/syn.dep...' failed (Exit 101)
error[E0277]: the trait bound `proc_macro2::TokenStream: std::convert::From<proc_macro::TokenStream>` is not satisfied
   --> external/raze__syn__0_15_6/src/buffer.rs:116:27
    |
116 |         Self::new2(stream.into())
    |                           ^^^^ the trait `std::convert::From<proc_macro::TokenStream>` is not implemented for `proc_macro2::TokenStream`
    |
    = note: required because of the requirements on the impl of `std::convert::Into<proc_macro2::TokenStream>` for `proc_macro::TokenStream`

error[E0308]: mismatched types
    --> external/raze__syn__0_15_6/src/parse.rs:1061:52
     |
1061 |         self.parse2(proc_macro2::TokenStream::from(tokens))
     |                                                    ^^^^^^ expected struct `proc_macro2::TokenStream`, found struct `proc_macro::TokenStream`
     |
     = note: expected type `proc_macro2::TokenStream`
                found type `proc_macro::TokenStream`

error: aborting due to 2 previous errors

Some errors occurred: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

Any additional suggestions?

@mfarrugi
Copy link
Collaborator

mfarrugi commented Sep 30, 2018

I updated the linked post, our file has

[raze.crates.proc-macro2.'0.4.19']
additional_flags = [
    "--cfg use_proc_macro",
]

I don't recall any difference between --cfg= and --cfg<space>, but that's the only difference.

Also, I don't see a build.rs in syn but that doesn't look relevant.

@pcj
Copy link
Author

pcj commented Sep 30, 2018

The space didn't seem to matter. If I look at the features of the syn build file, it has both proc-macro and proc-macro2 features. Should these be orthogonal?

rust_library(
    name = "syn",
    crate_root = "src/lib.rs",
    crate_type = "lib",
    srcs = glob(["**/*.rs"]),
    deps = [
        "@raze__proc_macro2__0_4_19//:proc_macro2",
        "@raze__quote__0_6_8//:quote",
        "@raze__unicode_xid__0_1_0//:unicode_xid",
    ],
    rustc_flags = [
        "--cap-lints allow",
        "--target=x86_64-unknown-linux-gnu",
    ],
    crate_features = [
        "clone-impls",
        "default",
        "derive",
        "parsing",
        "printing",
        "proc-macro",
        "proc-macro2",
        "quote",
        "visit",
    ],
)

@mfarrugi
Copy link
Collaborator

mfarrugi commented Sep 30, 2018 via email

@pcj
Copy link
Author

pcj commented Sep 30, 2018

Manually removing the proc-macro feature and retaining the proc-macro2 feature did the trick. Is there a way to suppress this in the generator?

Next one is:

INFO: SHA256 (https://crates-io.s3-us-west-1.amazonaws.com/crates/serde_derive/serde_derive-1.0.79.crate) = 31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe
INFO: Analysed target //:docgen (1 packages loaded).
INFO: Found 1 target...
ERROR: /home/pcj/.cache/bazel/_bazel_pcj/9feaf001454c16e46c01ade0d88992bb/external/raze__serde_derive__1_0_79/BUILD.bazel:20:1: error executing shell command: '/bin/bash -c set -e; if [ ! -z "${TMPDIR+x}" ]; then mkdir -p $TMPDIR; fi; rm -rf bazel-out/host/bin/external/raze__serde_derive__1_0_79/serde_derive.deps; mkdir bazel-out/host/bin/external/raze__s...' failed (Exit 101)
error: cannot find macro `parse_macro_input!` in this scope
  --> external/raze__serde_derive__1_0_79/src/lib.rs:86:17
   |
86 |     let input = parse_macro_input!(input as DeriveInput);
   |                 ^^^^^^^^^^^^^^^^^

error: cannot find macro `parse_macro_input!` in this scope
  --> external/raze__serde_derive__1_0_79/src/lib.rs:94:17
   |
94 |     let input = parse_macro_input!(input as DeriveInput);
   |                 ^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

The serde_derive Cargo.toml has:


[lib]
name = "serde_derive"
proc-macro = true

How would this be expressed with cargo-raze? Thanks for all your responses so far, very much appreciated and sorry to be such a pain.

@mfarrugi
Copy link
Collaborator

mfarrugi commented Sep 30, 2018 via email

@matt-duch
Copy link

I just ran in to this while starting a new project (it's just calling serde_json::to_string as a test to experiment with rust).

@pcj the proc-macro feature can't be removed (I'm pretty sure that's causing your next issue). I solved the problem with only one change, adding to my Cargo.toml:

[raze.crates.proc-macro2.'0.4.20']
additional_flags = [
    "--cfg use_proc_macro",
]

@arlyon
Copy link

arlyon commented Dec 11, 2019

@matt-duch's fix worked for me, although I needed --cfg=use_proc_macro on proc-macro version 1.0.6. Omitting the '=' didn't work for some reason.

[raze.crates.proc-macro2.'1.0.6']
additional_flags = [
    "--cfg=use_proc_macro",
]

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

5 participants