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

Failed to get crate data when compiling proc macro crate with --target #85847

Closed
Canop opened this issue May 31, 2021 · 2 comments
Closed

Failed to get crate data when compiling proc macro crate with --target #85847

Canop opened this issue May 31, 2021 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Canop
Copy link
Contributor

Canop commented May 31, 2021

Meta

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0

I also tried with rustc 1.54.0-nightly (b663c0f 2021-05-29), and I got the same error.

Reproduction

git clone https://github.com/Canop/lazy-regex.git
cd lazy-regex
rustup target add wasm32-unknown-unknown
cargo build --target=wasm32-unknown-unknown

Error output

RUST_BACKTRACE=1 cargo build --target=wasm32-unknown-unknown --verbose
       Fresh unicode-xid v0.2.2
       Fresh regex-syntax v0.6.25
       Fresh once_cell v1.7.2
       Fresh proc-macro2 v1.0.26
       Fresh memchr v2.4.0
       Fresh quote v1.0.9
       Fresh aho-corasick v0.7.18
       Fresh syn v1.0.72
       Fresh regex v1.5.4
       Fresh lazy-regex-proc_macros v2.0.1 (/home/dys/dev/lazy-regex/src/proc_macros)
   Compiling lazy-regex v2.0.1 (/home/dys/dev/lazy-regex)
     Running `rustc --crate-name lazy_regex --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=7383ed1e4040a672 -C extra-filename=-7383ed1e4040a672 --out-dir /home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/dys/dev/lazy-regex/target/debug/deps --extern proc_macros=/home/dys/dev/lazy-regex/target/debug/deps/liblazy_regex_proc_macros-925a4044a7b9d421.so --extern once_cell=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps/libonce_cell-dbc6fec029817a84.rmeta --extern regex=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps/libregex-3d889e62663e24c7.rmeta`
thread 'rustc' panicked at 'Failed to get crate data for crate16', compiler/rustc_metadata/src/creader.rs:139:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:457:5
   2: rustc_metadata::creader::CrateLoader::maybe_resolve_crate
   3: rustc_metadata::creader::CrateLoader::maybe_process_path_extern
   4: rustc_resolve::Resolver::extern_prelude_get
   5: rustc_resolve::macros::<impl rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
   6: rustc_resolve::Resolver::resolve_path_with_ribs::{{closure}}
   7: rustc_resolve::Resolver::resolve_path_with_ribs
   8: rustc_resolve::imports::ImportResolver::resolve_imports
   9: rustc_resolve::macros::<impl rustc_expand::base::ResolverExpand for rustc_resolve::Resolver>::resolve_imports
  10: rustc_expand::expand::MacroExpander::fully_expand_fragment
  11: rustc_expand::expand::MacroExpander::expand_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::configure_and_expand_inner
  14: rustc_interface::passes::configure_and_expand::{{closure}}
  15: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  16: rustc_interface::passes::configure_and_expand
  17: rustc_interface::queries::Queries::expansion
  18: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (b663c0f4f 2021-05-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `lazy-regex`

Caused by:
  process didn't exit successfully: `rustc --crate-name lazy_regex --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=7383ed1e4040a672 -C extra-filename=-7383ed1e4040a672 --out-dir /home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/dys/dev/lazy-regex/target/debug/deps --extern proc_macros=/home/dys/dev/lazy-regex/target/debug/deps/liblazy_regex_proc_macros-925a4044a7b9d421.so --extern once_cell=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps/libonce_cell-dbc6fec029817a84.rmeta --extern regex=/home/dys/dev/lazy-regex/target/wasm32-unknown-unknown/debug/deps/libregex-3d889e62663e24c7.rmeta` (exit status: 101)

Details

The involved crate is a proc-macro : https://github.com/Canop/lazy-regex.git

There's no problem when not using --target.

I reproduced the same problem with an app using it (broot) when compiling with a target (not just wasm), but not when compiling for the local implied target.

@Canop Canop added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 31, 2021
@Canop
Copy link
Contributor Author

Canop commented May 31, 2021

@AlephAlpha found a workaround: https://github.com/Canop/lazy-regex/pull/6/files

This issue should still probably stay open because of the rustc crash and because the problem isn't clear.

@jyn514
Copy link
Member

jyn514 commented May 31, 2021

Duplicate of #85386 (which was in turn a narrow case of #56935).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants