[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240928204357.3a28dada.gary@garyguo.net>
Date: Sat, 28 Sep 2024 20:43:57 +0100
From: Gary Guo <gary@...yguo.net>
To: Danilo Krummrich <dakr@...nel.org>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, wedsonaf@...il.com,
boqun.feng@...il.com, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...sung.com, aliceryhl@...gle.com, akpm@...ux-foundation.org,
daniel.almeida@...labora.com, faith.ekstrand@...labora.com,
boris.brezillon@...labora.com, lina@...hilina.net, mcanal@...lia.com,
zhiw@...dia.com, cjia@...dia.com, jhubbard@...dia.com, airlied@...hat.com,
ajanulgu@...hat.com, lyude@...hat.com, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v7 25/26] kbuild: rust: remove the `alloc` crate and
`GlobalAlloc`
On Thu, 12 Sep 2024 00:53:01 +0200
Danilo Krummrich <dakr@...nel.org> wrote:
> Now that we have our own `Allocator`, `Box` and `Vec` types we can remove
> Rust's `alloc` crate and the `new_uninit` unstable feature.
>
> Also remove `Kmalloc`'s `GlobalAlloc` implementation -- we can't remove
> this in a separate patch, since the `alloc` crate requires a
> `#[global_allocator]` to set, that implements `GlobalAlloc`.
>
> Signed-off-by: Danilo Krummrich <dakr@...nel.org>
> ---
> rust/Makefile | 43 +++++----------------
> rust/exports.c | 1 -
> rust/kernel/alloc/allocator.rs | 63 +------------------------------
> scripts/Makefile.build | 7 +---
> scripts/generate_rust_analyzer.py | 11 +-----
> 5 files changed, 15 insertions(+), 110 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 72b1232b1f7d..529ec5972e55 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -262,18 +262,13 @@ $(obj)/%.lst: $(obj)/%.c FORCE
>
> # Compile Rust sources (.rs)
> # ---------------------------------------------------------------------------
> -
> -rust_allowed_features := new_uninit
> -
Would it make sense to throw in a soon-to-be-stable (or
already-stable-but-beyond-min-rust-version) feature here to not have to
remove the build system support for unstable feature directly?
For example, I know that const_refs_to_static might be added here
soon-ish.
> # `--out-dir` is required to avoid temporaries being created by `rustc` in the
> # current working directory, which may be not accessible in the out-of-tree
> # modules case.
> rust_common_cmd = \
> RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \
> - -Zallow-features=$(rust_allowed_features) \
I think this actually allow all features instead of allowing none.
> -Zcrate-attr=no_std \
> - -Zcrate-attr='feature($(rust_allowed_features))' \
> - -Zunstable-options --extern force:alloc --extern kernel \
> + -Zunstable-options --extern kernel \
> --crate-type rlib -L $(objtree)/rust/ \
> --crate-name $(basename $(notdir $@)) \
> --sysroot=/dev/null \
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index d2bc63cde8c6..09e1d166d8d2 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -64,13 +64,6 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs):
> [],
> )
>
> - append_crate(
> - "alloc",
> - sysroot_src / "alloc" / "src" / "lib.rs",
> - ["core", "compiler_builtins"],
> - cfg=crates_cfgs.get("alloc", []),
> - )
> -
> append_crate(
> "macros",
> srctree / "rust" / "macros" / "lib.rs",
> @@ -96,7 +89,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs):
> append_crate(
> "kernel",
> srctree / "rust" / "kernel" / "lib.rs",
> - ["core", "alloc", "macros", "build_error", "bindings"],
> + ["core", "macros", "build_error", "bindings"],
> cfg=cfg,
> )
> crates[-1]["source"] = {
> @@ -133,7 +126,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs):
> append_crate(
> name,
> path,
> - ["core", "alloc", "kernel"],
> + ["core", "kernel"],
> cfg=cfg,
> )
>
Powered by blists - more mailing lists