Skip to content

Commit

Permalink
Auto merge of rust-lang#131816 - Zalathar:profiler-feature, r=<try>
Browse files Browse the repository at this point in the history
Make `profiler_builtins` an optional dependency of sysroot, not std

This avoids unnecessary rebuilds of std (and the compiler) when `build.profiler` is toggled off or on.

Fixes rust-lang#131812.

---

Background: The `profiler_builtins` crate has been an optional dependency of std (behind a cargo feature) ever since it was added back in rust-lang#42433. But as far as I can tell that has only ever been a convenient way to force the crate to be built, not a genuine dependency.

The side-effect of this false dependency is that toggling `build.profiler` causes a rebuild of std and the compiler, which shouldn't be necessary. This PR therefore makes `profiler_builtins` an optional dependency of the dummy sysroot crate (rust-lang#108865), rather than a dependency of std.

What makes this change so small is that all of the necessary infrastructure already exists. Previously, bootstrap would enable the `profiler` feature on the sysroot crate, which would forward that feature to std. Now, enabling that feature directly enables sysroot's `profiler_builtins` dependency instead.

---

I believe this is more of a bootstrap change than a libs change, so tentatively:
r? bootstrap
  • Loading branch information
bors committed Oct 17, 2024
2 parents 06d261d + ca6b5d1 commit e9f26d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "addr2line"
Expand Down Expand Up @@ -340,7 +340,6 @@ dependencies = [
"object",
"panic_abort",
"panic_unwind",
"profiler_builtins",
"r-efi",
"r-efi-alloc",
"rand",
Expand Down Expand Up @@ -368,6 +367,7 @@ name = "sysroot"
version = "0.0.0"
dependencies = [
"proc_macro",
"profiler_builtins",
"std",
"test",
]
Expand Down
2 changes: 0 additions & 2 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "0.1.133" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',
Expand Down Expand Up @@ -98,7 +97,6 @@ backtrace = [
]

panic-unwind = ["panic_unwind"]
profiler = ["profiler_builtins"]
compiler-builtins-c = ["alloc/compiler-builtins-c"]
compiler-builtins-mem = ["alloc/compiler-builtins-mem"]
compiler-builtins-no-asm = ["alloc/compiler-builtins-no-asm"]
Expand Down
3 changes: 2 additions & 1 deletion library/sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
# this is a dummy crate to ensure that all required crates appear in the sysroot
[dependencies]
proc_macro = { path = "../proc_macro" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
std = { path = "../std" }
test = { path = "../test" }

Expand All @@ -23,7 +24,7 @@ system-llvm-libunwind = ["std/system-llvm-libunwind"]
panic-unwind = ["std/panic_unwind"]
panic_immediate_abort = ["std/panic_immediate_abort"]
optimize_for_size = ["std/optimize_for_size"]
profiler = ["std/profiler"]
profiler = ["profiler_builtins"]
std_detect_file_io = ["std/std_detect_file_io"]
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
std_detect_env_override = ["std/std_detect_env_override"]
Expand Down

0 comments on commit e9f26d2

Please sign in to comment.