diff options
| author | bors <bors@rust-lang.org> | 2024-11-27 10:19:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-27 10:19:38 +0000 |
| commit | 39cb3386ddc6c71657418be28dbb3987eea4aa4b (patch) | |
| tree | d9dc869bd9dc664d264a9585d1e247fe07ae99ce /compiler/rustc_metadata/src | |
| parent | 5f8a2405a6a7ea0ff85072b3bf90f4cff1144e85 (diff) | |
| parent | 6798ecaf1000c223378151023b8eb37f3464af29 (diff) | |
Auto merge of #133369 - Zalathar:profiler-builtins-no-core, r=jieyouxu
Allow injecting a profiler runtime into `#![no_core]` crates An alternative to #133300, allowing `-Cinstrument-coverage` to be used with `-Zbuild-std`. The incompatibility between `profiler_builtins` and `#![no_core]` crates appears to have been caused by profiler_builtins depending on core, and therefore conflicting with core (or minicore). But that's a false dependency, because the profiler doesn't contain any actual Rust code. So we can just mark the profiler itself as `#![no_core]`, and remove the incompatibility error. --- For context, the error was originally added by #79958.
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/creader.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/errors.rs | 4 |
2 files changed, 5 insertions, 13 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 007d9265165..a18c6baec00 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -799,20 +799,16 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { self.inject_dependency_if(cnum, "a panic runtime", &|data| data.needs_panic_runtime()); } - fn inject_profiler_runtime(&mut self, krate: &ast::Crate) { - if self.sess.opts.unstable_opts.no_profiler_runtime - || !(self.sess.instrument_coverage() || self.sess.opts.cg.profile_generate.enabled()) - { + fn inject_profiler_runtime(&mut self) { + let needs_profiler_runtime = + self.sess.instrument_coverage() || self.sess.opts.cg.profile_generate.enabled(); + if !needs_profiler_runtime || self.sess.opts.unstable_opts.no_profiler_runtime { return; } info!("loading profiler"); let name = Symbol::intern(&self.sess.opts.unstable_opts.profiler_runtime); - if name == sym::profiler_builtins && attr::contains_name(&krate.attrs, sym::no_core) { - self.dcx().emit_err(errors::ProfilerBuiltinsNeedsCore); - } - let Some(cnum) = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit) else { return; }; @@ -1046,7 +1042,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { pub fn postprocess(&mut self, krate: &ast::Crate) { self.inject_forced_externs(); - self.inject_profiler_runtime(krate); + self.inject_profiler_runtime(); self.inject_allocator_crate(krate); self.inject_panic_runtime(krate); diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 16684ae6f26..b6c5619ec18 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -340,10 +340,6 @@ pub struct NoPanicStrategy { } #[derive(Diagnostic)] -#[diag(metadata_profiler_builtins_needs_core)] -pub struct ProfilerBuiltinsNeedsCore; - -#[derive(Diagnostic)] #[diag(metadata_not_profiler_runtime)] pub struct NotProfilerRuntime { pub crate_name: Symbol, |
