Skip to content

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

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

malezjaa wants to merge 5 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

@rust-bors

This comment has been minimized.

@malezjaa
malezjaa force-pushed the print-output-format branch from 02c2bc9 to 9e4f8c3 Compare November 14, 2026 18:10
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@malezjaa
malezjaa force-pushed the print-output-format branch from 9e4f8c3 to 6d1644e Compare November 24, 2026 17:09
@rustbot

rustbot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@malezjaa

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rust-log-analyzer

This comment has been minimized.

@malezjaa
malezjaa force-pushed the print-output-format branch from 6d1644e to a976fb8 Compare November 24, 2026 17:47
Comment on lines +26 to +28
use {
crate::do_not_use_safe_print as safe_print, crate::do_not_use_safe_print as safe_println,
};

@bjorn3 bjorn3 Nov 25, 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.

Suggested change
use {
crate::do_not_use_safe_print as safe_print, crate::do_not_use_safe_print as safe_println,
};
use crate::{do_not_use_safe_print as safe_print, do_not_use_safe_print as safe_println};

View changes since the review

let (req, out) = split_out_file_name(&req);

let (kind, arg) = if let Some(mnemonic) = req.strip_prefix("backend-has-mnemonic") {
let (kind, arg, format) = if let Some(rest) = req.strip_prefix("backend-has-mnemonic") {

@bjorn3 bjorn3 Nov 25, 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.

Having the part after : mean different things depending on the print kind is not that nice IMO. Maybe backend-has-mnemonic should use a different syntax like --print backend-has-mnemonic-RET or maybe we should do --print backend-supported-mnemonics that prints whether a fixed set of mnemonics is supported that matches the set compiletest needs to know? What do you think @folkertdev @fneddy

View changes since the review

@rust-bors

rust-bors Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #166567) 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.

4 participants