Skip to content

Commit 972663d

Browse files
committed
Allow injecting a profiler runtime into #![no_core] crates
Now that the profiler runtime is itself `#![no_core]`, it can be a dependency of other no_core crates, including core.
1 parent bba3567 commit 972663d

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

compiler/rustc_metadata/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ metadata_prev_alloc_error_handler =
233233
metadata_prev_global_alloc =
234234
previous global allocator defined here
235235
236-
metadata_profiler_builtins_needs_core =
237-
`profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`
238-
239236
metadata_raw_dylib_no_nul =
240237
link name must not contain NUL characters if link kind is `raw-dylib`
241238

compiler/rustc_metadata/src/creader.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
799799
self.inject_dependency_if(cnum, "a panic runtime", &|data| data.needs_panic_runtime());
800800
}
801801

802-
fn inject_profiler_runtime(&mut self, krate: &ast::Crate) {
802+
fn inject_profiler_runtime(&mut self) {
803803
let needs_profiler_runtime =
804804
self.sess.instrument_coverage() || self.sess.opts.cg.profile_generate.enabled();
805805
if !needs_profiler_runtime || self.sess.opts.unstable_opts.no_profiler_runtime {
@@ -809,10 +809,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
809809
info!("loading profiler");
810810

811811
let name = Symbol::intern(&self.sess.opts.unstable_opts.profiler_runtime);
812-
if name == sym::profiler_builtins && attr::contains_name(&krate.attrs, sym::no_core) {
813-
self.dcx().emit_err(errors::ProfilerBuiltinsNeedsCore);
814-
}
815-
816812
let Some(cnum) = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit) else {
817813
return;
818814
};
@@ -1046,7 +1042,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
10461042

10471043
pub fn postprocess(&mut self, krate: &ast::Crate) {
10481044
self.inject_forced_externs();
1049-
self.inject_profiler_runtime(krate);
1045+
self.inject_profiler_runtime();
10501046
self.inject_allocator_crate(krate);
10511047
self.inject_panic_runtime(krate);
10521048

compiler/rustc_metadata/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,6 @@ pub struct NoPanicStrategy {
339339
pub strategy: PanicStrategy,
340340
}
341341

342-
#[derive(Diagnostic)]
343-
#[diag(metadata_profiler_builtins_needs_core)]
344-
pub struct ProfilerBuiltinsNeedsCore;
345-
346342
#[derive(Diagnostic)]
347343
#[diag(metadata_not_profiler_runtime)]
348344
pub struct NotProfilerRuntime {

0 commit comments

Comments
 (0)