diff --git a/meta/classes-recipe/kernel-yocto-rust.bbclass b/meta/classes-recipe/kernel-yocto-rust.bbclass
index 49f2bfc1ae..3f9b2ef6ee 100644
--- a/meta/classes-recipe/kernel-yocto-rust.bbclass
+++ b/meta/classes-recipe/kernel-yocto-rust.bbclass
@@ -25,3 +25,19 @@ do_kernel_configme:append () {
 # More details in: https://lists.openembedded.org/g/openembedded-core/message/229336
 # Disable ccache for kernel build if kernel rust support is enabled to workaround this.
 CCACHE_DISABLE ?= "1"
+
+# Rust support in the kernel on riscv64 only works with the LLVM/Clang
+# toolchain, not gcc:
+# https://docs.kernel.org/rust/arch-support.html
+#
+python () {
+    if d.getVar('TARGET_ARCH') == 'riscv64' and d.getVar('TOOLCHAIN') != 'clang':
+        bb.fatal("Rust support in the kernel on riscv64 requires the clang toolchain, " \
+                 "but TOOLCHAIN is set to '%s'. Set TOOLCHAIN:riscv64 = \"clang\" in kernel recipe (or)" \
+                 "set TOOLCHAIN:pn-linux-yocto = \"clang\" in local.conf to build a riscv64 kernel with rust enabled. "\
+                 "see https://docs.kernel.org/rust/arch-support.html for details." % d.getVar('TOOLCHAIN'))
+}
+
+# lld is required when building the kernel with clang.
+DEPENDS:append:riscv64 = " lld-native"
+RUST_KERNEL_TASK_DEPENDS:append:riscv64 = " lld-native:do_populate_sysroot"
