From nobody Sat Apr 4 04:43:38 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65A982DCF67 for ; Fri, 3 Apr 2026 14:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228014; cv=none; b=Iwq0ncRWcPLXSQsRhfwTB7Ws1TrEk1sHmUODl/LCXrSkKKD3YIVp2wWcLm5pIqzWdZ2QQ5Pg3x9+6VjNze1E9ft3QmGVnlz9e88etxxR6srG8YmMji+8VDPDustAM9tnqoI6EUTCdlXFDcPUcPFz7WiANQIqW795672fgMDg0Gw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228014; c=relaxed/simple; bh=s41PsyrgmivcxsEasV3F2vMv28LGN20R8nGi2RgZncQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LzcTaA2iMpVdqyGwOOKi4dOVufBQ3I24nV+6vAj2/k+P5q9tGjFPrPZ1ukZC8aojJEobY7cUGSYVpT6bPXFqPtu8sikI0L14ArSNFmlZnXI6D8YF27/lb/f0+nlqLcw4Cty9yHkpM6Q8r5LgV7C/Qndw4Wk9cjOiq/A0lDgU8Uc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=p+Y9/fF2; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p+Y9/fF2" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82cebbdbdccso1004381b3a.1 for ; Fri, 03 Apr 2026 07:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775228013; x=1775832813; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fUTSB1GcQ+ZgkTavCnlkXCyNO/5I/d2MoyKGgMKrfsE=; b=p+Y9/fF2HU/q9BM6BbAVdapW7m1xvPLhcfdI7s0Jyu8nnc9WTg15KQg0XTz6AcUEwY S4HvDQGIJd61RGDC4tPJJD5X/tJv7jyih9BKewfeDyEmJqa+fFfG7L+DmUyci6Be3E+8 FYO/3303Kb62RAvjy2xhvnSzkTrVUyGb28c30wkM5Gwckl72ux0xVJ1tXLFZh/hhk/BE h7fvxPPbXfGz39inXdyg34pqUIuYpLu5WqJq8l3ExxLamI0Es2U+DH9tl3YByPgc+42s ufK7eab9lViUwX8lXC8zE9fVznZVptu812LD5XH6fu7xffru2oBuc2XdvQz/kP/W5L6w exZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775228013; x=1775832813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fUTSB1GcQ+ZgkTavCnlkXCyNO/5I/d2MoyKGgMKrfsE=; b=cFbsh9clOMZEwdfPvVuUcgf6hhsOuLrvhbWkLWN5rvcm9mq4PCg9C4wdbiJmdZ0F4h uWgYzegrT6ZfmBvDfjkLwNpZ4EQMLUUAatWb27boB3bBizxBSywp48TUX4a3fOvksrf/ NY/jU/gRWo8THCP6m2sJxaVb1i7TudilfRh+UL8TGTEDSw/e7zni5bDQVxshkbDbYU20 UUy9cGRGkoVHe9RjBGd08QcqgedITDPDMgtgVH0d4/pAaGERuCKr6Taf0dUuXQz9PeTE dOXcvm8bnlj/zoZoI9J9KTiBNM+fC3s7cU059D4ryVFkuxwAqdZVfEUNm82ehETmSv/R KMAQ== X-Forwarded-Encrypted: i=1; AJvYcCVQEEZd6W+W++Gv+TkzwWKDDuqbONgnyET2HkI5+/iVGBSzKgH5sBhyBhr5SGyEEqUX2NRpHphqKqjDAs4=@vger.kernel.org X-Gm-Message-State: AOJu0YyvuVum1ZHoK89K4zz/DJf/exotmnRHB0EKc665yNsvhKX+/3T7 YYtGVXJBbW+1oCrak66VDkdZzUx5l+efOVO1q9IZQvXqaxDAgZ7fsZI5 X-Gm-Gg: AeBDievXZwPb6tfsT1FgU+rB6rDDggggC8AVcaIRGOzGc02BAqkKTrrMhHpNX7QDD+S GwUWTcL5A3nydf+rUPSSlkmKSzqxhFnI9LohYdGTRJ0uMV7Byb9ouOYDE7S64gWfby7J7fYZJAN 7ljRkKKOymvKun3LrGR3mQrEUbFyMiEx6a4DIC/0TwuO4djUkj5qbOnqrhk224YsKBPJyPc26wy XLYDf6Dpzikv3X6Jq9nowmwTCst5YxZpNfrFz2/Si799CatIU7pxveguaz0pKRvJ4UenuEq84gD J3+2Jy93Y2sLAOpR5L7w5H1j4zR5R1vDwdQT5C4o4BExwLqcvg6F1iojzS1xR8cYVYOmiaMJzVn fqJePBoh1oTPiRvxdXHNn2lJNm5/Wbm+wIKIwlTynfv3//svvTApolu5lhJytymt9A6Ka9vAaHM g2fhHIYIAXLu/JpffRlPn90uDc2U26LdnZWTfM0BNf36Rgyez51vHiyZSPNS8kmrq+xrOglcbIz BfBoUcMcxv0Iw== X-Received: by 2002:a05:6a00:3699:b0:81f:544b:3998 with SMTP id d2e1a72fcca58-82d0dd20f4amr2711320b3a.26.1775228012689; Fri, 03 Apr 2026 07:53:32 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.160.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9ca4efesm6301682b3a.61.2026.04.03.07.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 07:53:32 -0700 (PDT) From: "Mukesh Kumar Chaurasiya (IBM)" To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, aliceryhl@google.com, rostedt@goodmis.org, ardb@kernel.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Cc: "Mukesh Kumar Chaurasiya (IBM)" Subject: [PATCH V8 1/4] rust: Fix "multiple candidates for rmeta dependency core" error Date: Fri, 3 Apr 2026 20:23:05 +0530 Message-ID: <20260403145308.1042622-2-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403145308.1042622-1-mkchauras@gmail.com> References: <20260403145308.1042622-1-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When building Rust code with LLVM=3D1 with -j1, rustc was encountering an error: "multiple candidates for `rmeta` dependency `core` found", with two candidates: 1. The host's standard library from the rustup toolchain 2. The kernel's custom libcore.rmeta in the rust/ directory This occurred because the build system was using `-L$(objtree)/rust` for host library builds (proc_macro2, quote, syn), which caused rustc to search the rust/ directory. During this search, rustc would find both the kernel's custom libcore.rmeta and gain access to the host's standard library, creating a conflict. The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use `-L$(objtree)/rust/host` for host builds instead of `-L$(objtree)/rust`. This ensures that: 1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta 2. Proc macro builds use `-L$(objtree)/rust/host` to find their dependencies 3. Test builds use `-L$(objtree)/rust/test` for their dependencies 4. Target builds continue to use `-L$(objtree)/rust` as before Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit `--extern` paths with absolute paths to reference the proc macros without adding `-L$(objtree)/rust`, which would reintroduce the conflict. The rust/host/ directory is added to clean-files to ensure it's removed during `make clean`. Changes: - Add clean-files :=3D host/ to clean the generated directory - Change host library targets from lib*.rlib to host/lib*.rlib - Update cmd_rustc_procmacrolibrary to create host/ directory - Update cmd_rustc_procmacro to use -L$(objtree)/rust/host - Update cmd_rustdoc to use -L$(objtree)/rust/host for host builds - Update cmd_rustc_test_library to use -L$(objtree)/rust/test - Update rustdoc-pin_init to use explicit --extern paths for proc macros Link: https://github.com/Rust-for-Linux/linux/issues/105 Link: https://github.com/linuxppc/issues/issues/451 Signed-off-by: Mukesh Kumar Chaurasiya (IBM) --- rust/Makefile | 63 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index 9801af2e1e02..762bddc868e4 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -3,6 +3,9 @@ # Where to place rustdoc generated documentation rustdoc_output :=3D $(objtree)/Documentation/output/rust/rustdoc =20 +# Clean generated host directory +clean-files :=3D host/ + obj-$(CONFIG_RUST) +=3D core.o compiler_builtins.o ffi.o always-$(CONFIG_RUST) +=3D exports_core_generated.h =20 @@ -27,7 +30,7 @@ endif =20 obj-$(CONFIG_RUST) +=3D exports.o =20 -always-$(CONFIG_RUST) +=3D libproc_macro2.rlib libquote.rlib libsyn.rlib +always-$(CONFIG_RUST) +=3D host/libproc_macro2.rlib host/libquote.rlib hos= t/libsyn.rlib =20 always-$(CONFIG_RUST_KERNEL_DOCTESTS) +=3D doctests_kernel_generated.rs always-$(CONFIG_RUST_KERNEL_DOCTESTS) +=3D doctests_kernel_generated_kunit= .c @@ -150,7 +153,7 @@ quiet_cmd_rustdoc =3D RUSTDOC $(if $(rustdoc_host),H, )= $< OBJTREE=3D$(abspath $(objtree)) \ $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=3D% --remap-pat= h-scope=3D%, \ $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ - $(rustc_target_flags) -L$(objtree)/$(obj) \ + $(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \ -Zunstable-options --generate-link-to-definition \ --output $(rustdoc_output) \ --crate-name $(subst rustdoc-,,$@) \ @@ -193,13 +196,16 @@ rustdoc-proc_macro2: $(src)/proc-macro2/lib.rs rustdo= c-clean FORCE +$(call if_changed,rustdoc) =20 rustdoc-quote: private rustdoc_host =3D yes -rustdoc-quote: private rustc_target_flags =3D $(quote-flags) +rustdoc-quote: private rustc_target_flags =3D $(quote-flags) \ + --extern proc_macro2=3D$(abspath $(objtree)/$(obj)/host/libproc_macro2= .rlib) rustdoc-quote: private skip_flags =3D $(quote-skip_flags) rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE +$(call if_changed,rustdoc) =20 rustdoc-syn: private rustdoc_host =3D yes -rustdoc-syn: private rustc_target_flags =3D $(syn-flags) +rustdoc-syn: private rustc_target_flags =3D $(syn-flags) \ + --extern proc_macro2=3D$(abspath $(objtree)/$(obj)/host/libproc_macro2= .rlib) \ + --extern quote=3D$(abspath $(objtree)/$(obj)/host/libquote.rlib) rustdoc-syn: $(src)/syn/lib.rs rustdoc-clean rustdoc-quote FORCE +$(call if_changed,rustdoc) =20 @@ -236,7 +242,10 @@ rustdoc-pin_init_internal: $(src)/pin-init/internal/sr= c/lib.rs \ +$(call if_changed,rustdoc) =20 rustdoc-pin_init: private rustdoc_host =3D yes -rustdoc-pin_init: private rustc_target_flags =3D $(pin_init-flags) \ +rustdoc-pin_init: private rustc_target_flags =3D \ + --extern pin_init_internal=3D$(abspath $(objtree)/$(obj)/$(libpin_init= _internal_name)) \ + --extern macros=3D$(abspath $(objtree)/$(obj)/$(libmacros_name)) \ + $(call cfgs-to-flags,$(pin_init-cfgs)) \ --extern alloc --cfg feature=3D\"alloc\" rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \ rustdoc-macros FORCE @@ -369,7 +378,9 @@ rusttest: rusttest-macros =20 rusttest-macros: private rustc_target_flags =3D --extern proc_macro \ --extern macros --extern kernel --extern pin_init \ - --extern proc_macro2 --extern quote --extern syn + --extern proc_macro2=3D$(abspath $(objtree)/$(obj)/test/libproc_macro2= .rlib) \ + --extern quote=3D$(abspath $(objtree)/$(obj)/test/libquote.rlib) \ + --extern syn=3D$(abspath $(objtree)/$(obj)/test/libsyn.rlib) rusttest-macros: private rustdoc_test_target_flags =3D --crate-type proc-m= acro rusttest-macros: $(src)/macros/lib.rs \ rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE @@ -525,48 +536,54 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FO= RCE =20 quiet_cmd_rustc_procmacrolibrary =3D $(RUSTC_OR_CLIPPY_QUIET) PL $@ cmd_rustc_procmacrolibrary =3D \ + mkdir -p $(dir $@); \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \ --emit=3Ddep-info=3D$(depfile) --emit=3Dlink=3D$@ --crate-type rlib -O \ - --out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \ --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $< =20 -$(obj)/libproc_macro2.rlib: private skip_clippy =3D 1 -$(obj)/libproc_macro2.rlib: private rustc_target_flags =3D $(proc_macro2-f= lags) -$(obj)/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE +$(obj)/host/libproc_macro2.rlib: private skip_clippy =3D 1 +$(obj)/host/libproc_macro2.rlib: private rustc_target_flags =3D $(proc_mac= ro2-flags) +$(obj)/host/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE +$(call if_changed_dep,rustc_procmacrolibrary) =20 -$(obj)/libquote.rlib: private skip_clippy =3D 1 -$(obj)/libquote.rlib: private skip_flags =3D $(quote-skip_flags) -$(obj)/libquote.rlib: private rustc_target_flags =3D $(quote-flags) -$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE +$(obj)/host/libquote.rlib: private skip_clippy =3D 1 +$(obj)/host/libquote.rlib: private skip_flags =3D $(quote-skip_flags) +$(obj)/host/libquote.rlib: private rustc_target_flags =3D $(quote-flags) \ + --extern proc_macro2=3D$(abspath $(objtree)/$(obj)/host/libproc_macro2.rl= ib) +$(obj)/host/libquote.rlib: $(src)/quote/lib.rs $(obj)/host/libproc_macro2.= rlib FORCE +$(call if_changed_dep,rustc_procmacrolibrary) =20 -$(obj)/libsyn.rlib: private skip_clippy =3D 1 -$(obj)/libsyn.rlib: private rustc_target_flags =3D $(syn-flags) -$(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE +$(obj)/host/libsyn.rlib: private skip_clippy =3D 1 +$(obj)/host/libsyn.rlib: private rustc_target_flags =3D $(syn-flags) \ + --extern proc_macro2=3D$(abspath $(objtree)/$(obj)/host/libproc_macro2.rl= ib) \ + --extern quote=3D$(abspath $(objtree)/$(obj)/host/libquote.rlib) +$(obj)/host/libsyn.rlib: $(src)/syn/lib.rs $(obj)/host/libquote.rlib FORCE +$(call if_changed_dep,rustc_procmacrolibrary) =20 quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET) P $@ cmd_rustc_procmacro =3D \ - $(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \ + $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ -Clinker-flavor=3Dgcc -Clinker=3D$(HOSTCC) \ -Clink-args=3D'$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \ --emit=3Ddep-info=3D$(depfile) --emit=3Dlink=3D$@ --extern proc_macro \ - --crate-type proc-macro -L$(objtree)/$(obj) \ + --crate-type proc-macro \ + -L$(objtree)/$(obj)/host \ --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \ - @$(objtree)/include/generated/rustc_cfg $< + @$(objtree)/include/generated/rustc_cfg \ + $(rustc_target_flags) \ + $< =20 # Procedural macros can only be used with the `rustc` that compiled it. $(obj)/$(libmacros_name): private rustc_target_flags =3D \ --extern proc_macro2 --extern quote --extern syn -$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \ - $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE +$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/host/libproc_macro2.= rlib \ + $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE +$(call if_changed_dep,rustc_procmacro) =20 $(obj)/$(libpin_init_internal_name): private rustc_target_flags =3D $(pin_= init_internal-flags) $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \ - $(obj)/libproc_macro2.rlib $(obj)/libquote.rlib $(obj)/libsyn.rlib FOR= CE + $(obj)/host/libproc_macro2.rlib $(obj)/host/libquote.rlib $(obj)/host/= libsyn.rlib FORCE +$(call if_changed_dep,rustc_procmacro) =20 # `rustc` requires `-Zunstable-options` to use custom target specifications --=20 2.53.0 From nobody Sat Apr 4 04:43:38 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1115E374730 for ; Fri, 3 Apr 2026 14:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228024; cv=none; b=I/zntoiBDcr2/+JDpIkgZFHLjC0mUFBDGNU0iZ6mgFF74lIucC1llr6T8RGZdpb4VanwRIbeds8B34J6HLbob4U6qO9YRGINd9ZSf+i5qyzGOE1J35Q5aUV5G3XjSRUqv3mgRil9ou8fa/eiffEJnCGs7wiP4YN4y+hLDiz5kbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228024; c=relaxed/simple; bh=8WQ7jEq8bJBsdnlHGUXrbWXnXrrr5Xxc2+zvN+1cF+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdPVnlSL1DFte4C6JXuzzsLNHF/WDdc7+MPtNKuxosQbq82FZr7jTCl5scnGwpri/UoagNZqRucH05qmJjg7T+kev+k2AOSe+6CqXoccbE/7B0WrxrTSW6yCVn9HSic454l1CT0SHc++FOIRjX3u6GL+ToxZdBSC3zMo0OsglQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=q+Iy4yN1; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q+Iy4yN1" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-824c9da9928so1197121b3a.3 for ; Fri, 03 Apr 2026 07:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775228022; x=1775832822; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SIf376OZyXcpY0mdrIrP1nTWV/VE0v5g8114Fjjgl84=; b=q+Iy4yN17nA7Z90UqWxkrbrvCXUr0bZgVn0JykyfefcL+DijJlO1wrzBgjV+3MpzKb jASPIuwF7i+vExD0S1tRhCXxx4C3FJUbUhKxN2O30dY6PAVlRPY+0dOapR2VrhC8ZeK3 XNBmLfW9JNEYrLZtcLxpMvVOHXY2e5aCptnd9qgIvKrY77hWeNMYA7l4NKarJHYa2lfz ym7FeoPTBhZW+GbtsOwxemvKZnZWRPB+nd6wNw50wTLFVgsWDOCQVxZplXz6IjjjPkLf TKjFpYZ2NCsh8vYfd+Sg/3NGcQVd2ubfgEZ7XpXSHEq7B521WOHg9ruWDLfghjoUiJLx UiOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775228022; x=1775832822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SIf376OZyXcpY0mdrIrP1nTWV/VE0v5g8114Fjjgl84=; b=Xht/W3I7LbT1xwdxbSApHsSA8mA2coSvNSlSBZSPwZqRSlQASNhxIFg3uAnzxj4y0j sK1cTC4QbTMs502MSWvsL3x2GJTDcENYGVUDkx6aPUN5EWGzdASm6KpiWI1Hsu6yDTwR MTqbOz5gC8r6T40f/Eqs1DbYJHOz7mLVlWQ9da/M4aEcMGOzjx4nmSiS6NxKA5TcxzlH lBL5WTWSS5CPW67Wg+ZNf24Jcvx8AxHht7tcN66556EMjpGqEQQMimKk6a1xwMLJXv7J FKGbwpVGsJkV2BVc+gsgycFoGcDvk/TVr/2Vbkp/+icdOyb5dzoWUC7DAFgDVn37mtyO 2ZiQ== X-Forwarded-Encrypted: i=1; AJvYcCXI98kid9PrtUdUI1NQv5z9UaefL92nGwzp2CmuISOFf8cXXJZQ4LKP3qtbE6FgOfHFmiCvzFIXSr7uILI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4nJn8JGMsTe9OTcziIEC7WLZ3e+Bdq0K2ZRPRv/CeB7ffU56q L+T+i691f1JeWV0YglVwPbfLT4v9m+NrYbgQbizXCnbziJ2m9DEtEdT/ X-Gm-Gg: ATEYQzzHqCcTslr2U6m9HVcRJCdFyGgl0JcsHb8VgAfwBR9EV0Ihewt+XpRBtic7dMW +Gc52nSpPIWPuhvK0IyJuepLi3W9K9iAITNHEmmc0Y1IxcILu7XreMgnW2fY2jofpj5fdwB4MRy i5d9zwvwMgOl6aZJ7QFZhoYnVPrOjx/eBOemOE9gg4HfYjygWELeLuRlYD+4UkfWTybGx77gG67 4tCpcZF/ZJ2modLN+esu0MtQw1h/PhFhAAyPx36UuH9ApL9ZhTPF40dkhyfkD7XMSLsiUMr/0tm 8TQ9yOER9WmBr+4DF4Y4dxDPY4wXf1q3foYP7/4X0W/QAbQ8XN7MXVTSiZQrXQv6gXyxxP7VNc3 rfpP5NOMfSGoMNdQdqDj/UWgewZDFXVnXibtAoJGJ4vHiqKvixblLCLn8ZY8Ylag2njB4bIKoSa EsZK+veSzPbkxAoZvZx7JpFAdeWEfI5HA3MeLubPO8qDS3sIYNrJWOWYJiNA5C/MvKCAkP7rQXa nQ= X-Received: by 2002:a05:6a00:414c:b0:82c:fe17:5af5 with SMTP id d2e1a72fcca58-82d0db96d9emr2983355b3a.44.1775228022326; Fri, 03 Apr 2026 07:53:42 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.160.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9ca4efesm6301682b3a.61.2026.04.03.07.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 07:53:41 -0700 (PDT) From: "Mukesh Kumar Chaurasiya (IBM)" To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, aliceryhl@google.com, rostedt@goodmis.org, ardb@kernel.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Cc: "Mukesh Kumar Chaurasiya (IBM)" Subject: [PATCH V8 2/4] powerpc/jump_label: adjust inline asm to be consistent Date: Fri, 3 Apr 2026 20:23:06 +0530 Message-ID: <20260403145308.1042622-3-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403145308.1042622-1-mkchauras@gmail.com> References: <20260403145308.1042622-1-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added support for a new macro ARCH_STATIC_BRANCH_ASM in powerpc to avoid duplication of inline asm between C and Rust. This is inline with 'commit aecaf181651c ("jump_label: adjust inline asm to be cons= istent")' Co-developed-by: Madhavan Srinivasan Signed-off-by: Madhavan Srinivasan Reviewed-by: Alice Ryhl Reviewed-by: Christophe Leroy (CS GROUP) Reviewed-by: Gary Guo Link: https://github.com/Rust-for-Linux/linux/issues/105 Link: https://github.com/linuxppc/issues/issues/451 Signed-off-by: Mukesh Kumar Chaurasiya (IBM) --- arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/a= sm/jump_label.h index d4eaba459a0e..3016e9c8d6bc 100644 --- a/arch/powerpc/include/asm/jump_label.h +++ b/arch/powerpc/include/asm/jump_label.h @@ -15,14 +15,20 @@ #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG) #define JUMP_LABEL_NOP_SIZE 4 =20 +#define JUMP_TABLE_ENTRY(key, label) \ + ".pushsection __jump_table, \"aw\" \n\t" \ + ".long 1b - ., " label " - . \n\t" \ + JUMP_ENTRY_TYPE key " - . \n\t" \ + ".popsection \n\t" + +#define ARCH_STATIC_BRANCH_ASM(key, label) \ + "1: nop \n\t" \ + JUMP_TABLE_ENTRY(key, label) + static __always_inline bool arch_static_branch(struct static_key *key, boo= l branch) { - asm goto("1:\n\t" - "nop # arch_static_branch\n\t" - ".pushsection __jump_table, \"aw\"\n\t" - ".long 1b - ., %l[l_yes] - .\n\t" - JUMP_ENTRY_TYPE "%c0 - .\n\t" - ".popsection \n\t" + asm goto( + ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]") : : "i" (&((char *)key)[branch]) : : l_yes); =20 return false; @@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(stru= ct static_key *key, bool { asm goto("1:\n\t" "b %l[l_yes] # arch_static_branch_jump\n\t" - ".pushsection __jump_table, \"aw\"\n\t" - ".long 1b - ., %l[l_yes] - .\n\t" - JUMP_ENTRY_TYPE "%c0 - .\n\t" - ".popsection \n\t" + JUMP_TABLE_ENTRY("%c0", "%l[l_yes]") : : "i" (&((char *)key)[branch]) : : l_yes); =20 return false; --=20 2.53.0 From nobody Sat Apr 4 04:43:38 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B88CE374730 for ; Fri, 3 Apr 2026 14:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228035; cv=none; b=nbGib2A3dyP99gl3lqHoFhxyj/QNJL8+QqJuh01eSK0WGXwlusJYbBnRy7smKrM6n0qrKOXv6EXaNuz+SJ6bzeFcjMv7m8xoDui6IJrzirkC3kCPF6XyzeQMj/MyNWELYsD2UCBz2lQndzE7hhoSKG9jtF9LlbSZencHL2k8a8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228035; c=relaxed/simple; bh=gAH5/sosVHs04ukM5lyiU/gDdyJ8q4IPrDsf9t768/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GfR5F4yaMWGa15/r5Ja6LlCFNppXApm/8QRc//Z8U+hWpv5k2M4QMJ9i9DLXBzMvqZx84wTYfXEBgE+96/Q5PEIHCITfv7L9wjEfvxCIz4UnHjgWXXvE+mg9CW3733WsAHD22u5vGz73/S2qYavVb7BGVKiSLFdkXJLxDaKuhRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ECqK1S3t; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ECqK1S3t" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-82cd98be655so1356578b3a.0 for ; Fri, 03 Apr 2026 07:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775228032; x=1775832832; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mk/c1eJYvsg8D8dqxhQYhJf46vVg1VoFShzT3q2jtfA=; b=ECqK1S3tfqmVd3uyAnjMTZKqK/c1Ww/9d6gEgKtrcmSf3KtVIcY8JYZ5nvSZI1cApG T5ORYYrTZ/s9lRr/Y0otSoNmbr9ZoP080BvbdRUgXkeqqMhe99muOk9d+BEKUHhUoW03 FcId0qozZbcEPk0d/CWpPNY0puj4UJCSfFz7KTma21/e/eNIdDQVC3MCJl/2HleLHeBd sUzim2N63oWv02WiCvC38a24ZL3wMehcyHPxtPuAb78sNfI1HTedWP0icduLhxNeYrTT uZ7cWAtZwvxuImjlQ2CQKksf+JCtXas1+mqYmp3ABuXzomOcHri1MKWWcxlcGrGkCl3x n8Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775228032; x=1775832832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mk/c1eJYvsg8D8dqxhQYhJf46vVg1VoFShzT3q2jtfA=; b=XcMlCtE6tLrFjyqWfMHBpICO4W6w0G8kzZkNTBjHhirJ323e2MaB660idIcTyGD3ve Tem2FZJarHkKaHL8xMT3Xsb0aNup2Yo1yNY2TAH2/z5e28LBBS/AgXpSAKCiNts5zT1+ RFeKE4anbthsuEs8W5E0SF9wWIfRoMezBXDM3LG2Em4AIVLLnw2gw0WdqOik22vrTuiw LBgPwzMoEFYJRkviMYBigOygnfEO6Of4V5V5UvMjXdLLWUy9BiIZ2K4NLoxa4jZFujlz HsecFyKMefSWCEJXIAvgTOX4PhJk4wcXxIExEnY0iFCYJnpKd0Yc+CtTNV9wFAYh0Lyz C+zw== X-Forwarded-Encrypted: i=1; AJvYcCUgHapacbpkeCeYRN4PLwyYCdJ+6TwwiDTm0PbPsMa6L1n21AJlISn6wvFvumRZQgSMXYSt0sngFkjXKOw=@vger.kernel.org X-Gm-Message-State: AOJu0YwxsB1ty7n4YsqUC8rPhoDYhhdNwKPwtYNgf7Vwv5bWvJp+hOiY JU53kEkm0QE9ZyqcHK6gADgjKqruawEOghFTvL5gzhDsXQQdJbeVEmOm X-Gm-Gg: AeBDietq5kkIJPisTt69iQDKnHuh6TX8dxbobt/yl6LnGW2wmGiaLQ4ijMKotU4/ARL j/XgJZjyp/jd7d95Zmjq/4ejJWP1qLeRSI0PonBstNc0y91llEyyrJ5SQUdsN6cnftEhN86NV95 /+z3QPP47XyOqcSU1DGZQCY5GGNq66pTzZttU7zM2NxlbRtASEK9k70Q0zgmwZZldSyw2fa1yy4 g4huR3/U35JWnPKSbeKBrG2yXc6LNbAhlJWM/dkAWL7sWgqGKU1cJnCDSKYgo+oEp7Aru2cyzJe 1Xv2JJN0d8BR2HMkNFgPqa3yJ82uf/akUF/aUCtmCQcKt28zqskc8+C4lqyjteQ0iQOwAiwh4JV KVue3hInZH7Ajs8c8AftZYAnKmCrrt4bIHYlmcWl4gwXLoZp1cfhhsWAWr/KqrXPzgFsr023UeA c3NkQxuved8ApRjNiZjNjTk10Hz4lOuonrm+xLbHXi3T62+EKLx+x+dCnSJ4qXsl94qkWYHyggj dA= X-Received: by 2002:a05:6a00:f93:b0:824:a635:4181 with SMTP id d2e1a72fcca58-82d0da84bafmr3123650b3a.15.1775228031997; Fri, 03 Apr 2026 07:53:51 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.160.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9ca4efesm6301682b3a.61.2026.04.03.07.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 07:53:51 -0700 (PDT) From: "Mukesh Kumar Chaurasiya (IBM)" To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, aliceryhl@google.com, rostedt@goodmis.org, ardb@kernel.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Cc: Link Mauve , "Mukesh Kumar Chaurasiya (IBM)" Subject: [PATCH V8 3/4] rust: Add PowerPC support Date: Fri, 3 Apr 2026 20:23:07 +0530 Message-ID: <20260403145308.1042622-4-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403145308.1042622-1-mkchauras@gmail.com> References: <20260403145308.1042622-1-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Link Mauve For now only Big Endian 32-bit PowerPC is supported, as that is the only hardware I have. This has been tested on the Nintendo Wii so far, but I plan on also using it on the GameCube, Wii U and Apple G4. These changes aren=E2=80=99t the only ones required to get the kernel to co= mpile and link on PowerPC, libcore will also have to be changed to not use integer division to format u64, u128 and core::time::Duration, otherwise __udivdi3() and __umoddi3() will have to be added. I have tested this change by replacing the three implementations with unimplemented!() and it linked just fine. Signed-off-by: Link Mauve Link: https://github.com/Rust-for-Linux/linux/issues/105 Link: https://github.com/linuxppc/issues/issues/451 Signed-off-by: Mukesh Kumar Chaurasiya (IBM) --- arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 2 ++ rust/Makefile | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 10240cb80904..1246b3add8ff 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -284,6 +284,7 @@ config PPC select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RSEQ + select HAVE_RUST if PPC32 select HAVE_SAMPLE_FTRACE_DIRECT if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if HAVE_DYNAMIC_FTRACE_WITH_DIRECT= _CALLS select HAVE_SETUP_PER_CPU_AREA if PPC64 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index a58b1029592c..589613eaa5dc 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -61,6 +61,8 @@ else KBUILD_LDFLAGS_MODULE +=3D $(objtree)/arch/powerpc/lib/crtsavres.o endif =20 +KBUILD_RUSTFLAGS +=3D --target=3Dpowerpc-unknown-linux-gnu + ifdef CONFIG_CPU_LITTLE_ENDIAN KBUILD_CPPFLAGS +=3D -mlittle-endian KBUILD_LDFLAGS +=3D -EL diff --git a/rust/Makefile b/rust/Makefile index 762bddc868e4..d05e76df15a8 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -413,13 +413,15 @@ bindgen_skip_c_flags :=3D -mno-fp-ret-in-387 -mprefer= red-stack-boundary=3D% \ -fstrict-flex-arrays=3D% -fmin-function-alignment=3D% \ -fzero-init-padding-bits=3D% -mno-fdpic \ -fdiagnostics-show-context -fdiagnostics-show-context=3D% \ - --param=3D% --param asan-% -fno-isolate-erroneous-paths-dereference + --param=3D% --param asan-% -fno-isolate-erroneous-paths-dereference \ + -ffixed-r2 -mmultiple -mno-readonly-in-sdata =20 # Derived from `scripts/Makefile.clang`. BINDGEN_TARGET_x86 :=3D x86_64-linux-gnu BINDGEN_TARGET_arm64 :=3D aarch64-linux-gnu BINDGEN_TARGET_arm :=3D arm-linux-gnueabi BINDGEN_TARGET_loongarch :=3D loongarch64-linux-gnusf +BINDGEN_TARGET_powerpc :=3D powerpc-linux-gnu BINDGEN_TARGET_um :=3D $(BINDGEN_TARGET_$(SUBARCH)) BINDGEN_TARGET :=3D $(BINDGEN_TARGET_$(SRCARCH)) =20 --=20 2.53.0 From nobody Sat Apr 4 04:43:38 2026 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C96733BD243 for ; Fri, 3 Apr 2026 14:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228044; cv=none; b=oCLSnaU1+aSt74Be8Hv8YcQvc5IRu7FEcI2GWhYMhptiu5X4M1UaKRydBYRDCSC3bz+hkadREA17GAM2aHdbusWo9u4IV/4HsoWPdHgBsNC8ud9O34iS6B5tzZR90kFXhN1IhaIRilLU9Msv/wJpA2t2E2OlHY0n2LwtNOYYjkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775228044; c=relaxed/simple; bh=NGYv3H0EXTwhJvQQa1DncgXYejzSc622oLZjrI5r7nk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PVZzDSgQY8eRF7MLjCKRXmKkx+YNhqJCQqh0ykI1OrHS5Dpo2nT5jwM6WXq60nNkjO2B/JOm6Zn2rUvVLvsBTVOFIxhOeMnVxz1h51o8pqGO+rTCz553uepF1S5ebSG54t74YzSozIflciCCXsdYU3dpoHLzNVtoTceoLmkiu50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OBKy54Dn; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OBKy54Dn" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-c766a95a72dso1172080a12.1 for ; Fri, 03 Apr 2026 07:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775228042; x=1775832842; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L5MnNEuF4jTrufZ1xjxpgz9Hp8B6c1d2sPYeGOGoVeo=; b=OBKy54DnLFCls2YqSEwGHFIGw+3UH7f7RVQBPwayHrU9fezLjDAFgJropWOcpgxKpE SRUoF1R9NqU3PVd6JlcFDnncH9Rz/nUgup763RiXJyOkY7ezi6Hz9k2HZi/tNQuaehMR 3vJTcPkWuuz99ISKGP+PSIewbU4kAMS+t5KKytA8Eyqg8tY8LCyAC2D2ofD+ksVqdkHM zHy74RRgV3j+p1TQmrZODUdFC/EqZiZ3D8EL6F95Pb3xabzyhMHnMnEBwonV+jdZAU1j 3NCuBEy+QlzHilFjU55ix8tCQST/cruM8k59jFshxyqa3/IzN/Ytspsvrauv/xkB2SPr gPGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775228042; x=1775832842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=L5MnNEuF4jTrufZ1xjxpgz9Hp8B6c1d2sPYeGOGoVeo=; b=CrExqbhv+nRcI49fvNjMVrPaemR7bGigcMnzg2L0kKG4w95gu4agvacWqqKEc4Rp16 qpg0+O9mRNGsQY2IerKV6B+PiYp+skpcBP+/ImnusRzAtUqBp+ltHxtKSGtI5YW2XOr6 /nh7IJXDzT3ehDep1KZUOLqmPUOzYGCq4w5U/7BsJ/yIjWVSrPAZOOumKKkgqvbULwPd cSPFcV+qj5oYm82bNsJ6EZ3eY+Fh5zMynIL3UKExyoFaYVFSLD5vmDhTC/kFOPOzHeXi M49ZDryH4Z+ecT2lHB6DUJMfUlsAgOYjh31zmG+cQnhK3zSZEwmDGAuygUSwSyjPjkmE Vt6w== X-Forwarded-Encrypted: i=1; AJvYcCVcxLkPpyQgK8O/j8N6imDvnmosQKxIN2CnmhaNhpcHFRlbNCCe7BKWxmiKWetvhblq6Hub36W/cKy5aWM=@vger.kernel.org X-Gm-Message-State: AOJu0Yzg61NCOCkbJSO0GxaDXTf182ISYBSvYnQuYL2jV1KDYelhr4f7 1zk4JQ9kSYpIwxuf0iVc+n4p59CU4+tjkPko/4by0gzIeBHLZz2+UVOf X-Gm-Gg: ATEYQzyxZmAg3WiBN6in011O9Zu1AlZx4Ht0KZJ/La/Ojp8tS4nc+0fpOgR/DE7HJp0 c5LA1H1mBsAHsDxSC48WT3vp7KgoCZdBivdmk/dTe7oEMZY0lPaVDGG/YWbS1d1dCjW+HesflUz reLLJfM2nlDZhlSM6QOFM0qFkIiZoiAzzJAP7L+BtCnlkcoCB4eLfqZFx08zJy7p8TEkR3cwrJE 7EJDDirxLIn+4V+1pV2/svnhnvN2g48gKGo803VEoYujFknhtOzGVwO+JE2RmE9KYR2Uo3KS2PD vVNXXMMjCZarHPJNDvUquL6i+JcWZo4Vm5NgfE9cCVK7hzboYmFGojNk1dJDcH5WKRIcTovL/Zt qIxglmeHflpN5tWdXAY31NcRJpqCPvVzrYtlE7zTMh5uYBr2bzLWz5z2MPXqXD6hDhXrGlNAT7g hcjopRP/sM2xcv3m0aeYn78b4En4RJDqFWPonXww+kwlSsbkjihZWqG9Fh50QDZM5UI1h3BbKtB hg= X-Received: by 2002:a05:6a20:12cd:b0:398:a1ca:7a2a with SMTP id adf61e73a8af0-39f2f0ff7d9mr3381106637.48.1775228042226; Fri, 03 Apr 2026 07:54:02 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.160.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9ca4efesm6301682b3a.61.2026.04.03.07.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 07:54:01 -0700 (PDT) From: "Mukesh Kumar Chaurasiya (IBM)" To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, aliceryhl@google.com, rostedt@goodmis.org, ardb@kernel.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Cc: "Mukesh Kumar Chaurasiya (IBM)" , Link Mauve , Venkat Rao Bagalkote Subject: [PATCH V8 4/4] powerpc: Enable Rust for ppc64le Date: Fri, 3 Apr 2026 20:23:08 +0530 Message-ID: <20260403145308.1042622-5-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403145308.1042622-1-mkchauras@gmail.com> References: <20260403145308.1042622-1-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Enabling rust support for ppc64le. Tested on pseries Power11: =E2=95=B0=E2=94=80=E2=9D=AF dmesg | grep rust [ 0.225728] Initialise system trusted keyrings [ 0.270961] rust_minimal: Rust minimal sample (init) [ 0.270968] rust_minimal: Am I built-in? true [ 0.270974] rust_minimal: test_parameter: 1 [ 0.270983] rust_misc_device: Initialising Rust Misc Device Sample [ 0.271012] rust_print: Rust printing macros sample (init) [ 0.271019] rust_print: Emergency message (level 0) without args [ 0.271023] rust_print: Alert message (level 1) without args [ 0.271026] rust_print: Critical message (level 2) without args [ 0.271030] rust_print: Error message (level 3) without args [ 0.271033] rust_print: Warning message (level 4) without args [ 0.271037] rust_print: Notice message (level 5) without args [ 0.271040] rust_print: Info message (level 6) without args [ 0.271043] rust_print: A line that is continued without args [ 0.271054] rust_print: Emergency message (level 0) with args [ 0.271064] rust_print: Alert message (level 1) with args [ 0.271072] rust_print: Critical message (level 2) with args [ 0.271077] rust_print: Error message (level 3) with args [ 0.271083] rust_print: Warning message (level 4) with args [ 0.271091] rust_print: Notice message (level 5) with args [ 0.271097] rust_print: Info message (level 6) with args [ 0.271102] rust_print: A line that is continued with args [ 0.271110] rust_print: 1 [ 0.271113] rust_print: "hello, world" [ 0.271121] rust_print: [samples/rust/rust_print_main.rs:35:5] c =3D "he= llo, world" [ 0.271129] rust_print: Arc says 42 [ 0.271130] rust_print: Arc says hello, world [ 0.271136] rust_print: "hello, world" [ 0.271198] usbcore: registered new interface driver rust_driver_usb [ 0.271207] rust_faux_driver: Initialising Rust Faux Device Sample [ 0.271227] faux_driver rust-faux-sample-device: Hello from faux device! [ 0.271297] rust_configfs: Rust configfs sample (init) Reviewed-by: Link Mauve Tested-by: Link Mauve Reviewed-by: Christophe Leroy (CS GROUP) Tested-by: Venkat Rao Bagalkote Link: https://github.com/Rust-for-Linux/linux/issues/105 Link: https://github.com/linuxppc/issues/issues/451 Signed-off-by: Mukesh Kumar Chaurasiya (IBM) --- arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 7 ++++++- rust/Makefile | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1246b3add8ff..a5f50434daf3 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -285,6 +285,7 @@ config PPC select HAVE_RELIABLE_STACKTRACE select HAVE_RSEQ select HAVE_RUST if PPC32 + select HAVE_RUST if PPC64 && CPU_LITTLE_ENDIAN select HAVE_SAMPLE_FTRACE_DIRECT if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if HAVE_DYNAMIC_FTRACE_WITH_DIRECT= _CALLS select HAVE_SETUP_PER_CPU_AREA if PPC64 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 589613eaa5dc..9385db478c59 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -61,7 +61,12 @@ else KBUILD_LDFLAGS_MODULE +=3D $(objtree)/arch/powerpc/lib/crtsavres.o endif =20 -KBUILD_RUSTFLAGS +=3D --target=3Dpowerpc-unknown-linux-gnu +ifdef CONFIG_PPC64 +KBUILD_RUSTFLAGS +=3D --target=3Dpowerpc64le-unknown-linux-gnu +KBUILD_RUSTFLAGS +=3D -Ctarget-feature=3D-mma,-vsx,-hard-float,-altivec +else +KBUILD_RUSTFLAGS +=3D --target=3Dpowerpc-unknown-linux-gnu +endif =20 ifdef CONFIG_CPU_LITTLE_ENDIAN KBUILD_CPPFLAGS +=3D -mlittle-endian diff --git a/rust/Makefile b/rust/Makefile index d05e76df15a8..321b7d0e15c7 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -421,7 +421,13 @@ BINDGEN_TARGET_x86 :=3D x86_64-linux-gnu BINDGEN_TARGET_arm64 :=3D aarch64-linux-gnu BINDGEN_TARGET_arm :=3D arm-linux-gnueabi BINDGEN_TARGET_loongarch :=3D loongarch64-linux-gnusf + +ifdef CONFIG_PPC64 +BINDGEN_TARGET_powerpc :=3D powerpc64le-linux-gnu +else BINDGEN_TARGET_powerpc :=3D powerpc-linux-gnu +endif + BINDGEN_TARGET_um :=3D $(BINDGEN_TARGET_$(SUBARCH)) BINDGEN_TARGET :=3D $(BINDGEN_TARGET_$(SRCARCH)) =20 --=20 2.53.0