Skip to content

Access to compiler artifact notifications messages #13672

Open
@pacak

Description

@pacak

Problem

You can pass --json=artifacts to rustc and it will emit json messages like {"$message_type":"artifact","artifact":"/path/to/target/release/deps/libsample-fb5d74408737397e.rlib","emit":"link"} to stderr.

cargo then parses them and mostly ignores:

if let Ok(artifact) = serde_json::from_str::<ArtifactNotification>(compiler_message.get()) {
trace!("found directive from rustc: `{}`", artifact.artifact);
if artifact.artifact.ends_with(".rmeta") {
debug!("looks like metadata finished early!");
state.rmeta_produced();
}
return Ok(false);
}

later emitting its own version:

destinations.push(src.clone());

I'm extending --json=artifacts in rustc to include files produced by --emit (rust-lang/rust#122597) to avoid doing fragile guesswork in cargo-show-asm, but right now this information won't be accessible when rustc is invoked via cargo.

Proposed Solution

cargo should collect this information when present and output it as part of its own notifications, including cases where rustc wasn't actually invoked if source files staid the same.

Notes

The alternative is for me to invoke rustc directly - fragile or to do nothing - currently I have to pass codegen-units=1 - potentially confusing behavior.

If approved - I can look into implementing required change myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-json-outputArea: JSON message outputC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-rustcS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions