From nobody Sat Apr 18 06:54:43 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 A763C30C62E for ; Fri, 17 Apr 2026 15:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439418; cv=none; b=Y724wRNWPH5/vp89LTa5iciADY6pbUuAxedC7wNgEfG2XiR4Bm4P+nvwdfLjm0Jnc5/orlU/x4XA0zoziRoR9MTUAdrQYMR1jpAA2BgUp2oSGsGrPu0SIlzYNJra/3PmqovhBnTKKKg4Fp697sTeBGNtzL5ULi+BBvT9GfvpcTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439418; c=relaxed/simple; bh=5FTPUPuJVsTLpqcjhVFxeZpAV4lxrHWidC31zn6JrrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pj9UKqv3nDyhfz+ESYWvwvxIl7TG9pQBP3OwGcTUBkaf+a9ovnqZkHABricOp1UrZ2ijWSRwFCMDuNXi2wqYO5jM+Wh3AAtpObJtBnWKlUEYtdAobO2ilPZ+WGCGyTynsDKkigN8aXhy/xE6/9WLgzBJMNiaOZfT0Q56Fvf6WMc= 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=Fv/rrUYg; arc=none smtp.client-ip=209.85.210.177 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="Fv/rrUYg" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-827270d50d4so748442b3a.3 for ; Fri, 17 Apr 2026 08:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776439416; x=1777044216; 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=DwPvJVxOydbYWn8IiNW1x83FpaENNDbiz2YSZJBpMak=; b=Fv/rrUYgNeKe1DwbTmLKkpHrSInr6YhiqrwMfVttr3F1zkXqTYVYZWXfuI55Hp4SD4 als41gNqXR8Dt3s0jExp6BwiMYyVY8Y1iMp9ffy5b6KlNfgbGjRDbIH2sbpf1ZCJX3/X N1Gc0Z/w9nlx+baHqmqv9LofRGi3oR4oORxBaAL4Yw4DchaJ4WtHRcUBQBxrUPEYV0aw jUgPif2ykGjXuGQoVbC/GaNcGwuXyRL2/M5pcW1vNjz93qohjhiF3rG2kvwnVYjel69n XUtUOuoWRmV14BPilis2UAre9/fKNJSLOYRILMKMSttZBqRZ+hmul4fSceGixlRlSLIl fLxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776439416; x=1777044216; 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=DwPvJVxOydbYWn8IiNW1x83FpaENNDbiz2YSZJBpMak=; b=O259FKd0oaeOoh1VSfCtebKH0f1/v55bipvbEHRvS4Jk2hhWrSa3/ZtzZNVPY9+fRW rJZsTzq69g89blvngRbdvks6yuH1VdPtggAykSlGuzN/xYo9iv8hb+oCe8rcG6sDrq74 E5vcuUAq+bTmEdvNq2dGwvApyFQrYtONgzqm4wJ6hIygVjfwLTPQ9r9H5BsVB0DxvEsa pbkokQytVqR3aY/MoyzJwr3AmzgXk+BSdpQ5wNy4z20ZwxFwJ2kto1rSksgAxiZdBkqB URtY86uKKt6vWI2DomMOuv3lN3Bl80yjcIXne7aBdleAd0A81vjfU+deZAq+4/gaSDxU a+Zw== X-Forwarded-Encrypted: i=1; AFNElJ/cswph7rt+CsI1sYjK39U8oGUN8Au3KNOVEJlfa2GpTwEuj7+BcrI75xXe3MLm8UFiyXNpo2Eh4EkVn60=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9p1SSBwO3dRIp0bUJDNg9b/iN/ZKAQjbeYUfwI1wk0m43SauD db2gt5ccj9rsgneHChvn+sAQVkT0TpVqKWzFm7McLhhlWgBf9ElV1kQn X-Gm-Gg: AeBDiesGcVXAIex+5wk8nwI25Ou+axRZSC6sIA9ewLI5Hq/YoiwFGWDvKZK5FFbZvu5 AclRGEeIUeqcAHmQo0350xUjpZp46JBSX1tx14UidnZrcnxSJ6v1Baz0Ake9IzieGKWlohH1moj DQV+K6DqpU8cWN6pTtowRvq8QEL8ZTzDugna0Ryuf129v5fOfs4NVv/qGHeiwNFocO/gl4svNK2 lMJapnS1DOJz3JONP+IDgLIcLV9EYJpA9MNGLhqkG0fCP0BGr1Qt3Zf5M3nZiJ48vDDppWPxbgE UuBL47HQ9c5ahovO2CkA0Ylxpb57P3hGBozM+UnGe4Ct8KTM4RaQ7HlA2+Jt+X3+uUAxO8l/wtA M20E6eCEKLqoNubs5OdpJ97vWFgsvrnRaYGhn1lU6Z57HMnSPKeya3JD4uFzibqMI/b4RXFDRsq B1L2bRjpkeHU83MgcSFu9rhsRnKdp232nhVQI4t9tNTDMvm5vfx7at3JVsfPmJp9/a2848hF9E/ YR7kbOobyBzlnw= X-Received: by 2002:a05:6a00:4c86:b0:82f:7076:cf2b with SMTP id d2e1a72fcca58-82f8c90ba46mr3696324b3a.40.1776439415810; Fri, 17 Apr 2026 08:23:35 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.164.157]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebb3829sm2384373b3a.31.2026.04.17.08.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 08:23:35 -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 V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error Date: Fri, 17 Apr 2026 20:52:50 +0530 Message-ID: <20260417152253.2312961-2-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260417152253.2312961-1-mkchauras@gmail.com> References: <20260417152253.2312961-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 9801af2e1e02..e234b8a39358 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-,,$@) \ @@ -237,6 +240,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 @@ -528,23 +532,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 $@ @@ -553,20 +557,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 Sat Apr 18 06:54:43 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 2B4163101B6 for ; Fri, 17 Apr 2026 15:23:46 +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=1776439427; cv=none; b=mTLW0OIL1KBfuZBpaLfwAbfvd5bZ5K/22mxF+RCrc5O/elqmtd8zC30v7pBtY+AkASa8HETv6HndFNTmEeh7LqVLSY6+hETniL3zXuEa9v3Mgdv2D3RViy8sayn6qetEwL8009UpnBBjoKdf5+W84S+aOZfow1Y/9DyOSoqXNkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439427; c=relaxed/simple; bh=8WQ7jEq8bJBsdnlHGUXrbWXnXrrr5Xxc2+zvN+1cF+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KnDLecAxAqlQObNht2qkcdnYreQsUD5W2WtuaEvYUNjSxLa0r6tP8L2bVEZJAbx/zGrByOCgxF4FhUKAiGxxsRSGcuPTXYciu+AgqVCznKVjeeDWI5sE8iIr/thS+zYK01VNETTGqwQddG/qRGk7qAE4LCotJxZAF1/Tg89Pd5M= 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=TbZaUz6H; 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="TbZaUz6H" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c79467f128cso327322a12.3 for ; Fri, 17 Apr 2026 08:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776439425; x=1777044225; 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=TbZaUz6H3O0m1xGl8hvdU7eggKnjETDRAEDLN00BZJUQhNLHWTFzuGEQxUOBPJR+iy 8ql+hs9AbQ/6YIgQbRmsvxHc+p+1onywT+nXUJCsPPxRxPlip9lbBc/RhlG1GhVYyW20 8UDkgiVI7FZMkc59JnZHRqGJe8krinhFVGh881gzh7Ag9sMH+iidJz/7NZXe5JGrvjmv ItkvZvtBFTpkURuozeiSR5UV2tzJBg08Af8+B422FJscFZD3I5HCo+cOUpQtDxZG+m+A 923sGzYe6wVlCVOlL9ycg2AcUj8uJPCupYDPRlK4c4Mn0icCPsvPL8eA/zGNPRAVFTnX OtsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776439425; x=1777044225; 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=r46jxHbmgaSVJ6gM6wr1JGw1/OstIVnzcHM9GbaHEwFzq3nv4+jyBacWAasGiFBNHN keZbt4tXoDi7cy8yAUC3A8zcZquihopryIemGfFLHvT7Ou1RSDJmcP1yrrce2EfgKCbM q8nyoz2PBplaStX9GStEFm9ymZWaCT7LRFT6P174PkkZZZlewcjJtye6REh6dYh2dCha 48qktONE76zQ5Ln4sTh0RqcDpqJqe31vnNEdo8A9BapYgVLQLVJkDVGXV2GjCBdgXu59 rNcNePEAMQ8e1ALkS35b2QFHbx2LGP1OwDn86Y3SYT0n2jzxJP9OfpRtrG+XK93E0zZ4 Z41g== X-Forwarded-Encrypted: i=1; AFNElJ+jKOcHluPcEWkA92/uBbxb8TkjlsN6zvt0NCoLcPDPlqzGPGYtWhFLQpewB88mdptrPtsYVf7KFsAXw6I=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8CjaEhVpHvsFjPbhO0lQGkSdgChv49E4yI+ymEoTIvoZ/ZdE7 ZXkr4CVw8Kel7HmRhQ5XT3AGstKdhT7ulmuc61my9wojQ1Cfqp+Ci/gD X-Gm-Gg: AeBDietl6HRIaSsZLHBuHjnvx5eavXl9c5fkRKwrhOsNpnFokuo1kOTubTwAuCqvW9+ RnFyZA0Bt+c6XCIoKrIfbl26mcQ0wKrY6CMCdoeodB0n9PgGvBJu5fb2G2Tk4+gQl8MRD83cXVV yYirP1JF6V9k7gvvGkAqWoY9bhNDmCfBPNlT3wcCeXuJfMRGufcw6BJ1D7tIob1MsR20dp/VbqZ vbYAtL4ubf0BSyfLo0CjyPXio7aVINnsLbCqZGkq+g9uqaf+myzHS4AkNSs7zTpg4xszqwzdQjI 1yjoVwz2RPpbnfp9ucqsmjCTPa656SRbsB3HghXTRsM60jL9x2cth/rHZqK9FKU3taGG/eOBEwH TlwDiay6YjKrVOMVNQV8b2sXwtJAVsWK585VHtogEihpkXh0QS3fpVtKdt8K/FGveptI7FSrYrr +tg2y9mGgJGdd30ZaUo3YCPj1tBx15ARWs1yJLR8prwn8X+JnR137I8q/ViEF1Xia0Ls+3x1OZF 9/2tSTJB6mgIDY= X-Received: by 2002:a05:6a20:7491:b0:398:ac0d:9a06 with SMTP id adf61e73a8af0-3a08d933c68mr3614755637.55.1776439425364; Fri, 17 Apr 2026 08:23:45 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.164.157]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebb3829sm2384373b3a.31.2026.04.17.08.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 08:23: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)" Subject: [PATCH V11 2/4] powerpc/jump_label: adjust inline asm to be consistent Date: Fri, 17 Apr 2026 20:52:51 +0530 Message-ID: <20260417152253.2312961-3-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260417152253.2312961-1-mkchauras@gmail.com> References: <20260417152253.2312961-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 18 06:54:43 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 C73D422B8C5 for ; Fri, 17 Apr 2026 15:23:55 +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=1776439437; cv=none; b=pd+IcsP1a0v67CHR09blJmd/oomYp4lRV3cLsNAB1pI4q7VYu7ePGMW3R7e9jXKhSn0R/BUe0tG676CNelMUBeVTWw5Us5upd3dwU51clXz1bBtal58gms5X0XFp3KnH91hMvdC+4GpDSPPxemw+JUFioTny+vTfAgWxq/9t9D4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439437; c=relaxed/simple; bh=pYf+H/saGpsBMW8EFfQgaezWo01ragM5sMbBA4ndTm0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=adEI7UcWYsEaskRjfa0cMvrSN6PqKmStLSu/sKqamCMOhjwbo2Jhp/b0wtRU7qTuTzaMnw1jis326mfjaJ76nIcdYj0Vb7H1WvauZTyCQZPm3fkZUA7ex38N3EVxfBLtN7gk+CFsD4pfU64NLyF0hZCKzWjnpTdXB2WiyXTMkek= 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=EhhsbqFN; 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="EhhsbqFN" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82cd5c07f93so359416b3a.1 for ; Fri, 17 Apr 2026 08:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776439435; x=1777044235; 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=ww02/jkdVLSyp8HOStmgEIcppt5LBeLhIRfQtuTFtSY=; b=EhhsbqFNIFHbTGyusyCpLuG5uRbZgt8Ntan+nPEj9jBfPhSdn1mzPAbcaNX9YPXzwG gKa+LBHWpwedp2cp+e++7ImHdaCt6Trwq3D93b5N1e+vtlq/hd1x0h0zIkVxuZ/P4L54 4D/QFqQikhVbMZLHqxBIKNd7FqETm7OCGsH3s8+S27F0a67/9ZZnhcQRkCHgIIfvS1ns yw9R4EriPmS7tpdEdUG4uE7/DuXDYVB3ZFUP1OP5FnTsItTgo2Ow23/iIKNmqZBouyMg k94WODlcgD1puvTGHr8UwKjQrkwVOkuPxbBOAbsO1MlmK7oB/2AwKWw4siyrGq0+Qd+o U97A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776439435; x=1777044235; 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=ww02/jkdVLSyp8HOStmgEIcppt5LBeLhIRfQtuTFtSY=; b=D8oj0o0FP+mQDYAFqfjZhbobpy375TpjnCPUWVOEpnW6dFkQerGJlPJ7k1S3VYFVGW aexlPm2i+4NLvZHfKeuROWv9iQslmD84pauVULylbN6YnBpWFRj9C241lkp0MBNioJ/j 7y5ju5hFBX0m+eJBd625fKNXhboCzg3pVpkJBZG0ZNFIozDiOtc0fjI1ijMQZUEvMIPj zjJI4QO4YWBsZilcpFgtLrAxGb6lRawWuVOWxN3Y0KV6/fQR1Fqrs6XmMZwQb8EdtQZI U5qLoy6225gKPj55SyPlzppBi5zrRSRQ1BYiV9xWEnuEAObWCt7fsEGSA38M+uXUczaL HZlQ== X-Forwarded-Encrypted: i=1; AFNElJ8/Z6ZsoDB4v719JLytgea8NAawV64FBUh8hiUWLAw8o1K2ZG7rIT2SWQ0FGxgLCX4gbIKjasUnhqqHbEY=@vger.kernel.org X-Gm-Message-State: AOJu0YzcCcOFs6Blnt49F9BptTTeryi8bfnDqtD8qwYS1axwuacFTr2u LfohK10F+M+T8/0MS1VxIBMbCWXc/YMKR82HXr4CodAVh73TvbKZnj62 X-Gm-Gg: AeBDievkvjOlQ+vQd+8RD2KIyyx2gImKQc+J7N7a90ZLVaMgkD867f2YjVebudVv2Yu 3hIQASS32TdpVxeYLHi90FdpIG3lWnaJBG0wJg7QuPkx9bq/CrMPGfEBlTsNXq95frEhZH5wKgb 7NMWk16hZISslrpnMOdJqlhZmy3BuheIa1mdMsk37MhfsNYaizzs3ZPJosHtcdHaZbtWlTrRn/E BmuobpJMfKJ1REIIxHwBFosMTkxs0gWUbDnFhg108cysGe0fDhL4T/7ATKatUxMOW2ctLsWKewe 0tAOovo0477psnk3x/p6lrqQ6E5r3m7EaLbs5L1bYKkiLu6JR2P+LNUJPh644MKp1vDfDnkjjm2 9XrKIVd0fPM9wdFbAb1LRhk1viuOuNJMosYWuLtF614gPrI7DLoNW6g+XQ8b8KgwMktuKyF1rE9 M4tq70q0eI8YSc3k+tLjwf2USfajlMMb2uu0oMqFVlX3q0Y3u9huJdpXSifmCaCjBdqX25a4+fN OiyXP7GEWRsosU= X-Received: by 2002:a05:6a00:a883:b0:82c:e09b:3f76 with SMTP id d2e1a72fcca58-82f8c9b6728mr3532095b3a.41.1776439435073; Fri, 17 Apr 2026 08:23:55 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.164.157]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebb3829sm2384373b3a.31.2026.04.17.08.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 08:23:54 -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 V11 3/4] rust: Add PowerPC support Date: Fri, 17 Apr 2026 20:52:52 +0530 Message-ID: <20260417152253.2312961-4-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260417152253.2312961-1-mkchauras@gmail.com> References: <20260417152253.2312961-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 e234b8a39358..af0c8ab2e5b6 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -406,13 +406,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 18 06:54:43 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 2FAC130DECC for ; Fri, 17 Apr 2026 15:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439447; cv=none; b=arODFxSO+wMOaqOL5vYmQSpYD9UGy0EINyRpZhgJBrc+wqUAHk/PrsqLh0ysXkSGp0wBZ5PIPXJJw9IasrMrLIE1muz72hi2+GklG1s30U43ro9g3SYg7Pz9X0EtkH3b6aLfRiNOPRmqGLH9TM7ekw/lbm7yHfWh44hxtbXfIW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776439447; c=relaxed/simple; bh=KGTavH2N2h74JlTQWyY6Aj3TbwX/gCXKETtAzErZUN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Du29frsfaxsAHfHyAIdx4kS74BzjCQn1hAUdi0fsglW/SsybnHCw6vxU4Jdrhlajv0Zo1r5C4MU24ByzA4gL9OhIz6FSeerL6i9noFEp4DQP9bfnwIyjshQe/mTwrv7Q1OsiaPujYE524C7PCED7cZ/qCQ9+Wg7jIBTMCkxQhnE= 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=evfatWVN; arc=none smtp.client-ip=209.85.210.175 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="evfatWVN" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82f1f6103afso398106b3a.1 for ; Fri, 17 Apr 2026 08:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776439445; x=1777044245; 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=B58d6JHjS7h5Y5vjFZ6dbGJt4nx8a8vTRSygt806S6s=; b=evfatWVNJIwhCz3eoV9zYs9feh7z+15ry0DxqSb3dYhvNgytkgfq5lTqJzCLuHqQcD 8Aibbp7dPbJuHD0rgLAJM8iUAtLRdFvWbEeXEXXfi6VBkpMnXlxj5IW4avUiQfLrPCdh 2mpyXPQU47TrPK2FvYtE6Bo+YfE3bLf7eXgAQa3qJSdOGFNJrhWqIMNs2o0GeqPcixI+ 9kUzn7iw+4zOPkq6Q7cfpScbNzbkPZBknvEsPNrhDKEQTE7kMtNfIqRafk7c7GI982aN eOxJFajt7XsVsGSxBSHZn9Gt9B1smbEPh+GEYbHe2/7PNwDivyudIkwvSA/Uq/Mzvg7e Rw/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776439445; x=1777044245; 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=B58d6JHjS7h5Y5vjFZ6dbGJt4nx8a8vTRSygt806S6s=; b=poYZW4hibHGo/1Dh8rTRZ+7hNfVRaLh+9+w7u+4iZiXJpBqVNk0+VYBdbrzFBtcTei 4SX/AI4xSr3svzVSIcjDuduiBjfJl5RJspNKczWZ2Unt532Q2717Rq2XyF6qh/BmeT/l nprN7ATDiII1xWPl0HwigId1srgAqqbCO2+D8cRTwqWF0cvES+4icTXVgTtMu+/iS25A CVpK44PJQxj48UQzuR4fyIVMQ0dfe5Bjv51MAwW3UcCZEsmu6Nedr+iSbhWzdLHzo3FX 6ZtFPIHTyitBs9WtqFqZ9BgkLwMtbqcRzSUNPEI+XAAv287j+mTAgSGy+RE13pHMmsiz tYlw== X-Forwarded-Encrypted: i=1; AFNElJ9d1xx17DFAK4nkoiH1ttmwx4kICFSf6j4FFvLkg7HeFD9cIPVJquugqphQx5cNaJUB0qr7xR/i0clk+60=@vger.kernel.org X-Gm-Message-State: AOJu0YzWkUk6Q+lElwk38vfcvhOFigsYeZQhd+fWzzTFo5xErnNc25hi 2GBccmxB+97V0okYdabYr0aF+wL/B19HpNBp9SSypgfqze7ZZ0L2xX+7 X-Gm-Gg: AeBDies0SiDbD9v8RbrRAR2tw5bNM1IR2aEe/Xgc5RmkT1KcuP+ZGBvVY86dIGxQl3G PpQMU3BEPrS7YlCdn0mO8l081MiBZNUb39s35RlO/HDimak4XnfbEu0/WELrbmg36KiH1AyEolr Mnx1apENIKppFJO4ccM+wV58/lbZpj6X7K+U5ZdLwJ4hcnrK9rJ4f9c6HtXWkfkVd2NVTg9eFmi D8yrSlxrwahM7+i1BOx4cGehfwxl6GQU7cBMQ3Kqn5nB5QihmtgzzNddQbhC+WD87z+OXakUmb7 hRCd4AS5RiEfkB4Uai34L/lwNdEnq4zP4StP8+j7m+l6BeR+aALUMoVbTU0QXOmOFS0VWW+2QMO Z8xMOVBFwwcx3klu6lYJrZySh30zZ28fod1bPz+XJXM4CkHummzSD5R+FqG0aQEtrnSyKEiSEGN s6iGqtn9FzJ4hut5jFDMbruiI/5n3E3oyZTCUyoHZ0hjx7Qus1ErHacQBg0USwKYLbD7tTfOotw JB/7vgMiLKHENZvAIPbbwHokw== X-Received: by 2002:a05:6a00:984:b0:82f:6cd5:1ead with SMTP id d2e1a72fcca58-82f8c86b573mr3320740b3a.16.1776439445297; Fri, 17 Apr 2026 08:24:05 -0700 (PDT) Received: from li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com.com ([106.51.164.157]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebb3829sm2384373b3a.31.2026.04.17.08.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 08:24:05 -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 V11 4/4] powerpc: Enable Rust for ppc64le Date: Fri, 17 Apr 2026 20:52:53 +0530 Message-ID: <20260417152253.2312961-5-mkchauras@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260417152253.2312961-1-mkchauras@gmail.com> References: <20260417152253.2312961-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 af0c8ab2e5b6..99537c2c55ee 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -414,7 +414,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