From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Miguel Ojeda" <ojeda@kernel.org>
Cc: "kernel test robot" <lkp@intel.com>, <llvm@lists.linux.dev>,
<oe-kbuild-all@lists.linux.dev>
Subject: Re: [linux-next:master 9676/10599] ld.lld: error: undefined symbol: rust_build_error
Date: Fri, 21 Nov 2025 22:41:46 +0900 [thread overview]
Message-ID: <DEEEZRYSYSS0.28PPK371D100F@nvidia.com> (raw)
In-Reply-To: <aSAr-aA2U26lr3iI@google.com>
On Fri Nov 21, 2025 at 6:08 PM JST, Alice Ryhl wrote:
> On Fri, Nov 21, 2025 at 03:13:16PM +0900, Alexandre Courbot wrote:
>> On Fri Nov 21, 2025 at 1:41 AM JST, kernel test robot wrote:
>> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
>> > head: 88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b
>> > commit: 01e345e82ec3a5a7edeb9fa0dcb7fd4b0e5c534e [9676/10599] rust: num: add Bounded integer wrapping type
>> > config: loongarch-randconfig-6002-20251120 (https://download.01.org/0day-ci/archive/20251121/202511210055.RUsFNku1-lkp@intel.com/config)
>> > compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
>> > rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
>> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251121/202511210055.RUsFNku1-lkp@intel.com/reproduce)
>> >
>> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> > the same patch/commit), kindly add following tags
>> > | Reported-by: kernel test robot <lkp@intel.com>
>> > | Closes: https://lore.kernel.org/oe-kbuild-all/202511210055.RUsFNku1-lkp@intel.com/
>> >
>> > All errors (new ones prefixed by >>):
>> >
>> >>> ld.lld: error: undefined symbol: rust_build_error
>> > >>> referenced by build_assert.rs:83 (rust/kernel/build_assert.rs:83)
>> > >>> rust/doctests_kernel_generated.o:(<kernel::num::bounded::Bounded<u8, 1>>::from_expr) in archive vmlinux.a
>> > >>> referenced by build_assert.rs:83 (rust/kernel/build_assert.rs:83)
>> > >>> rust/doctests_kernel_generated.o:(<kernel::num::bounded::Bounded<u32, 4>>::from_expr) in archive vmlinux.a
>> > >>> referenced by build_assert.rs:83 (rust/kernel/build_assert.rs:83)
>> > >>> rust/doctests_kernel_generated.o:(<kernel::num::bounded::Bounded<u16, 8>>::from_expr) in archive vmlinux.a
>>
>> Mmm, I don't like this. The expressions that are failing are extremely
>> simple, for instance:
>>
>> Bounded::<u8, 1>::from_expr(1)
>>
>> So if the compiler is unable to assess that this won't fail, this might
>> be a deal-breaker for `from_expr` and we might need to remove it. :(
>>
>> This would also mean a lot more runtime checks when working with
>> bitfields and registers. Or can we assume that this is a compiler
>> problem on this particular architecture?
>
> Yeah, it sounds like from_expr() isn't going to work.
It would be a pity but we can replace `from_expr` with an unsafe
`new_unchecked` for these cases where the caller is absolutely sure of
their input. I have tried on bitfield/Nova and the result is not too
bad.
Still, this is a bummer - it is much better to have the compiler
validate safety properties than relying on a SAFETY comment.
I notice that loongarch is a Tier 2 Rust platform, but I suppose that's
not an excuse to let it not build? ^_^;
If I had to bet I'd wager that in this case the "shift left then back
right" technique to check the bounds is not working well. I will try to
find an alternative, but meanwhile we should probably remove
`from_expr`. I will send a patch to that effect unless told otherwise.
next prev parent reply other threads:[~2025-11-21 13:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 16:41 [linux-next:master 9676/10599] ld.lld: error: undefined symbol: rust_build_error kernel test robot
2025-11-21 6:13 ` Alexandre Courbot
2025-11-21 9:08 ` Alice Ryhl
2025-11-21 13:41 ` Alexandre Courbot [this message]
2025-11-21 14:10 ` Alice Ryhl
2025-11-21 14:21 ` Miguel Ojeda
2025-11-21 14:30 ` Gary Guo
2025-11-21 14:39 ` Alexandre Courbot
2025-11-21 14:44 ` Alice Ryhl
2025-11-21 15:53 ` Miguel Ojeda
2025-11-21 15:27 ` Alexandre Courbot
2025-11-21 15:30 ` Miguel Ojeda
2025-11-22 2:12 ` Alexandre Courbot
2025-11-21 14:19 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DEEEZRYSYSS0.28PPK371D100F@nvidia.com \
--to=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=ojeda@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).