Skip to content

Extend --print requests with output format suffixes - #165817

Open
malezjaa wants to merge 4 commits into
rust-lang:mainfrom
malezjaa:print-output-format
Open

malezjaa wants to merge 4 commits into
rust-lang:mainfrom
malezjaa:print-output-format

Conversation

@malezjaa

@malezjaa malezjaa commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

MCP: rust-lang/compiler-team#860
Tracking issue: #165816

I think the implementation is pretty straightforward: CodegenBackend trait now has target_cpus and target_features instead of print. I hope that these two methods make sense for every backend not just LLVM. I moved print_crate_info to a sepearte file and it also now handles printing for generic stuff like code models, relocation models etc, instead of it being in LLVM backend. I know that the handling of printing might look a bit "ad-hoc" for native-static-libs and link-args, but I don't think there would be any other useful output format besides json and the default one, so I didn't try to abstract it.

This is still missing documentation/reference update, multiple print requests (and possibly more), but just wanted to open a pr for initial review.

r? @bjorn3
cc @jieyouxu @Urgau

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2026
writeln!(out, " Target features listing is not supported by this LLVM version.")
.unwrap();
TargetFeaturesInfo {
rustc_features: rustc_target_features,

@bjorn3 bjorn3 Nov 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect the rustc features list to be handled in a backend independent way.

View changes since the review

}

fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
fn target_cpus(&self, _sess: &Session) -> Vec<TargetCpuInfo> {

@bjorn3 bjorn3 Nov 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is confusable with the target_cpu method (the actually selected target cpu). Please remove either or both to indicate their role.

View changes since the review

@bjorn3 bjorn3 Nov 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move the extracting print_crate_info into crate_info.rs to a separate commit?

View changes since the review

pub kind: PrintKind,
pub out: OutFileName,
pub arg: Option<String>,
pub format: PrintOutputFormat

@bjorn3 bjorn3 Nov 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make sure each commit is formatted to avoid unrelated formatting changes in other commits?

View changes since the review

@rust-bors

rust-bors Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #165918) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants