Received: from flow-a5-smtp.messagingengine.com (flow-a5-smtp.messagingengine.com [103.168.172.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABD96272803 for ; Sat, 8 Aug 2026 02:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.140 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786155992; cv=none; b=g98R0Bz0UzJ2DxfC3yn4+yQnmCpA37/VPnStNmGVM3Jkc0Aw4rLknYkGlpwZmcpX6rk1aWTnLgEOBg+6+3PQEyx6fXAeL8UqbpwqrQclXQkmC98GTXMSSoW5vF2AvvZnJY41Ha50bKRGfAcGCOl4Dsu7TXhV5bKHb9PtN/EFqzU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786155992; c=relaxed/simple; bh=uZUVRju81i1lLcrtRlX7ovg5SJNieRe7e3zQsSTWsZc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HElOmfEH1O5u4EoDKng8K9WiAfzT3qBTEvugmzfUOBz0J/dBtsf2nqqcJf5qh6pGtCei2ixtxK2kyg5AvUA6iBikXuMkFvcebV5+DHxlPwCc2bD3OkuPO4HiZ5R4BckF4VHULOBKP48/RzrJ5ktmnJ20MqOBV65ArnoABU3Qcq0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org; spf=pass smtp.mailfrom=flapping.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b=Maz/y+Hd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bIsxOqwW; arc=none smtp.client-ip=103.168.172.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flapping.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b="Maz/y+Hd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bIsxOqwW" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.phl.internal (Postfix) with ESMTP id 8D65B1380076; Fri, 7 Aug 2026 22:26:29 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 07 Aug 2026 22:26:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flapping.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm1; t=1786155989; x=1786159589; bh=DrZ/ugl0jrV+exNDvkqqv jkGRbqAuIQ3t5N3+4zfSfU=; b=Maz/y+HdGNUap9xiQWmP9mz9PZCJOhCLf0mLl QbdXplxcnj6ChdCaZ3f0gHGrHuzlJQTAb1wjs3H+tt9bePO4C1aYQcZHBuf70L83 Zq29ebDQh9ilyWhUeg0Gx0WIO9hy8+agc9N734zg0kN6LBPgmBKRecMko9jFbxzb VKLtOo5/VGiZcM/AHyEYURPcnlx2sh1TIHDRGK4YoViyctzk0TtwIGaz9SE3ghJF 0WMdJ8AJPgmWv12Cc5195WscJaD57yb9s/r5YtYszgCvBCYu5PaksMBaY3Z3/ur5 hxRqcSTPSGljaUow7gCUzND1yAUNPQht/QZze5F088yI9VbgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1786155989; x=1786159589; bh=DrZ/ugl0jrV+exNDvkqqvjkGRbqAuIQ3t5N 3+4zfSfU=; b=bIsxOqwWb852p7pKB8y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e4b43:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Aug 2026 22:26:25 -0400 (EDT) From: FUJITA Tomonori To: ojeda@kernel.org Cc: a.hindborg@kernel.org, acourbot@nvidia.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org, daniel.almeida@collabora.com, gary@garyguo.net, lossin@kernel.org, tamird@kernel.org, tmgross@umich.edu, work@onurozkan.dev, rust-for-linux@vger.kernel.org, FUJITA Tomonori Subject: [PATCH v1] rust: bug: skip arch-specific asm in `testlib` builds Date: Sat, 8 Aug 2026 11:26:08 +0900 Message-ID: <20260808022608.1125174-1-tomo@flapping.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: FUJITA Tomonori Running `make rusttest` with `ARCH=` set to an architecture other than the host's fails, e.g. `ARCH=arm64` on an x86_64 host: error: invalid instruction mnemonic 'brk' --> rust/kernel/bug.rs:63:17 | 63 | / concat!( 64 | | "/* {size} */", 65 | | include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_warn_asm.rs")), 66 | | include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_reachable_asm.rs"))); | |_______________________________________________________________________________________________________^ | note: instantiated into assembly here --> :1:115 | 1 | /* 8 */.pushsection __bug_table,"aw"; .align 2; 14470: .long 14471f - .;.short 2305;.align 2; .popsection; 14471:brk 0x800 | ^^^ The reason is that `rusttest` builds the `kernel` crate as a host library: it passes the `CONFIG_*` cfgs of the configured architecture, but not `--target`, so code generation happens for the host. `warn_flags!` then selects the arch-specific inline asm arm based on `CONFIG_*`, and the host assembler rejects it. This does not happen with the current `master` because `warn_on!` has no user inside the `kernel` crate itself yet, but it will as soon as one is added. Reported-by: Miguel Ojeda Closes: https://lore.kernel.org/all/CANiq72n4=fz=JNKY0Jdm8BnLa=RmHB2B7s0bO47YTJ7hygqBZg@mail.gmail.com/ Signed-off-by: FUJITA Tomonori --- rust/kernel/bug.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs index ed943960f851..8e4c21e393c9 100644 --- a/rust/kernel/bug.rs +++ b/rust/kernel/bug.rs @@ -8,6 +8,7 @@ #[macro_export] #[doc(hidden)] +#[cfg(not(testlib))] #[cfg(all(CONFIG_BUG, not(CONFIG_UML), not(CONFIG_LOONGARCH), not(CONFIG_ARM)))] #[cfg(CONFIG_DEBUG_BUGVERBOSE)] macro_rules! warn_flags { @@ -47,6 +48,7 @@ macro_rules! warn_flags { #[macro_export] #[doc(hidden)] +#[cfg(not(testlib))] #[cfg(all(CONFIG_BUG, not(CONFIG_UML), not(CONFIG_LOONGARCH), not(CONFIG_ARM)))] #[cfg(not(CONFIG_DEBUG_BUGVERBOSE))] macro_rules! warn_flags { @@ -73,6 +75,7 @@ macro_rules! warn_flags { #[macro_export] #[doc(hidden)] +#[cfg(not(testlib))] #[cfg(all(CONFIG_BUG, CONFIG_UML))] macro_rules! warn_flags { ($file:expr, $flags:expr) => { @@ -91,6 +94,7 @@ macro_rules! warn_flags { #[macro_export] #[doc(hidden)] +#[cfg(not(testlib))] #[cfg(all(CONFIG_BUG, any(CONFIG_LOONGARCH, CONFIG_ARM)))] macro_rules! warn_flags { ($file:expr, $flags:expr) => { @@ -101,7 +105,7 @@ macro_rules! warn_flags { #[macro_export] #[doc(hidden)] -#[cfg(not(CONFIG_BUG))] +#[cfg(any(testlib, not(CONFIG_BUG)))] macro_rules! warn_flags { ($file:expr, $flags:expr) => {}; } base-commit: 075b74841bd0065a3bda3440873c747938e69b68 -- 2.43.0