Skip to content
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

Access to compiler artifact notifications messages #13672

Open
pacak opened this issue Mar 31, 2024 · 2 comments
Open

Access to compiler artifact notifications messages #13672

pacak opened this issue Mar 31, 2024 · 2 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@pacak
Copy link
Contributor

pacak commented Mar 31, 2024

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.

@pacak pacak added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Mar 31, 2024
@pacak
Copy link
Contributor Author

pacak commented Apr 8, 2024

FWIW rust-lang/rust#122597 is implemented and approved, awaiting on FCP to how exactly to get it merged.

@epage
Copy link
Contributor

epage commented Apr 24, 2024

cargo show-asm is calling cargo rustc, passing --emit to rustc to render this information to users. They want to get the json messages for these emitted files so they can look up directly, rather than inferring.

For me, the main question is "why was the filtering done in the first place?"

The code in question was changed in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants