Skip to content

error[E0433]: failed to resolve: unresolved import for libc crate #72263

@bjorn3

Description

@bjorn3

I tried this code:

[package]
authors = ["bjorn3 <[email protected]>"]
name = "sysroot"
version = "0.0.0"

[dependencies]
core = { path = "./sysroot_src/src/libcore" }
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/src/liballoc" }
std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind", "backtrace"] }

[patch.crates-io]
rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" }
rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" }

[profile.release]
debug = true
Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "alloc"
version = "0.0.0"
dependencies = [
 "compiler_builtins",
 "core",
]

[[package]]
name = "autocfg"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"

[[package]]
name = "backtrace"
version = "0.3.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130"
dependencies = [
 "backtrace-sys",
 "cfg-if",
 "compiler_builtins",
 "libc",
 "rustc-demangle",
 "rustc-std-workspace-core",
]

[[package]]
name = "backtrace-sys"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399"
dependencies = [
 "cc",
 "compiler_builtins",
 "libc",
 "rustc-std-workspace-core",
]

[[package]]
name = "cc"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "404b1fe4f65288577753b17e3b36a04596ee784493ec249bf81c7f2d2acd751c"

[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
dependencies = [
 "compiler_builtins",
 "rustc-std-workspace-core",
]

[[package]]
name = "compiler_builtins"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439a6fab343b1dab347823537734a5cd4ae6ae2000b465ab886f64cdb723bd14"
dependencies = [
 "rustc-std-workspace-core",
]

[[package]]
name = "core"
version = "0.0.0"

[[package]]
name = "dlmalloc"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f283302e035e61c23f2b86b3093e8c6273a4c3125742d6087e96ade001ca5e63"
dependencies = [
 "compiler_builtins",
 "libc",
 "rustc-std-workspace-core",
]

[[package]]
name = "fortanix-sgx-abi"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c56c422ef86062869b2d57ae87270608dc5929969dd130a6e248979cf4fb6ca6"
dependencies = [
 "compiler_builtins",
 "rustc-std-workspace-core",
]

[[package]]
name = "hashbrown"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead"
dependencies = [
 "autocfg",
 "compiler_builtins",
 "rustc-std-workspace-alloc",
 "rustc-std-workspace-core",
]

[[package]]
name = "hermit-abi"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
dependencies = [
 "compiler_builtins",
 "libc",
 "rustc-std-workspace-core",
]

[[package]]
name = "libc"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f"
dependencies = [
 "rustc-std-workspace-core",
]

[[package]]
name = "panic_abort"
version = "0.0.0"
dependencies = [
 "compiler_builtins",
 "core",
 "libc",
]

[[package]]
name = "panic_unwind"
version = "0.0.0"
dependencies = [
 "alloc",
 "cfg-if",
 "compiler_builtins",
 "core",
 "libc",
 "unwind",
]

[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
dependencies = [
 "compiler_builtins",
 "rustc-std-workspace-core",
]

[[package]]
name = "rustc-std-workspace-alloc"
version = "1.99.0"
dependencies = [
 "alloc",
]

[[package]]
name = "rustc-std-workspace-core"
version = "1.99.0"
dependencies = [
 "core",
]

[[package]]
name = "std"
version = "0.0.0"
dependencies = [
 "alloc",
 "backtrace",
 "cfg-if",
 "compiler_builtins",
 "core",
 "dlmalloc",
 "fortanix-sgx-abi",
 "hashbrown",
 "hermit-abi",
 "libc",
 "panic_abort",
 "panic_unwind",
 "unwind",
 "wasi",
]

[[package]]
name = "sysroot"
version = "0.0.0"
dependencies = [
 "alloc",
 "compiler_builtins",
 "core",
 "std",
]

[[package]]
name = "unwind"
version = "0.0.0"
dependencies = [
 "cc",
 "cfg-if",
 "compiler_builtins",
 "core",
 "libc",
]

[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
dependencies = [
 "compiler_builtins",
 "rustc-std-workspace-alloc",
 "rustc-std-workspace-core",
]

./sysroot_src contains an unpatched copy of the rust-src component.

I expected to see this happen: Compile fine
Instead, this happened: error[E0433]: failed to resolve: unresolved import

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (ed084b0b8 2020-05-15)
binary: rustc
commit-hash: ed084b0b8341c974769a0328f61851b0e1fc17fa
commit-date: 2020-05-15
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0
Backtrace

error[E0433]: failed to resolve: unresolved import

thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', src/librustc_errors/lib.rs:933:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::emit_diagnostic
  14: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  15: <rustc_resolve::Resolver as rustc_ast_lowering::Resolver>::resolve_str_path
  16: rustc_ast_lowering::LoweringContext::std_path
  17: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_range
  18: rustc_data_structures::stack::ensure_sufficient_stack
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  21: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_for
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_ast_lowering::LoweringContext::lower_stmt
  26: rustc_ast_lowering::LoweringContext::lower_block_noalloc
  27: rustc_ast_lowering::LoweringContext::lower_block_expr
  28: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_fn_body_block
  29: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item
  30: rustc_ast_lowering::LoweringContext::with_hir_id_owner
  31: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  32: rustc_ast::visit::walk_item
  33: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  34: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  35: rustc_ast::visit::walk_item
  36: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  37: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  38: rustc_ast::visit::walk_item
  39: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  40: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  41: rustc_ast::visit::walk_crate
  42: rustc_ast_lowering::lower_crate
  43: rustc_interface::passes::BoxedResolver::access::{{closure}}
  44: rustc_interface::passes::configure_and_expand::{{closure}}
  45: rustc_interface::passes::BoxedResolver::access
  46: rustc_interface::queries::Queries::lower_to_hir
  47: rustc_interface::queries::Queries::global_ctxt
  48: rustc_interface::interface::run_compiler_in_existing_thread_pool
  49: scoped_tls::ScopedKey<T>::set
  50: rustc_ast::attr::with_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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (ed084b0b8 2020-05-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z panic-abort-tests -Z codegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Z force-unstable-if-unmarked -Z treat-err-as-bug=1 -C embed-bitcode=no -C debuginfo=2 -C panic=abort -C debuginfo=2 --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 `libc`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions