From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F120ACEB2D0 for ; Tue, 1 Oct 2024 13:27:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82E6A280085; Tue, 1 Oct 2024 09:27:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DE57280068; Tue, 1 Oct 2024 09:27:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A611280085; Tue, 1 Oct 2024 09:27:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4D4A3280068 for ; Tue, 1 Oct 2024 09:27:18 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C9EA7C074E for ; Tue, 1 Oct 2024 13:27:17 +0000 (UTC) X-FDA: 82625109714.23.363C99D Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf10.hostedemail.com (Postfix) with ESMTP id 134DEC0006 for ; Tue, 1 Oct 2024 13:27:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qFS5gTba; spf=pass (imf10.hostedemail.com: domain of dakr@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727789067; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aUSIvpYMnJtP1vmdVT0cLqO1ZJaZ621hP78oqnWiy0k=; b=75t4OfOzyoz7J9ChRGbQQ0uaiZimJ90gqEhU3BL2op/DTFl42aIPib47K7WC7Dqr8sAJ2C JmTM+SQp2nqF42gOAkY8aCLLcajtejBWdzAP+poqRcZMuivI+e+5AgLsNAl0gJTieDhqsj YDbEeC9i35oEno4zx+ZWmhJX9d2NwDQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qFS5gTba; spf=pass (imf10.hostedemail.com: domain of dakr@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727789067; a=rsa-sha256; cv=none; b=Del8R54jjtcXrRu/VDVUPUW86h2fGxAXkdtBm5VVkRZv45gGcjZP7ZF3aXfknL9SkcDF9k pv+iJUI+MKakQoCm9cayJ+3QvYeluHe72kE+bqxWsuCFxGAMDN1t5rtQNa8+Se/9Th8ZQ1 WFRuqn6+ve/i7UOtAAfE3TkG9PU2C4k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id AFAD4A436B8; Tue, 1 Oct 2024 13:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 222F2C4CED1; Tue, 1 Oct 2024 13:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727789234; bh=lo+LhlofpgXlCwI69zHLxSTcxLWDkf/fiIg3BNcDXv4=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=qFS5gTbaHhXSeyvgEFgpM2FFgO5HEgLCg4qaY9ONUZR0Z8R8lRy5UJ4/aFZO1qYM3 w7IFJdmrsNnEnTsX/WdJ0qetntbOs4ZUL2oAKdi2Ed6+2G6XHRhYexKnXJzl7ABasH xE+24mCQe5vUTGVPf4RbIBcTSFW70hLD6wS20Y+1gOGsnl4T4dxvL7LYl1H545LAzk 01Ajoh7rXzZYoG60cjGb5DwxQ6uUxFti4NCuH7vkpjrjKVx6NH8jjQfP3pjvDDAwkY A2pNRIRdV12sUTSzelVfMLrRsVHXzMmzCHH53OFwkYwtu7GoFntHG9lkS59cr2waIW ZcHqTZhXC17PQ== Message-ID: <829c9cf9-9e73-4167-94dc-ca5db3a37e6a@kernel.org> Date: Tue, 1 Oct 2024 15:27:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 25/26] kbuild: rust: remove the `alloc` crate and `GlobalAlloc` From: Danilo Krummrich To: Gary Guo Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org, daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org References: <20240911225449.152928-1-dakr@kernel.org> <20240911225449.152928-26-dakr@kernel.org> <20240928204357.3a28dada.gary@garyguo.net> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 134DEC0006 X-Stat-Signature: 9j6m3p3kmcc1mg6a96f1u81or4axjggk X-Rspam-User: X-HE-Tag: 1727789235-179102 X-HE-Meta: U2FsdGVkX18+SqNEjC8ASYKXlGaxpA7+17KNFMpl9nF1CbwG7BVOKAF/0vMshH2F5E/TB6NBOsca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upRCK/ZNkSs6/wDD3jiMnLkgxbZeXqZsvaVJmAhZvm5TNAwbckxcveBOH5intta7D57EdwcSMO8pMEibEmG20YRswm5TBuyqDXssP8VlURyRj+lBeL+L5v6RhSzTZlqe7SkxvmNpENOwjAQOxReGDR68v4OP9IBqzFGJ+ctgXX7PdFV42l6CuhimuULhmSzKxZD1Pzg+fEB2m1gXo07egI45PQ+g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 9/29/24 5:17 PM, Danilo Krummrich wrote: > On Sat, Sep 28, 2024 at 08:43:57PM +0100, Gary Guo wrote: >> On Thu, 12 Sep 2024 00:53:01 +0200 >> Danilo Krummrich 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 >>> --- >>> 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? > > It's only about those two lines, right? I can only remove the `new_uninit` and > leave `rust_allowed_features :=` and leave... > >> >> 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) \ > > ...this line, I guess? Seems like I can't, it blows up with an empty feature list. I'll keep it as it is for now. Shouldn't be a big deal to add it again, once needed. > >> >> 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, >>> ) >>> >>