From patchwork Tue Mar 4 22:55:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benno Lossin X-Patchwork-Id: 14001590 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 784A82780E1; Tue, 4 Mar 2025 22:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741128919; cv=none; b=sV9WdSNXJgCMO50bS5Zonk1ORaFYBuxJ3d20N4tEv7LlVME8CvvE5ML/oD6YtlhW2eQ0q3nSXMvw8ZcTo5fnRRvLWzYnjLAoVyXfjs5/ppfLEhjyYmAHtWOfv4PA0SNIHZ7J70Xu5aOeUXdBFG4611ZvGMB8GmzvJDbWAethun8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741128919; c=relaxed/simple; bh=klf+lp55mfDrG/1Bwb8fQJYIX6GXd18Gw8msOUHxyDY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YcrvKdtVGppUfA3EZdIPUolx30XRrCUxlA18NcHG+ylrYOS1E2ACcpR4BeUACkOAOdHbX3hJrQQXvRrojnKmUsV0/3K718pp8zSMrpOGoO1bM2sxD/L2HdRpzQvKADhMDJKyhgeV1zcGd/ebCRrjplo3I2zMHK8ZzPMe8cil66U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=V0itePNZ; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="V0itePNZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1741128914; x=1741388114; bh=9ktcs2JjIkXtE2G2aieN69fA68njFZ1Ud+0yudHUGAg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=V0itePNZMuHFEMnkHY/8lQzu3SGfeEuM9Jqxa4dJ73+pxT6UQXAJkXHjfEmfSOaEe 6ejcv4LQDlGkM8m/jKBc4wBb86S69L6+QCvfQspgsJiN7BhwWtkkF56XE7yZU+sdy6 3Qm4rHO/ETL/bO8mqkSMrU1BY87YGPnY4DrxAKeaC/OMCIOG5nWfhQRdbOEf0ZKkcP EWZ4eHvMP6v6kNol8IdEGdSNpFNZad5ARtFB/142lIXcu/O5pPKbeetYiAyFUNyg/2 TEWahFuz2yXJsRuJvJ052K42XXGh2hKk1bDTNp2d3Bo5UIidS15P8QZ4q6JW3sg9MX 134KGMPUovDzw== Date: Tue, 04 Mar 2025 22:55:09 +0000 To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Masahiro Yamada , Nathan Chancellor , Nicolas Schier From: Benno Lossin Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH 14/22] rust: add pin-init crate build infrastructure Message-ID: <20250304225245.2033120-15-benno.lossin@proton.me> In-Reply-To: <20250304225245.2033120-1-benno.lossin@proton.me> References: <20250304225245.2033120-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 5323de5313efcd0522f7a176cf8dae2d57e087f5 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Miguel Ojeda Add infrastructure for moving the initialization API to its own crate. Covers all make targets such as `rust-analyzer` and `rustdoc`. The tests of pin-init are not added to `rusttest`, as they are already tested in the user-space repository [1]. Link: https://github.com/Rust-for-Linux/pin-init [1] Signed-off-by: Miguel Ojeda Co-developed-by: Benno Lossin Signed-off-by: Benno Lossin --- rust/Makefile | 75 +++++++++++++++++++++++------- rust/pin-init/internal/src/_lib.rs | 3 ++ rust/pin-init/internal/src/lib.rs | 4 ++ rust/pin-init/src/_lib.rs | 5 ++ scripts/Makefile.build | 2 +- scripts/generate_rust_analyzer.py | 17 ++++++- 6 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 rust/pin-init/internal/src/_lib.rs create mode 100644 rust/pin-init/src/_lib.rs diff --git a/rust/Makefile b/rust/Makefile index ea3849eb78f6..90310f0620eb 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_RUST) += helpers/helpers.o CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs -obj-$(CONFIG_RUST) += bindings.o kernel.o +obj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o always-$(CONFIG_RUST) += exports_helpers_generated.h \ exports_bindings_generated.h exports_kernel_generated.h @@ -41,7 +41,10 @@ ifdef CONFIG_RUST libmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type proc-macro - TokenStream { diff --git a/rust/pin-init/src/_lib.rs b/rust/pin-init/src/_lib.rs new file mode 100644 index 000000000000..e0918fd8e9e7 --- /dev/null +++ b/rust/pin-init/src/_lib.rs @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + +//! Will be removed in a future commit, only exists to prevent compilation errors. + +#![no_std] diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 993708d11874..08b6380933f5 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -237,7 +237,7 @@ rust_common_cmd = \ -Zallow-features=$(rust_allowed_features) \ -Zcrate-attr=no_std \ -Zcrate-attr='feature($(rust_allowed_features))' \ - -Zunstable-options --extern kernel \ + -Zunstable-options --extern pin_init --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 aa8ea1a4dbe5..a44a4475d11f 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -93,10 +93,25 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): ) crates[-1]["env"]["OBJTREE"] = str(objtree.resolve(True)) + append_crate( + "pin_init_internal", + srctree / "rust" / "pin-init" / "internal" / "src" / "_lib.rs", + [], + cfg=["kernel"], + is_proc_macro=True, + ) + + append_crate( + "pin_init", + srctree / "rust" / "pin-init" / "src" / "_lib.rs", + ["core", "pin_init_internal", "macros"], + cfg=["kernel"], + ) + append_crate( "kernel", srctree / "rust" / "kernel" / "lib.rs", - ["core", "macros", "build_error", "bindings"], + ["core", "macros", "build_error", "bindings", "pin_init"], cfg=cfg, ) crates[-1]["source"] = {