Skip to content

CTFE mir is sufficient for statics and consts #85430

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

Closed
wants to merge 1 commit into from

Conversation

jsgf
Copy link
Contributor

@jsgf jsgf commented May 18, 2021

The issue isn't that the MIR is missing, but that it's for CTFE, so extend the check for that as well.

Closes issue #85401

@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 18, 2021
@tmiasko
Copy link
Contributor

tmiasko commented May 18, 2021

With proposed change statics from another crate will be codegened locally, i.e., duplicated each time they are referenced from another crate.

Under normal circumstances the issue never arise because is_reachable_non_generic(def_id) is true for statics, and should_codegen_locally returns false earlier.

@jsgf
Copy link
Contributor Author

jsgf commented May 18, 2021

@tmiasko I see. Would doing something like

if tcx.is_ctfe_mir_available(def_id) {
    return false;
}

be better then?

My goal here is to make running separate rustc --emit metadata -Zalways-encode-mir=yes/rustc --emit link commands equivalent to the cargo pipelined build invocation of rustc --emit link,metadata - that is, so that the .rmetas can be used as inputs to downstream dependent builds.

@tmiasko
Copy link
Contributor

tmiasko commented May 18, 2021

I suspect that anything short of computing reachable_non_generics when building the metadata crate will run into trouble. Without this information all functions will be generated locally.

@jsgf
Copy link
Contributor Author

jsgf commented May 19, 2021

@tmiasko That must be what --emit metadata,link must doing then, yes?

@tmiasko
Copy link
Contributor

tmiasko commented May 19, 2021

That must be what --emit metadata,link must doing then, yes?

There are two implementation of reachable_non_generics. One for the local crate that actually computes it and the second one for non-local crates that merely decodes what had been computed by the other. Consequently the content for non-local crates will be reflection of compilation flags used when the metadata had been emitted.

The --emit metadata,link will include reachable_non_generics for that crate, --emit metadata will omit it.

@RalfJung
Copy link
Member

Cc @oli-obk who wrote the code that is being modified here.

@jsgf
Copy link
Contributor Author

jsgf commented May 28, 2021

Closing in favour of #85793

@jsgf jsgf closed this May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants