Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2d47816
rustc_llvm: Add a `-Z print-llvm-stats` option to expose LLVM statist…
pcwalton Nov 5, 2022
138f522
Don't enable by default :)
pcwalton Nov 5, 2022
4d307c4
print on rustc_codegen_llvm and rename malloc and cpy c_char
khei4 Jul 16, 2023
b1398ca
Make {Rc,Arc}::allocator associated functions
glandium Jul 18, 2023
c7bf20d
address feedback from nikic and oli-obk https://github.com/rust-lang/…
khei4 Jul 19, 2023
11dcd1d
Add test of --print KIND=PATH
dtolnay Apr 25, 2023
c0dc0c6
Store individual output file name with every PrintRequest
dtolnay Jul 17, 2023
f72bdb1
Parse --print KIND=PATH command line syntax
dtolnay Jul 17, 2023
32cac2e
Disallow overlapping prints to the same location
dtolnay Jul 17, 2023
f2e3d3f
Move OutFileName writing into rustc_session
dtolnay Jul 17, 2023
5a60660
Implement printing to file in print_crate_info
dtolnay Jul 17, 2023
c80cbe4
Implement printing to file in codegen_backend.print
dtolnay Jul 17, 2023
6e734fc
Implement printing to file in llvm_util
dtolnay Jul 13, 2023
815a114
Implement printing to file in PassWrapper
dtolnay Jul 13, 2023
dcfe94a
Implement printing to file for link-args and native-static-libs
dtolnay Jul 17, 2023
7ee059b
Add ui test of LLVM print-from-C++ changes
dtolnay Jul 14, 2023
5ca0946
Document --print KIND=PATH in Command-line Arguments documentation
dtolnay Jul 17, 2023
26fd6b1
Add note about writing native-static-libs to file
dtolnay Jul 19, 2023
11ae0af
Create separate match arms for FileNames and CrateNames
dtolnay Jul 19, 2023
40e1164
Minor improvements to Windows TLS dtors
ChrisDenton Jul 20, 2023
715efa4
style-guide: Remove material about tool configurability
joshtriplett Jun 28, 2023
cf4b20d
style-guide: Fix typo: s/forth/fourth/g
joshtriplett Jun 29, 2023
615b58b
style-guide: Fix an example to match the style
joshtriplett Jul 3, 2023
081e15a
style-guide: Simplify the structure of a recommendation (no semantic …
joshtriplett Jul 3, 2023
ce5aca9
style-guide: Avoid using "should" or "may" for required parts of the …
joshtriplett Jun 28, 2023
9ccc104
style-guide: Add an additional chaining example
joshtriplett Jul 5, 2023
69d29a7
style-guide: Fix typo: s/right-hand side/left-hand side/
joshtriplett Jul 5, 2023
144e8a3
style-guide: Fix example to match the rule it exemplifies (and match …
joshtriplett Jul 5, 2023
77d09cb
Clarify wording on breaking arrays across lines
joshtriplett Jul 20, 2023
20ce7f1
Rollup merge of #113380 - joshtriplett:style-guide-cleanup-must-shoul…
matthiaskrgr Jul 21, 2023
2734b5a
Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikic
matthiaskrgr Jul 21, 2023
b1d1e99
Rollup merge of #113780 - dtolnay:printkindpath, r=b-naber
matthiaskrgr Jul 21, 2023
5ac3684
Rollup merge of #113810 - glandium:allocator-fn, r=Amanieu
matthiaskrgr Jul 21, 2023
8c6ef1d
Rollup merge of #113907 - ChrisDenton:tls, r=thomcc
matthiaskrgr Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement printing to file in codegen_backend.print
  • Loading branch information
dtolnay committed Jul 20, 2023
commit c80cbe4baedfe1ef8ea6f88f3cf2f8db06c8c399
23 changes: 12 additions & 11 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ impl CodegenBackend for LlvmCodegenBackend {
|tcx, ()| llvm_util::global_llvm_features(tcx.sess, true)
}

fn print(&self, req: &PrintRequest, sess: &Session) {
fn print(&self, req: &PrintRequest, out: &mut dyn PrintBackendInfo, sess: &Session) {
match req.kind {
PrintKind::RelocationModels => {
println!("Available relocation models:");
writeln!(out, "Available relocation models:");
for name in &[
"static",
"pic",
Expand All @@ -276,26 +276,27 @@ impl CodegenBackend for LlvmCodegenBackend {
"ropi-rwpi",
"default",
] {
println!(" {}", name);
writeln!(out, " {}", name);
}
println!();
writeln!(out);
}
PrintKind::CodeModels => {
println!("Available code models:");
writeln!(out, "Available code models:");
for name in &["tiny", "small", "kernel", "medium", "large"] {
println!(" {}", name);
writeln!(out, " {}", name);
}
println!();
writeln!(out);
}
PrintKind::TlsModels => {
println!("Available TLS models:");
writeln!(out, "Available TLS models:");
for name in &["global-dynamic", "local-dynamic", "initial-exec", "local-exec"] {
println!(" {}", name);
writeln!(out, " {}", name);
}
println!();
writeln!(out);
}
PrintKind::StackProtectorStrategies => {
println!(
writeln!(
out,
r#"Available stack protector strategies:
all
Generate stack canaries in all functions.
Expand Down
20 changes: 19 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use rustc_span::symbol::Symbol;
use rustc_target::abi::call::FnAbi;
use rustc_target::spec::Target;

use std::fmt;

pub trait BackendTypes {
type Value: CodegenObject;
type Function: CodegenObject;
Expand Down Expand Up @@ -61,7 +63,7 @@ pub trait CodegenBackend {
fn locale_resource(&self) -> &'static str;

fn init(&self, _sess: &Session) {}
fn print(&self, _req: &PrintRequest, _sess: &Session) {}
fn print(&self, _req: &PrintRequest, _out: &mut dyn PrintBackendInfo, _sess: &Session) {}
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
vec![]
}
Expand Down Expand Up @@ -162,3 +164,19 @@ pub trait ExtraBackendMethods:
std::thread::Builder::new().name(name).spawn(f)
}
}

pub trait PrintBackendInfo {
fn infallible_write_fmt(&mut self, args: fmt::Arguments<'_>);
}

impl PrintBackendInfo for String {
fn infallible_write_fmt(&mut self, args: fmt::Arguments<'_>) {
fmt::Write::write_fmt(self, args).unwrap();
}
}

impl dyn PrintBackendInfo + '_ {
pub fn write_fmt(&mut self, args: fmt::Arguments<'_>) {
self.infallible_write_fmt(args);
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod write;

pub use self::abi::AbiBuilderMethods;
pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods};
pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods, PrintBackendInfo};
pub use self::builder::{BuilderMethods, OverflowOp};
pub use self::consts::ConstMethods;
pub use self::coverageinfo::CoverageInfoBuilderMethods;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ fn print_crate_info(
| TargetCPUs
| StackProtectorStrategies
| TargetFeatures => {
codegen_backend.print(req, sess);
codegen_backend.print(req, &mut crate_info, sess);
}
// Any output here interferes with Cargo's parsing of other printed output
NativeStaticLibs => {}
Expand Down