Add "system" option to override-allocator directive - #160100
Conversation
|
This PR modifies If appropriate, please update |
|
r? @jieyouxu rustbot has assigned @jieyouxu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
In case it is useful for review purposes, I've uploaded a version of this patch with some extra tracing code to a different branch: https://github.com/fs-rachel/rust/tree/fix-jemalloc-directive-with-tracing |
|
Small procedural question about @Kobzol's suggestion of renaming |
|
Good point, I was also thinking about that. Even though it's new, I think we should just create a new change tracker entry.. some people might already renamed the option (the It's not great that we do a breaking change so soon, but I think that it also doesn't warrant creating yet another way to configure the allocator. We could also just keep the |
|
r? @Kobzol |
Okay, I'll re-upload with that change in a minute
IMHO |
|
Yeah, it does :) And even if we changed the default allocator on some targets in the future, "system" vs "jemalloc" still seems like reasonable options, we could maybe add "default" in the future, but I don't think that would be needed, the default will likely always be the system one. |
849982d to
ed7c99e
Compare
|
I'm not sure about dropping the |
|
I don't think that overriding is a load-bearing word in tems of unsafety, you can probably cause a whole lot of issues or unsafety by (mis)configuring other bootstrap options, which don't talk about overriding a specific thing. Good point about the Since we are already renaming the option and breaking people who updated bootstrap since last week (hopefully not too many of them), moving the By the way, all uses of |
|
Moving into the build section seems reasonable |
ed7c99e to
ff6dcf4
Compare
|
This PR modifies If appropriate, please update Warning If you are changing how CI LLVM is built or linked, make sure to bump cc @jieyouxu |
ff6dcf4 to
76bb5f0
Compare
|
Tidied things up and moved |
|
And a note to myself: Once this is merged I need to send a separate PR to rustc-dev-guide to update things there |
| if let Some(allocator) = builder.config.override_allocator(target) { | ||
| let allocator = builder.config.allocator(target); | ||
| if allocator != Allocator::System { | ||
| features.push(allocator.feature_name().to_string()); |
There was a problem hiding this comment.
I think that a better design (rather than panicking) would be for feature_name() to return Option<&'static str> (or just Option<String>, doesn't really matter), and then we'd use if let Some(feature_name) = allocator.feature_name() { ... }.
| @@ -406,7 +402,6 @@ pub fn check_incompatible_options_for_ci_rustc( | |||
| err!(current_rust_config.llvm_tools, llvm_tools, "rust"); | |||
| err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust"); | |||
| err!(current_rust_config.jemalloc, jemalloc, "rust"); | |||
There was a problem hiding this comment.
This should still check the allocator from the build section.
There was a problem hiding this comment.
I've had a look at what this is actually doing, and I think it should also check the target.<host>.jemalloc and target.<host>.allocator settings, so I'll add those as well
There was a problem hiding this comment.
Oh and there's one glaring issue I've noticed: If there are incompatible settings in the target.<host> section, the warning message incorrectly states the issue is in the build section
Honestly this function should probably be cleaned up and moved elsewhere, but I'll at least fix that one while I'm here.
There was a problem hiding this comment.
Tbh it's a sanity check, the function doesn't have to be perfect. I don't think we ever dealt with target options in these sanity checks, and there are also other options that could affect the build. It's a best-effort check.
This comment has been minimized.
This comment has been minimized.
Add "system" option to `override-allocator` directive
b0cb8f9 to
92c4436
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
…n download rustc from CI
…ild.<host>` section
92c4436 to
0ca1049
Compare
I did a find-and-replace before rebasing, and I don't see any new instances when I search for
That was a merge conflict during rebasing, and I just didn't realize that it had to be ordered like that. Fixed. |
|
Oh, maybe I rebased wrongly or my IDE showed stale result. Nevermind, it indeed looks like there aren't any mentions left. Thank you! @bors r+ rollup=iffy |
…r=Kobzol Add "system" option to `override-allocator` directive This allows a per-target `override-allocator` to revert to the system allocator even if there is a global rule specifying a different allocator. Remap `jemalloc = false` to `override-allocator = "system"` instead of mapping it to "override-allocator is unset"; this restores the correct precedence behaviour of this directive. This also allows `Config::override_allocator()` to always resolve the directive to a definite value, rather than needing it to be wrapped in an `Option`, which simplifies some other code. Finally, print a more specific warning when `jemalloc` is set, telling users the appropriate setting to use for `override-allocator` depending on whether `jemalloc` is set to true or false. Fixes rust-lang#160084
…r=Kobzol Add "system" option to `override-allocator` directive This allows a per-target `override-allocator` to revert to the system allocator even if there is a global rule specifying a different allocator. Remap `jemalloc = false` to `override-allocator = "system"` instead of mapping it to "override-allocator is unset"; this restores the correct precedence behaviour of this directive. This also allows `Config::override_allocator()` to always resolve the directive to a definite value, rather than needing it to be wrapped in an `Option`, which simplifies some other code. Finally, print a more specific warning when `jemalloc` is set, telling users the appropriate setting to use for `override-allocator` depending on whether `jemalloc` is set to true or false. Fixes rust-lang#160084
…uwer Rollup of 21 pull requests Successful merges: - #160100 (Add "system" option to `override-allocator` directive) - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - #160233 (Bubble bad path error while parsing field to avoid unecessary second error) - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - #154202 (rustfmt: Format `cfg_select!`) - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules) - #159520 (Suggest `Vec<T>` instead of `[T]`) - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - #160066 (rustc_middle: lint attribute cleanups) - #160085 (Remove various superfluous lint attributes) - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - #160157 (Remove outdated comments from `va_list.rs`) - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - #160244 (Rename splat to rustc_splat in error messages) - #160246 (dont fire `unused_mut` on `&pin mut self`) - #160247 (Configure backport nominations for rustfmt) - #160274 (renovate: update lock files weekly)
…uwer Rollup of 22 pull requests Successful merges: - #160100 (Add "system" option to `override-allocator` directive) - #160220 (Refactor: shrink region ext traits) - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - #160233 (Bubble bad path error while parsing field to avoid unecessary second error) - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - #154202 (rustfmt: Format `cfg_select!`) - #159520 (Suggest `Vec<T>` instead of `[T]`) - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts) - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - #160066 (rustc_middle: lint attribute cleanups) - #160085 (Remove various superfluous lint attributes) - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - #160157 (Remove outdated comments from `va_list.rs`) - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - #160244 (Rename splat to rustc_splat in error messages) - #160246 (dont fire `unused_mut` on `&pin mut self`) - #160247 (Configure backport nominations for rustfmt) - #160274 (renovate: update lock files weekly)
Rollup merge of #160100 - fs-rachel:fix-jemalloc-directive, r=Kobzol Add "system" option to `override-allocator` directive This allows a per-target `override-allocator` to revert to the system allocator even if there is a global rule specifying a different allocator. Remap `jemalloc = false` to `override-allocator = "system"` instead of mapping it to "override-allocator is unset"; this restores the correct precedence behaviour of this directive. This also allows `Config::override_allocator()` to always resolve the directive to a definite value, rather than needing it to be wrapped in an `Option`, which simplifies some other code. Finally, print a more specific warning when `jemalloc` is set, telling users the appropriate setting to use for `override-allocator` depending on whether `jemalloc` is set to true or false. Fixes #160084
View all comments
This allows a per-target
override-allocatorto revert to the system allocator even if there is a global rule specifying a different allocator.Remap
jemalloc = falsetooverride-allocator = "system"instead of mapping it to "override-allocator is unset"; this restores the correct precedence behaviour of this directive.This also allows
Config::override_allocator()to always resolve the directive to a definite value, rather than needing it to be wrapped in anOption, which simplifies some other code.Finally, print a more specific warning when
jemallocis set, telling users the appropriate setting to use foroverride-allocatordepending on whetherjemallocis set to true or false.Fixes #160084