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

'crate-type = ["proc-macro"]' causes 'error: proc-macro crate not dylib' and ICE when documenting downstream crates #52625

Closed
ExpHP opened this issue Jul 22, 2018 · 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

@ExpHP
Copy link
Contributor

ExpHP commented Jul 22, 2018

Reproduction

Minimal reproduction requires two crates. Here's a script to generate them:

Bash script
#!/usr/bin/env bash

rm -rf dep main

cargo new --lib dep
cargo new --bin main

cat >dep/Cargo.toml <<EOF
[package]
name = "dep"
version = "0.1.0"

[lib]
crate-type = ["proc-macro"]
EOF

cat >main/Cargo.toml <<EOF
[package]
name = "main"
version = "0.1.0"

[dependencies]
dep = { path = "../dep" }
EOF

cat >main/src/main.rs <<EOF
#![allow(unused)]
#[macro_use]
extern crate dep;

fn main() {}
EOF

cd dep
cargo build || exit 1 # ok
cargo doc   || exit 1 # ok
cd ..

cd main
cargo build || exit 1 # ok
cargo doc   || exit 1 # 'error: proc-macro crate not dylib'
cd ..

Output

 Documenting main v0.1.0 (file:///home/lampam/cpp/throwaway/rep/main)                                                                       
thread '<unnamed>' panicked at 'librustc_metadata/creader.rs:524: proc-macro crate not dylib', librustc/session/mod.rs:1297:26              
note: Run with `RUST_BACKTRACE=1` for a 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.29.0-nightly (1ecf6929d 2018-07-16) running on x86_64-unknown-linux-gnu

error: Could not document `main`.                                                                                                           

Caused by:
  process didn't exit successfully: `rustdoc --crate-name main src/main.rs -o /home/lampam/cpp/throwaway/rep/main/target/doc -L dependency=/home/lampam/cpp/throwaway/rep/main/target/debug/deps --extern dep=/home/lampam/cpp/throwaway/rep/main/target/debug/deps/libdep-81a747942b9c6cac.rmeta` (exit code: 101)

Stack trace is probably easy to guess and not very interesting, but here you go:

Stack trace
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:475
   5: std::panicking::begin_panic
   6: rustc::session::opt_span_bug_fmt::{{closure}}
   7: rustc::ty::context::tls::with_opt::{{closure}}
   8: rustc::ty::context::tls::with_context_opt
   9: rustc::ty::context::tls::with_opt
  10: rustc::session::opt_span_bug_fmt
  11: rustc::session::span_bug_fmt
  12: rustc_metadata::creader::CrateLoader::resolve_crate
  13: <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_extern_crate
  14: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::build_reduced_graph_for_item
  15: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
  16: syntax::visit::walk_item
  17: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
  18: syntax::ext::expand::AstFragment::visit_with
  19: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_ast_fragment_with_placeholders
  20: syntax::ext::expand::MacroExpander::collect_invocations
  21: syntax::ext::expand::MacroExpander::expand_fragment
  22: syntax::ext::expand::MacroExpander::expand_crate
  23: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}
             at /checkout/src/librustc_driver/driver.rs:986
             at /checkout/src/librustc/util/common.rs:166
             at /checkout/src/librustc/util/common.rs:160
             at /checkout/src/librustc_driver/driver.rs:985
  24: rustc::util::common::time
             at /checkout/src/librustc/util/common.rs:166
             at /checkout/src/librustc/util/common.rs:160
  25: rustdoc::core::run_core::{{closure}}
             at /checkout/src/librustc_driver/driver.rs:938
             at librustdoc/core.rs:293
  26: rustc_driver::driver::spawn_thread_pool
             at /checkout/src/librustc_driver/driver.rs:73
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /checkout/src/librustc_driver/driver.rs:72
  27: rustdoc::core::run_core
             at librustdoc/core.rs:248
  28: <scoped_tls::ScopedKey<T>>::set
             at librustdoc/lib.rs:674
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /checkout/src/libsyntax/lib.rs:100
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  29: syntax::with_globals
             at /checkout/src/libsyntax/lib.rs:99
  30: std::panicking::try::do_call
             at librustdoc/lib.rs:670
             at /checkout/src/librustc_driver/lib.rs:1633
             at /checkout/src/libstd/panic.rs:313
             at /checkout/src/libstd/panicking.rs:310
  31: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:106
  32: rustc_driver::monitor
             at /checkout/src/libstd/panicking.rs:289
             at /checkout/src/libstd/panic.rs:392
             at /checkout/src/librustc_driver/lib.rs:1565
             at /checkout/src/librustc_driver/lib.rs:1632
  33: rustdoc::rust_input
             at librustdoc/lib.rs:670
  34: rustdoc::main_args
             at librustdoc/lib.rs:590
             at librustdoc/lib.rs:545
  35: <scoped_tls::ScopedKey<T>>::set
             at librustdoc/lib.rs:116
             at /checkout/src/libcore/option.rs:414
             at librustdoc/lib.rs:116
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /checkout/src/libsyntax/lib.rs:100
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  36: syntax::with_globals
             at /checkout/src/libsyntax/lib.rs:99
  37: std::panicking::try::do_call
             at /checkout/src/libstd/thread/mod.rs:409
             at /checkout/src/libstd/panic.rs:313
             at /checkout/src/libstd/panicking.rs:310
  38: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:106
  39: <F as alloc::boxed::FnBox<A>>::call_box
             at /checkout/src/libstd/panicking.rs:289
             at /checkout/src/libstd/panic.rs:392
             at /checkout/src/libstd/thread/mod.rs:408
             at /checkout/src/liballoc/boxed.rs:640
  40: std::sys_common::thread::start_thread
             at /checkout/src/liballoc/boxed.rs:650
             at libstd/sys_common/thread.rs:24
  41: std::sys::unix::thread::Thread::new::thread_start
             at libstd/sys/unix/thread.rs:90
  42: start_thread
  43: clone

Description

Basically, crate-type = ["proc-macro"] is a thing that mostly appears to work, even though all documentation says to use proc-macro = true. However, using it causes issues when documenting downstream crates, most notably the above.

See also rust-lang/cargo#5310.

@ExpHP ExpHP changed the title 'crate-type = ["proc-macro"]' causes 'ICE: proc-macro crate not dylib' when documenting downstream crates 'crate-type = ["proc-macro"]' causes 'error: proc-macro crate not dylib' and ICE when documenting downstream crates Jul 22, 2018
@memoryruins memoryruins added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 11, 2018
@real-felix
Copy link

Thanks for your tip, I replaced the following line:

crate_type = ["proc-macro"]

with

proc-macro = true

and now I can generate the documentation without ICE.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2019
@bjorn3
Copy link
Member

bjorn3 commented May 16, 2022

Fixed by rust-lang/cargo#6256

@bjorn3 bjorn3 closed this as completed May 16, 2022
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

5 participants