rust-lang / rust-lang/rust

Cannot cross-compile with rustc-dev package (or with any pre-built rlib files that depend on proc-macros, really)

Open
#143,226 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-discussion
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Attempting to cross-compile something that depends on rustc-dev crates does not work. Even after installing rustc-dev for both the host and the target, the result is >1000 errors, the first ones being:

error[E0463]: can't find crate for `tracing_attributes` which `tracing` depends on
  --> src/lib.rs:53:1
   |
53 | extern crate tracing;
   | ^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `rustc_macros` which `rustc_abi` depends on
  --> src/lib.rs:56:1
   |
56 | extern crate rustc_abi;
   | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `derive_where` which `rustc_ast` depends on
  --> src/lib.rs:58:1
   |
58 | extern crate rustc_ast;
   | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `rustc_abi`
  --> src/lib.rs:59:1
   |
59 | extern crate rustc_attr_data_structures;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

@bjorn3 said:

Yeah, you can't cross-compile projects that use rustc_driver outside of bootstrap. The rustc-dev component only contains proc-macros for the target, while rustc needs them available for the host too.

However, that's why I installed the rustc-dev component both both the current host and the target. Somehow, that's still not enough, and I don't understand why. Does the rustc sysroot not have a concept of "crates for the current target" vs "crates for the host"?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the cross-compilation failure with rustc-dev installed for both the host and target, focusing on rustc_driver and the reported missing proc-macro crates. Read the rustc sysroot and bootstrap behavior described in the issue; done means identifying why host proc-macros are not resolved and determining a fix or documenting the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.