Skip to content

creader: Host crate loaded twice produces different CrateNums if host != target #56935

Closed

Description

Reproduction (as an UI test):

// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro]
pub fn mac(input: TokenStream) -> TokenStream {
    input
}
// edition:2018
// compile-flags:--extern reproduction
// aux-build:reproduction.rs

reproduction::mac!();

fn main() {}
# Assuming x86_64-unknown-linux-gnu host
./x.py test --bless --stage 1 --target i686-unknown-linux-gnu src/test/ui --test-args reproduction

Name resolution will try to load the crate twice, first in initial pass, then in validation pass.
The results will be different due to different loaded CrateNums, so we get the "inconsistent resolution for a macro" assertion.

This happens due to the locate_ctxt.triple == &self.sess.opts.target_triple condition in CrateLoader::load preventing reuse of CrateNums for host crates during cross-compilation.

cc @alexcrichton probably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-crossArea: Cross compilationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-metadataArea: Crate metadataA-resolveArea: Name resolutionC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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