Difference in .rmeta file generation between rustc commands with --emit=dep-info,metadata,link and split commands with separate --emit options

I have encountered a discrepancy in the generated .rmeta file when comparing the rustc command with --emit=dep-info,metadata,link and splitting the command into two separate subcommands. In the original command generated by Cargo, the combination of --emit options produces a .d file, a .rmeta file, and a .rlib file. However, when I split the command into two subcommands, with the first emitting dep-info and metadata, and the second emitting link, I noticed that the resulting .rmeta file from the first subcommand is different from the one generated by the original command.

I am curious to understand the reason behind this difference and the potential implications it may have. Additionally, when another crate depends on the .rmeta file using --extern, I encountered an error when compiling the crate. The error message states that there is no MIR (Mid-level Intermediate Representation) available for a specific DefId. This issue seems to occur only when using the .rmeta file generated by the split command.

I would appreciate any insights or explanations regarding the discrepancy in .rmeta file generation between the original command and the split command, as well as any suggestions or potential solutions to address the error when using the split command with --extern dependency.

Without --emit link rustc will omit MIR for all inline and generic functions in the crate metadata to improve performance of cargo check. Note that mixing artifacts from different rustc invocations is not allowed even when using the same source.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.