From nobody Wed Jun 17 01:50:58 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.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 2392B29BDB4 for ; Tue, 21 Apr 2026 12:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773422; cv=none; b=isRRWY3GUDEMsN70ScMUweYA3ws0CWpM+DooaLj4zabr7xz+c94/L4pPXbOhEOAm66HrprjA5+WpWcP1Vdfh+vV2MBM6/hsBE2JPo492DVHBtz5EBrZHovZL2P1W762XX7/bSbctc870lUUSkOog/M5DHSbOEsv33LkTQa1u+PY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773422; c=relaxed/simple; bh=DaJD+iC/4t/zDn6B6rcfGqjo/dCgt4gKeEwY5aGTxec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dhxLtQegRsQUazr0TyYxCFdYvFWdFSzHA2qlYFh/wtfCu7BrrmF4fvQ2v7jBRMB1tTWKbxcheoD2wjQhh0manpp+uyLlfCX4jcPWNRX1Ws5NezpyfvvnhozKJQzU1+f/1s1bz9zQpA2kD3W1jxImyBJnxUzPds+HO9sYlrjWuPU= 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=CkO4yhzT; arc=none smtp.client-ip=209.85.215.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="CkO4yhzT" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-c70e27e2b74so1483436a12.0 for ; Tue, 21 Apr 2026 05:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776773420; x=1777378220; 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=avSEhYLX24df+mZ+6wWnK3u2AMb0siNB32CpS+CSjqU=; b=CkO4yhzTX50hVDkPnvC3Ik3OFpfQ4jk9q/plh2//OG9sISogFR416S2g49W39AN8FU NBo4A2/njOvPIjeNABOfYlruMi9LaAU5sFTWS/PT3HARtrUw9CkjvYdmkqslJxblNAYS Lqv6r+UIcqY+ygSdQay5uiB+FtYlaZ2VZd6j5CE5lqTp8yH9siDEfUD7tRuMmKkGSU49 Hr9GFy4yJK28BtkxfUjvSjNtU5FN0cnnN8z7beUo6KMeRrUy/cP36WprgQGQeMp7EKAo OGfwgKQG7KvJm8iDv4PdULhEW2p+ecA2yPV9M46pbnLytBaVska0BqEKSg2pB4DJGBxh i8+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776773420; x=1777378220; 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=avSEhYLX24df+mZ+6wWnK3u2AMb0siNB32CpS+CSjqU=; b=QGzvtrDEz7aMSYKbTPhteVcKuvADVg3OQh5FpimjaAsou3BmmgxvMRC81MVaOdAkcv fBhmS4V9S0ReG4DwLuqbCDoqiunbxPNU4LdTomVLkPratMLJKVgtaz07TdcIFSTRtF8m 31tDGgqicI3tnqrnaUm9ri5m1jW2DcAO8P0l78OmkSz8sIRXv2a0c9AztUMQ08qyP59t w8j2Z2ccMjoYCq9p8MRI8gsLH04HVtwUJB+ou7Ovhft7RoSBPNx7gTMDQkBsvYxTbmyb rtVvGsSiY5zYaK6ubdMrh7PN2+opPdvg8JXHnbSMYXYtEcpM56Qm8XrzyKYCX2BuGyJ4 /8KQ== X-Forwarded-Encrypted: i=1; AFNElJ+AcS3UF84/3EtqhWEZcTUEy1UlUlUXmLVmI/4uV4quVuFwmP3FM6RAMwPU5C84Gob5Y7Idvp6oR4j72oA=@vger.kernel.org X-Gm-Message-State: AOJu0Yzo/8GNQ7G+vVZ2TAq/XbROipwBnepprUgHNmKDMfQjx0f/4i0W j4E21u0DD0JaOqfeioTXzMCwvgyQdJsmyJ2ca3QTRvojBNKfD2EZP6zm X-Gm-Gg: AeBDievhrONEqeM+mdJ/OlGL2teQqr8cVO2Ca4phUOl0pwvnt2t25W430ALP18BJ7X2 ceH/xl2eQ7sDMT/GkY51YY/I2LYqsJoUXnXzK4sp7kPBETtsjXpOTdu5UYRKyfveE81vr0Xlp4w ItFQ5co1VC4R4w63JOnzry08HoOidodTfYoqEKRXrvlYpgSOz8EhTSSW8CPjJXuwHfh/oz16vXo StxsTqHj8Et3bZ7Q6I8kQcqiOQXZdldD245fbJbla6cdcqb04tFdoL6XZCQdeSBVVRtQfEYNTMK wS+09aXDu5Q3Z01/Dyk76J8tU3roSJQXKvrea1KNH5Rf6Ho70YhmiCUSBqiBtOvvdKovSG7XQ4m cRV5CnmG0DkQa4cfraYxI0Qb0sNbR/9EevJ5lDCGFpL/V6H51cU4/cPCQCeG/NkjqtTxf/qwiz0 DiX/bFDejhrwPGOwpiRW+/HWiCFk9D7fasQP1Y3J25vl2974FQFOXfxxGcBu1AA6rovdtW8J+sV yZgCNpeyPqwyqo= X-Received: by 2002:a05:6a20:7f8e:b0:3a2:d68d:9e79 with SMTP id adf61e73a8af0-3a2d68dd14emr7145641637.41.1776773420280; Tue, 21 Apr 2026 05:10:20 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797701d9bfsm10045274a12.16.2026.04.21.05.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 05:10:19 -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 V12 1/4] rust: Fix "multiple candidates for rmeta dependency core" error Date: Tue, 21 Apr 2026 17:39:55 +0530 Message-ID: <20260421120958.190430-2-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421120958.190430-1-mkchauras@gmail.com> References: <20260421120958.190430-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 for powerpc64le with LLVM=3D1 and -j1, rustc encounters 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 occurs because the build system uses `-L$(objtree)/rust` for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains 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 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 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`. 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 | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index b361bfedfdf0..2a5428a5503d 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 @@ -31,7 +34,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 @@ -146,7 +149,7 @@ quiet_cmd_rustdoc =3D RUSTDOC $(if $(rustdoc_host),H, )= $< cmd_rustdoc =3D \ OBJTREE=3D$(abspath $(objtree)) \ $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-scope=3D%,$(if $(rustd= oc_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-,,$@) \ @@ -231,6 +234,7 @@ rustdoc-pin_init_internal: $(src)/pin-init/internal/src= /lib.rs \ =20 rustdoc-pin_init: private rustdoc_host =3D yes rustdoc-pin_init: private rustc_target_flags =3D $(pin_init-flags) \ + --extern pin_init_internal=3D$(objtree)/$(obj)/$(libpin_init_internal_= name) \ --extern alloc --cfg feature=3D\"alloc\" rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \ rustdoc-macros FORCE @@ -520,23 +524,23 @@ quiet_cmd_rustc_procmacrolibrary =3D $(RUSTC_OR_CLIPP= Y_QUIET) PL $@ $(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) \ + --out-dir $(objtree)/$(obj)/host -\L$(objtree)/$(obj)/host \ --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) +$(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) +$(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 $@ @@ -545,20 +549,20 @@ quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET= ) P $@ -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 $< =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 Wed Jun 17 01:50:58 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 69CD93043B2 for ; Tue, 21 Apr 2026 12:10:29 +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=1776773430; cv=none; b=SrD4mVzvSXLvF+8NldwC7mcJ48Ato0GoYYl3TXZZ2hiT1xCBI2jbiN4puMFKI9oR64vXmHu9A4h9GqIqT52FUAl10uqAlJvqBa5VtyTBoWFVDe2B7uRzXM1nmbNin9KrLHkdw0++3e3s/nYvFmATk8zmbBPxqCkWce8hC1syrZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773430; c=relaxed/simple; bh=8WQ7jEq8bJBsdnlHGUXrbWXnXrrr5Xxc2+zvN+1cF+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mscngJ+UjRmfFMQ3TSu13Rnsla6wIgWO9iuoFZ9kLYN5Jy0AW4Yc2mZDqhJuWJ5qvPUXOGKBu8dxFLZfYU3W9AmdWhfbdL5VD/GybK2H6GqfFkvvkTCcfrB192mDZF72vBPUJy7PLccLtvRqlMRYdaja+oD6S9c6i9jk/pkOFHs= 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=JFdupLIW; 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="JFdupLIW" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-c795a47186bso1630075a12.0 for ; Tue, 21 Apr 2026 05:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776773429; x=1777378229; 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=JFdupLIW16gJN+Qgle5y0+KM68yGwV2Rlvra7AiqdZ+xX6oHFM1F1z5WmSK3qG1uzR ZVHoClhQb5r9JqzllgTMFG7um1B75wHp4ZBO8o/xz0XTzobte5NuFIbhUeZ+A65R9tBC 2/q8pVRvVwNPGpaTMmoedaJ796xaGQNBE1aTsevpiEs9Pc9meZmC5Afrd2/bSN1Go65V K+VvkbtHJJNrwiOMb80n/bdveCnyi8b5vDkeLfyBXN6njyyE/zF1NFC6sI4hGynsY6Yp /F7lXmGlELPGAdasLZlKe9iu+gg9IWuoqAP8pu4nWF5bpEQOpK4mYGy4mPHnqKnRgka3 F7UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776773429; x=1777378229; 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=TFez6pNk//Vhiq8ofpBxQdIxgAmMe/0zGG0ILJjgYMzQMQWOGAWPZIS+N4elWJ8tTo +3OPgP4WZNKM50uGqIx+ugWCyMoPZSQFLaXWF2uT3wRE4WLIwsrlSLFWziuVKY3+XDrg DQF9lA9fvqfCgYZsuzdgJUZvhMiNutmF7W6jh2fojwfflwIuWsGuHY5Iz40rP4CdoAqC A9aoEkadfEyUlOA7xwCPBmNeSSXVa4dAMPO8zYx0xDxaj1ky/IffYSc/R5j4YFO+aXxI ltwFXHa595GNYhP4MDHtDCIgNKSM28JbdCYOZ3KtUUeL5eZI09dgPC2wf1BQdTwmcPSn tN+g== X-Forwarded-Encrypted: i=1; AFNElJ8ZDeCC0PKLZ+uVkPDcFksuSNel5OYpLFOqvB9ieO/L1vQDVLstx/Rof0H2qJaczD2wjghAROvM2d6R7n4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywkh4VadKIewqYduTWHTMkfbn7tLcTyO4YIGP7g2xbtrXTkE84r +v7v6nwqUOnFqFgU5ZPaJhZme5Zmc1M8mklms87PIxkqjujT5Cs5GcEG X-Gm-Gg: AeBDies0Z/8L2INZTnwCPclcF5WN+yrR1QJQG/qilb5ZMb76Zx30KF52MIRX4Tba3Vf nu6ZUkRAKeePNfR/G+kG1AvWzHEfqiFwBV/UbK/GOb6XRnJEXGyNP7MeJKBmpxp/C492Nt5gKsa q96QAUCzkVEdv7BgiE7xWHOMeueZ76+XG7V770iSjr7mhPdcuRki6/DD1ksPwRgG50R+CrclRRT 2jSrhY7lfBMzpvxsGfZJCY5M3IAHVrrEB3T+2qKX87RlbmyFVh/nJ9ztJO3P21MydmIE2PcAs0+ Pbf51zea6dIRqlHdDIiG8CPPPPs3iKXkpwkKFaFlkOyd+1zXhK/Ey5zDdqVjWigHpl6Unos+k0n eB0zxejRVU0V+kHQf3wXZ7kc2XyahZ221D4KHsGpv1EcObphnzv2hyIY1KGVFT+1SAmMj7gZw7a gVBeYjB6GbrkVoP1yrIIUPd1uSUhxKpa0Tv3T0pP/enp6kpuHMcR3nz5YCa6rf4nHhw7jUmGqN8 rAtUOs4kfWXWXYt8xoFSDtr4Q== X-Received: by 2002:a05:6a20:6a10:b0:3a2:edff:296b with SMTP id adf61e73a8af0-3a2edff3a32mr1965327637.21.1776773428601; Tue, 21 Apr 2026 05:10:28 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797701d9bfsm10045274a12.16.2026.04.21.05.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 05:10:27 -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 V12 2/4] powerpc/jump_label: adjust inline asm to be consistent Date: Tue, 21 Apr 2026 17:39:56 +0530 Message-ID: <20260421120958.190430-3-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421120958.190430-1-mkchauras@gmail.com> References: <20260421120958.190430-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 Wed Jun 17 01:50:58 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 D7A9D3A3E66 for ; Tue, 21 Apr 2026 12:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773439; cv=none; b=t3KhHyte6ujXgjMrP5d89mujwrxj9xkkbs+/7lJ/EuhQOzupFFS9vambQsgqUOl1+4Lgb+KthPGmYsmBnfM1bg3EkvEBStx09pmE4uX0Z7g9sHmWoFoyrazFGR0DZPIqX3We/9wwxZyKlrKApt8bWBgryUUerP3pLZ6eU+q6LiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773439; c=relaxed/simple; bh=hGgphpE1DYmiUm/7ovOlTVs3V0qJFy1Wl3p3E1Kd9FE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N532gkcgJAmnf3hCCnRIIwjDph8YMR9rBUz4VvluJjm1oDeRFn9b1OIrxEuegB5COUiyFWrHzhLbo8CM+EktQy7U1pM4MNqRGKCu2z6luVevsmsyk/sX5sHGW1YPdGOtFdTlaT5PaTOE11pP0RRG2ruIzkmQJB7SowZLL7TvFLg= 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=XJzbJALT; arc=none smtp.client-ip=209.85.215.178 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="XJzbJALT" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c79467f124dso1495175a12.2 for ; Tue, 21 Apr 2026 05:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776773437; x=1777378237; 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=3BeysMzI6zwGD6joEXhhGssagLKkCvhT6RVRv5CKQ4U=; b=XJzbJALTGkjeGs2TdeeH3TR5P901WQEesPFA8Sg+iuwg6ITH8aDxR90n9Zxdo1qS91 eM2PVY9o9r7l/VkhqBtcnepN0Gxx23OXx7Lhb6Ual9oGe8CrxXQwtybbZi0sKm2kj0Dh F9zEcIofywqjLnidtrR3gc+WK+ZvI52ZEF9wk8uJ4a/7k002r1Tj0VaaS3OARTpNAnZp rsy1xCBTv/hiScyNompBpb7CK1E/JjLgnyKitLxtp6NNGTFLMBx3qcoxVdm3fV37ZauF jEIUt8cIuVFhne1N5RjW9iLuQL+b3P+ulUFDipNw5zuyNEsHBSeJQoEKKdgWzIETbd9v ee9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776773437; x=1777378237; 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=3BeysMzI6zwGD6joEXhhGssagLKkCvhT6RVRv5CKQ4U=; b=j5FEBjo7Mrk2E+07cRymTjE+U0woO1fbffdmn/BBuv+u6M8zdlvt/XNHu+/T8LbHbk TzYflmVbSoKQnIIoY0AAI6S/uQSbOK3bcqTOEBwAofAxNH+DcuFpZxuP2LOMO6KfalMy vpwM9Ul2+CBZrWKqPbUu39l15XTkCmmaBo1AdyyCYpdhQLCNM9XT0TSD2SjUp6MX3G3e Dt3S3WKj64mxA/+zTrMO4vNcFYBBZ3Inu/55unBonEkO+vtJ4TlXlMBmEPoMbxr3aeyo 046VLt5AAVODI+SKnfHM2E3GELK7v1GU8tv85ijPM4qCrGJMbIlrISKg3Y9s5es2mgwz HArg== X-Forwarded-Encrypted: i=1; AFNElJ+RP92oxaTseAoy/TeRZ0zt+J5BDOpP/eTh+hJHaDEH/83s+osHr5JAFLP0F/895KW3h0y0VExaxxJgFFs=@vger.kernel.org X-Gm-Message-State: AOJu0YwVVyfZzcxNPnZ24PlUEdo4WDDC0D5iOP6+j0oTGhFPwDMMXGjY iTcay1md7CrBbR/G7/QeyvUFuPEchT+mCAw9IjKcUP9aEK5BEvx5kGMd X-Gm-Gg: AeBDiesuDfkIr1gzrzu3wpQa+6DuRDxw5h27Kjl7VQ4nsRJ8fOPfCkYLj98E4ez7H3U R+QnGoNcsHi7rLeq301Axh9KBEPKG9qzEtcLXgVteJ2YgVad3hqzJxgeAbLr7LO0VAzRHZUVN5N D+cSTsXYirk0vy9iBcq0AqwMjRZOrUKKs1z+ISIWfKcwJ+LGski8wQ2+MfQZsJm1Ejek0tRkKus ZqZEHFslBKQGm0xYyvqwANmpS3+TbWKSg/rsWs6b/aOiwRH5OAp+brzDe9+0NBCEYl4wWgRNFH5 QpF3zz6X7imA5nBhSQjIFxzv36FayVVT3oxu4hWewRJAjcDTcNEe8RE9GT53GGpuZlE4JfIwtWL 3OZpuF5s8udCtTv0O+oTGXSCbKMNYu8omZnRzvpha43WANLuURZUPID6TgC7l8Qavob4Mji8brs fZNOnMKj8pNwy2kx1ubTY2f+SjUesrD2nikJxMZbymfGKs5iGLAzBsJGmyWdP9pr74/Rk73XvSc 2awK/9H0qsXZb4= X-Received: by 2002:a05:6a20:e211:b0:39c:783:e42b with SMTP id adf61e73a8af0-3a08d6eee6fmr19057917637.21.1776773436940; Tue, 21 Apr 2026 05:10:36 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797701d9bfsm10045274a12.16.2026.04.21.05.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 05:10:36 -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 V12 3/4] rust: Add PowerPC support Date: Tue, 21 Apr 2026 17:39:57 +0530 Message-ID: <20260421120958.190430-4-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421120958.190430-1-mkchauras@gmail.com> References: <20260421120958.190430-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 e93df95b79e7..4ac897b650d4 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -285,6 +285,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 2a5428a5503d..c90811a2f564 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -400,13 +400,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 Wed Jun 17 01:50:58 2026 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 B74CF3A16AB for ; Tue, 21 Apr 2026 12:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773447; cv=none; b=Ajn2IigyjkqcYRPmqKRAiHK+OS7jr3L255ic/WVHDFNPMOBnx4sD4/DnCdanZaJ2q/oYnUZaoD1wmiEz2DbEhkIoeTKEfXvT2EKE/yh5qiRGmQX/ZVbqancQj56F3NcM3ru1jDeQ8/3ZY+FpMgK7nayAKupEwSQh7Y2gsRdiH+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776773447; c=relaxed/simple; bh=/H5PcSrC2tQdEl6SKLI73OsGEYqK/u2LFa7CaU6S+YQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oZzHCDWsQWb39VBjoE0D4eCDwRJJyVMdlC5pOztIX9tXyGIZIUkTbUR9dysPJDY1+ch5oNVcawAqVEutzg/6xwL6a0gLbUlRtI4vyeOJ5Tarh1HFFWEw518sdcfOXeoi6n9lb4nyM3A/s/0202PjqHIGEhNYmBvOIklkdEwFLh4= 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=tFve1YoF; arc=none smtp.client-ip=209.85.215.182 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="tFve1YoF" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-c70f91776fcso1590446a12.0 for ; Tue, 21 Apr 2026 05:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776773446; x=1777378246; 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=pFBtEobc7yIaM1eVkOtXcJsieQCaSzPZbTXZ7JIsJxk=; b=tFve1YoF7llEb09aBotqgR5cE1JxRCx2wh1xPNNa1/rdc8CltFVdnqtN8HU2L/rYjE o5TkEIIg2tuRGq2Bce3PciXOM4Qw/5bYzrq23TpZrH/EJiamomRidxM1kuTC4QmyFH8l h0i262R/0/Xi1Bg2sUfc93MIdqP0lxNm/3hg1Pnb+Dd4BM+1oIDg0p6mKbMDsNH/BQm+ dvtuzZW3+UTfdeUv1KFxgMbtgAK3UAN8PulOIcpmqByr4qjNmlm7a6aLkUZJIhlcs6h0 4QXSnKUqXalwzSLJIlmF/1J4wvW1E5y+7mW3MgkZ3wdwXc1Cm8iTC8RRZi3v19+szUg8 wOag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776773446; x=1777378246; 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=pFBtEobc7yIaM1eVkOtXcJsieQCaSzPZbTXZ7JIsJxk=; b=PKPvU/VyOojnr3q/kDGYymvzDj3XZoXHqPlTSwTTBIfRlImuhLN+WIzVV6SZCpDOGI fXqE9ET/744T4B65rBBUfiDTl+vIw+3nHEyP3xLNnhUzBG0wC8mW36GOWaadF6xvVshF 8EVZG6+Ewrl6KJFRoWot2RPMvt8tXFI2u4/sKNfwxJOjM/jKbtMn7vehrnrU13fOaRvv +ephL3xzNbURTPJJv38G9N/JsCVJtSRNY2Uu8pTD/dewWtWXPYRzLrHoCbsWT1OcSfQ3 hjRoEiAVhsYkLkpB2ZhKHP+hXsX2JIvxAEY+gUnGt7FXkus4W4gbX+wDeMkdQMz0HqxG VhJw== X-Forwarded-Encrypted: i=1; AFNElJ/dtESEmFzhgYEctgslnYMi0Re/Qi/kufHQRcCAb0w1yFCRLXrMap10vwpgeisHtVRQglBtGlF6sBqe/m0=@vger.kernel.org X-Gm-Message-State: AOJu0YzA1Hlysp4IZWncNhK5fctkSbQcOEEdl+Ar4waIl0v3OAr9oRda 5I24MYVJjbv6Eg91FY5z7t+z099/JTBYBBeRCEAL+j7I85QYa8WfwymM X-Gm-Gg: AeBDiesPIYJ/2Sn+fqfVPtnN5Bu7YCCNfNjWSLMImIBSViZZC0uvL42es9V0P5+rvKp mCl+DFeC1b3I+xiGWJCy+L6iVDA4VzrRUmX5YwBxkwZQWMThWekLhtyLreuhSLAiDNqcajETaEZ HN08Rau2daw8w6DjYU55EG9RE7rf8hoWGP/sYWfVzG4xqaaEKwHLzyVEx9v4pziqIU1YshCw/1M ocSvIsEab0+j9QpZUdJENZXccbxdTTHU+yYQYdb9MPxF8eAYAbXsu/G5zfbQKVbdqBpLzHCGrrA N+NwkcyT+WrZsClobkuLfAV0WkTNpFMwWkZq6H7ZUhWKhDKVQuIhwsDaHHvGuYwtFyOyFeBw9E3 gGfYkXhO6/qNC3gJQYcbDvk7EYvv6jtz8CUO9YWTpWiWAJqSeZ0vcftOFAOV2XTCC8wbD4+zwX2 qaBubUypLNL/fIfgXaJ5zoW+PbHGKMa6XUD2rcDhg/lHLF47CsXm50+vpM+IB4wEmUTmWz/Ec6k QdtvbI8O/B0Ot4F/pqsQxEP0w== X-Received: by 2002:a05:6a20:918b:b0:3a0:b9d8:966 with SMTP id adf61e73a8af0-3a0b9d83334mr11249808637.55.1776773445911; Tue, 21 Apr 2026 05:10:45 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797701d9bfsm10045274a12.16.2026.04.21.05.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 05:10:45 -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 V12 4/4] powerpc: Enable Rust for ppc64le Date: Tue, 21 Apr 2026 17:39:58 +0530 Message-ID: <20260421120958.190430-5-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421120958.190430-1-mkchauras@gmail.com> References: <20260421120958.190430-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 4ac897b650d4..2e3065bce9cd 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -286,6 +286,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 c90811a2f564..846fe1a45056 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -408,7 +408,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