Skip to content

Commit 0fc0614

Browse files
authored
Rollup merge of rust-lang#87756 - Amanieu:no_profiler_runtime, r=jackh726
Add back -Zno-profiler-runtime This was removed by rust-lang#85284 in favor of `-Zprofiler-runtime=<name>`.However the suggested `-Zprofiler-runtime=None` doesn't work because`None` is treated as a crate name.
2 parents bd8858b + 1247f9b commit 0fc0614

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

compiler/rustc_interface/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ fn test_debugging_options_tracking_hash() {
740740
tracked!(new_llvm_pass_manager, Some(true));
741741
tracked!(no_generate_arange_section, true);
742742
tracked!(no_link, true);
743+
tracked!(no_profiler_runtime, true);
743744
tracked!(osx_rpath_install_name, true);
744745
tracked!(panic_abort_tests, true);
745746
tracked!(plt, Some(true));
@@ -748,7 +749,7 @@ fn test_debugging_options_tracking_hash() {
748749
tracked!(print_fuel, Some("abc".to_string()));
749750
tracked!(profile, true);
750751
tracked!(profile_emit, Some(PathBuf::from("abc")));
751-
tracked!(profiler_runtime, None);
752+
tracked!(profiler_runtime, "abc".to_string());
752753
tracked!(relax_elf_relocations, Some(true));
753754
tracked!(relro_level, Some(RelroLevel::Full));
754755
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));

compiler/rustc_metadata/src/creader.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -777,19 +777,17 @@ impl<'a> CrateLoader<'a> {
777777
}
778778

779779
fn inject_profiler_runtime(&mut self, krate: &ast::Crate) {
780-
let profiler_runtime = &self.sess.opts.debugging_opts.profiler_runtime;
781-
782-
if !(profiler_runtime.is_some()
783-
&& (self.sess.instrument_coverage()
780+
if self.sess.opts.debugging_opts.no_profiler_runtime
781+
|| !(self.sess.instrument_coverage()
784782
|| self.sess.opts.debugging_opts.profile
785-
|| self.sess.opts.cg.profile_generate.enabled()))
783+
|| self.sess.opts.cg.profile_generate.enabled())
786784
{
787785
return;
788786
}
789787

790788
info!("loading profiler");
791789

792-
let name = Symbol::intern(profiler_runtime.as_ref().unwrap());
790+
let name = Symbol::intern(&self.sess.opts.debugging_opts.profiler_runtime);
793791
if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) {
794792
self.sess.err(
795793
"`profiler_builtins` crate (required by compiler options) \

compiler/rustc_metadata/src/locator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,8 @@ impl CrateError {
11031103
if sess.is_nightly_build() {
11041104
err.help("consider building the standard library from source with `cargo build -Zbuild-std`");
11051105
}
1106-
} else if Some(crate_name)
1107-
== sess.opts.debugging_opts.profiler_runtime.as_deref().map(Symbol::intern)
1106+
} else if crate_name
1107+
== Symbol::intern(&sess.opts.debugging_opts.profiler_runtime)
11081108
{
11091109
err.note(&"the compiler may have been built without the profiler runtime");
11101110
}

compiler/rustc_session/src/options.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ options! {
11721172
"compile without linking"),
11731173
no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
11741174
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1175+
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1176+
"prevent automatic injection of the profiler_builtins crate"),
11751177
normalize_docs: bool = (false, parse_bool, [TRACKED],
11761178
"normalize associated items in rustdoc when generating documentation"),
11771179
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
@@ -1217,8 +1219,8 @@ options! {
12171219
profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
12181220
"file path to emit profiling data at runtime when using 'profile' \
12191221
(default based on relative source path)"),
1220-
profiler_runtime: Option<String> = (Some(String::from("profiler_builtins")), parse_opt_string, [TRACKED],
1221-
"name of the profiler runtime crate to automatically inject, or None to disable"),
1222+
profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
1223+
"name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
12221224
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
12231225
"enable queries of the dependency graph for regression testing (default: no)"),
12241226
query_stats: bool = (false, parse_bool, [UNTRACKED],

0 commit comments

Comments
 (0)