diff --git a/compiler/rustc_codegen_llvm/src/back/command_line_args.rs b/compiler/rustc_codegen_llvm/src/back/command_line_args.rs deleted file mode 100644 index b14713969b34c..0000000000000 --- a/compiler/rustc_codegen_llvm/src/back/command_line_args.rs +++ /dev/null @@ -1,37 +0,0 @@ -#[cfg(test)] -mod tests; - -/// Joins command-line arguments into a single space-separated string, quoting -/// and escaping individual arguments as necessary. -/// -/// The result is intended to be informational, for embedding in debug metadata, -/// and might not be properly quoted/escaped for actual command-line use. -pub(crate) fn quote_command_line_args(args: &[String]) -> String { - // Start with a decent-sized buffer, since rustc invocations tend to be long. - let mut buf = String::with_capacity(128); - - for arg in args { - if !buf.is_empty() { - buf.push(' '); - } - - print_arg_quoted(&mut buf, arg); - } - - buf -} - -/// Equivalent to LLVM's `sys::printArg` with quoting always enabled -/// (see llvm/lib/Support/Program.cpp). -fn print_arg_quoted(buf: &mut String, arg: &str) { - buf.reserve(arg.len() + 2); - - buf.push('"'); - for ch in arg.chars() { - if matches!(ch, '"' | '\\' | '$') { - buf.push('\\'); - } - buf.push(ch); - } - buf.push('"'); -} diff --git a/compiler/rustc_codegen_llvm/src/back/command_line_args/tests.rs b/compiler/rustc_codegen_llvm/src/back/command_line_args/tests.rs deleted file mode 100644 index 69641fed3bc92..0000000000000 --- a/compiler/rustc_codegen_llvm/src/back/command_line_args/tests.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[test] -fn quote_command_line_args() { - use super::quote_command_line_args; - - struct Case<'a> { - args: &'a [&'a str], - expected: &'a str, - } - - let cases = &[ - Case { args: &[], expected: "" }, - Case { args: &["--hello", "world"], expected: r#""--hello" "world""# }, - Case { args: &["--hello world"], expected: r#""--hello world""# }, - Case { - args: &["plain", "$dollar", "spa ce", r"back\slash", r#""quote""#, "plain"], - expected: r#""plain" "\$dollar" "spa ce" "back\\slash" "\"quote\"" "plain""#, - }, - ]; - - for &Case { args, expected } in cases { - let args = args.iter().copied().map(str::to_owned).collect::>(); - let actual = quote_command_line_args(&args); - assert_eq!(actual, expected, "args {args:?}"); - } -} diff --git a/compiler/rustc_codegen_llvm/src/back/mod.rs b/compiler/rustc_codegen_llvm/src/back/mod.rs index fe3883e8c73e6..6cb89f80ab89a 100644 --- a/compiler/rustc_codegen_llvm/src/back/mod.rs +++ b/compiler/rustc_codegen_llvm/src/back/mod.rs @@ -1,5 +1,4 @@ pub(crate) mod archive; -mod command_line_args; pub(crate) mod lto; pub(crate) mod owned_target_machine; mod profiling; diff --git a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs index d5228f0e0dee1..24c21e19cc539 100644 --- a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs +++ b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs @@ -38,8 +38,6 @@ impl OwnedTargetMachine { output_obj_file: &CStr, debug_info_compression: &CStr, use_emulated_tls: bool, - argv0: &str, - command_line_args: &str, use_wasm_eh: bool, ) -> Result> { // SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed to data @@ -66,10 +64,6 @@ impl OwnedTargetMachine { output_obj_file.as_ptr(), debug_info_compression.as_ptr(), use_emulated_tls, - argv0.as_ptr(), - argv0.len(), - command_line_args.as_ptr(), - command_line_args.len(), use_wasm_eh, ) }; diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 1950b8288d149..23972f5ed66e0 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -31,7 +31,6 @@ use rustc_span::{BytePos, InnerSpan, Pos, SpanData, SyntaxContext, sym}; use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use tracing::{debug, trace}; -use crate::back::command_line_args::quote_command_line_args; use crate::back::lto::ThinBuffer; use crate::back::owned_target_machine::OwnedTargetMachine; use crate::back::profiling::{ @@ -253,19 +252,6 @@ pub(crate) fn target_machine_factory( let use_emulated_tls = matches!(sess.tls_model(), TlsModel::Emulated); - // Command-line information to be included in the target machine. - // This seems to only be used for embedding in PDB debuginfo files. - // FIXME(Zalathar): Maybe skip this for non-PDB targets? - let argv0 = std::env::current_exe() - .unwrap_or_default() - .into_os_string() - .into_string() - .unwrap_or_default(); - let command_line_args = quote_command_line_args(&sess.expanded_args); - // Self-profile counter for the number of bytes produced by command-line quoting. - // Values are summed, so the summary result is cumulative across all TM factories. - sess.prof.artifact_size("quoted_command_line_args", "-", command_line_args.len() as u64); - let debuginfo_compression = sess.opts.debuginfo_compression.to_string(); match sess.opts.debuginfo_compression { rustc_session::config::DebugInfoCompression::Zlib => { @@ -326,8 +312,6 @@ pub(crate) fn target_machine_factory( &output_obj_file, &debuginfo_compression, use_emulated_tls, - &argv0, - &command_line_args, use_wasm_eh, ) }) diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index fd972f371df49..d88f5a0585bbf 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2492,10 +2492,6 @@ unsafe extern "C" { OutputObjFile: *const c_char, DebugInfoCompression: *const c_char, UseEmulatedTls: bool, - Argv0: *const c_uchar, // See "PTR_LEN_STR". - Argv0Len: size_t, - CommandLineArgs: *const c_uchar, // See "PTR_LEN_STR". - CommandLineArgsLen: size_t, UseWasmEH: bool, ) -> *mut TargetMachine; diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index cbaf67d734547..54a156ec1039e 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -346,12 +346,6 @@ pub struct CodegenContext { pub split_dwarf_kind: rustc_session::config::SplitDwarfKind, pub pointer_size: Size, - /// All commandline args used to invoke the compiler, with @file args fully expanded. - /// This will only be used within debug info, e.g. in the pdb file on windows - /// This is mainly useful for other tools that reads that debuginfo to figure out - /// how to call the compiler with the same arguments. - pub expanded_args: Vec, - /// Emitter to use for diagnostics produced during codegen. pub diag_emitter: SharedEmitter, /// LLVM optimizations for which we want to print remarks. @@ -1153,7 +1147,6 @@ fn start_executing_work( remark: sess.opts.cg.remark.clone(), remark_dir, incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()), - expanded_args: tcx.sess.expanded_args.clone(), diag_emitter: shared_emitter.clone(), output_filenames: Arc::clone(tcx.output_filenames(())), module_config: regular_config, diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 8dab520cf36b9..f88bf58130b7a 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -269,7 +269,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send)) make_codegen_backend: None, registry: diagnostics_registry(), using_internal_features: &USING_INTERNAL_FEATURES, - expanded_args: args, }; callbacks.config(&mut config); diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index b52c5b4cd663b..bc4e4127c8eda 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -376,12 +376,6 @@ pub struct Config { /// enabled. Makes it so that "please report a bug" is hidden, as ICEs with /// internal features are wontfix, and they are usually the cause of the ICEs. pub using_internal_features: &'static std::sync::atomic::AtomicBool, - - /// All commandline args used to invoke the compiler, with @file args fully expanded. - /// This will only be used within debug info, e.g. in the pdb file on windows - /// This is mainly useful for other tools that reads that debuginfo to figure out - /// how to call the compiler with the same arguments. - pub expanded_args: Vec, } /// Initialize jobserver before getting `jobserver::client` and `build_session`. @@ -480,7 +474,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se util::rustc_version_str().unwrap_or("unknown"), config.ice_file, config.using_internal_features, - config.expanded_args, ); codegen_backend.init(&sess); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 7730bddc0f12d..a74030c6d3c34 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -78,7 +78,6 @@ where "", None, &USING_INTERNAL_FEATURES, - Default::default(), ); let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg")); let cfg = build_configuration(&sess, cfg); diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 7518b40799bc1..c8abdbc03d5c4 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -271,9 +271,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( bool TrapUnreachable, bool Singlethread, bool VerboseAsm, bool EmitStackSizeSection, bool RelaxELFRelocations, bool UseInitArray, const char *SplitDwarfFile, const char *OutputObjFile, - const char *DebugInfoCompression, bool UseEmulatedTls, const char *Argv0, - size_t Argv0Len, const char *CommandLineArgs, size_t CommandLineArgsLen, - bool UseWasmEH) { + const char *DebugInfoCompression, bool UseEmulatedTls, bool UseWasmEH) { auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc); @@ -344,11 +342,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( Options.EmitStackSizeSection = EmitStackSizeSection; - if (Argv0 != nullptr) - Options.MCOptions.Argv0 = {Argv0, Argv0Len}; - if (CommandLineArgs != nullptr) - Options.MCOptions.CommandlineArgs = {CommandLineArgs, CommandLineArgsLen}; - #if LLVM_VERSION_GE(21, 0) TargetMachine *TM = TheTarget->createTargetMachine(Trip, CPU, Feature, Options, RM, CM, OptLevel); diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 25b46241c52df..999c1e240fc86 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -148,12 +148,6 @@ pub struct Session { /// None signifies that this is not tracked. pub using_internal_features: &'static AtomicBool, - /// All commandline args used to invoke the compiler, with @file args fully expanded. - /// This will only be used within debug info, e.g. in the pdb file on windows - /// This is mainly useful for other tools that reads that debuginfo to figure out - /// how to call the compiler with the same arguments. - pub expanded_args: Vec, - target_filesearch: FileSearch, host_filesearch: FileSearch, @@ -1015,7 +1009,6 @@ pub fn build_session( cfg_version: &'static str, ice_file: Option, using_internal_features: &'static AtomicBool, - expanded_args: Vec, ) -> Session { // FIXME: This is not general enough to make the warning lint completely override // normal diagnostic warnings, since the warning lint can also be denied and changed @@ -1132,7 +1125,6 @@ pub fn build_session( unstable_target_features: Default::default(), cfg_version, using_internal_features, - expanded_args, target_filesearch, host_filesearch, invocation_temp, diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index d7f6fa347becb..fada93e1f8304 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -165,12 +165,6 @@ pub(crate) struct Options { /// to have it in both places. pub(crate) unstable_features: rustc_feature::UnstableFeatures, - /// All commandline args used to invoke the compiler, with @file args fully expanded. - /// This will only be used within debug info, e.g. in the pdb file on windows - /// This is mainly useful for other tools that reads that debuginfo to figure out - /// how to call the compiler with the same arguments. - pub(crate) expanded_args: Vec, - /// Arguments to be used when compiling doctests. pub(crate) doctest_build_args: Vec, @@ -870,7 +864,6 @@ impl Options { json_unused_externs, scrape_examples_options, unstable_features, - expanded_args: args, doctest_build_args, target_modifiers, }; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index b8aaafcb517a9..ecafd7e7d103c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -213,7 +213,6 @@ pub(crate) fn create_config( describe_lints, lint_cap, scrape_examples_options, - expanded_args, remap_path_prefix, target_modifiers, .. @@ -326,7 +325,6 @@ pub(crate) fn create_config( registry: rustc_driver::diagnostics_registry(), ice_file: None, using_internal_features: &USING_INTERNAL_FEATURES, - expanded_args, } } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 95bd31729de18..4a4af6f9ba118 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -198,7 +198,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions registry: rustc_driver::diagnostics_registry(), ice_file: None, using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES, - expanded_args: options.expanded_args.clone(), }; let externs = options.externs.clone(); diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/filecheck.txt b/tests/run-make/pdb-buildinfo-cl-cmd/filecheck.txt deleted file mode 100644 index a01999d5bdf76..0000000000000 --- a/tests/run-make/pdb-buildinfo-cl-cmd/filecheck.txt +++ /dev/null @@ -1,4 +0,0 @@ -CHECK: LF_BUILDINFO -CHECK: rustc.exe -CHECK: main.rs -CHECK: "-g" "--crate-name" "my_crate_name" "--crate-type" "bin" "-Cmetadata=dc9ef878b0a48666" diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/main.rs b/tests/run-make/pdb-buildinfo-cl-cmd/main.rs deleted file mode 100644 index f328e4d9d04c3..0000000000000 --- a/tests/run-make/pdb-buildinfo-cl-cmd/main.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs b/tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs deleted file mode 100644 index 9418f4f8d84d3..0000000000000 --- a/tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Check if the pdb file contains the following information in the LF_BUILDINFO: -// 1. full path to the compiler (cl) -// 2. the commandline args to compile it (cmd) -// This is because these used to be missing in #96475. -// See https://github.com/rust-lang/rust/pull/113492 - -//@ only-windows-msvc -// Reason: pdb files are unique to this architecture - -use run_make_support::{llvm, rustc}; - -fn main() { - rustc() - .input("main.rs") - .arg("-g") - .crate_name("my_crate_name") - .crate_type("bin") - .metadata("dc9ef878b0a48666") - .run(); - - let pdbutil_result = - llvm::llvm_pdbutil().arg("dump").arg("-ids").input("my_crate_name.pdb").run(); - - llvm::llvm_filecheck().patterns("filecheck.txt").stdin_buf(pdbutil_result.stdout_utf8()).run(); -}