Subject: Re: linux-next: build failure after merge of the tip tree

From: Stephen Rothwell <[email-masked]>
Date: Fri, 8 Nov 2024 00:04:32 +1100

Hi Peter,

On Thu, 7 Nov 2024 11:34:14 +0100 Peter Zijlstra <[email-masked]> wrote:
>
> On Thu, Nov 07, 2024 at 06:24:11PM +1100, Stephen Rothwell wrote:
> So I can't get RUST=y, even though make rustavailable is happy.
> 
> make LLVM=-19 allmodconfig does not get me RUST=y
> 
> I started out with tip/master, tried adding rust-next, then kbuild-next
> gave up and tried next/master. Nada.

Just on Linus' tree allmodconfig gives me:

$ grep RUST .config
CONFIG_RUSTC_VERSION=108100
CONFIG_RUST_IS_AVAILABLE=y
CONFIG_RUSTC_LLVM_VERSION=180108
CONFIG_RUST=y
CONFIG_RUSTC_VERSION_TEXT="rustc 1.81.0"
CONFIG_HAVE_RUST=y
CONFIG_RUST_FW_LOADER_ABSTRACTIONS=y
CONFIG_BLK_DEV_RUST_NULL=m
CONFIG_RADIO_TRUST=m
CONFIG_HID_THRUSTMASTER=m
CONFIG_THRUSTMASTER_FF=y
CONFIG_TRUSTED_KEYS=m
CONFIG_HAVE_TRUSTED_KEYS=y
CONFIG_TRUSTED_KEYS_TPM=y
CONFIG_TRUSTED_KEYS_TEE=y
CONFIG_TRUSTED_KEYS_CAAM=y
CONFIG_INTEGRITY_TRUSTED_KEYRING=y
CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=y
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN=y
CONFIG_SAMPLES_RUST=y
CONFIG_SAMPLE_RUST_MINIMAL=m
CONFIG_SAMPLE_RUST_PRINT=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_RUST_DEBUG_ASSERTIONS=y
CONFIG_RUST_OVERFLOW_CHECKS=y
CONFIG_RUST_BUILD_ASSERT_ALLOW=y

$ rustc --version
rustc 1.81.0

> Anyway, I think the above needs something like this:
> 
> ---
> diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
> index b7b0945e8b3c..5804a6062eb1 100644
> --- a/rust/helpers/spinlock.c
> +++ b/rust/helpers/spinlock.c
> @@ -5,11 +5,16 @@
>  void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
>  				  struct lock_class_key *key)
>  {
> +#ifndef CONFIG_PREEMPT_RT
>  #ifdef CONFIG_DEBUG_SPINLOCK
>  	__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
>  #else
>  	spin_lock_init(lock);
>  #endif
> +#else
> +	rt_mutex_base_init(&lock->lock);
> +	__rt_spin_lock_init(lock, name, key, false);
> +#endif
>  }
>  
>  void rust_helper_spin_lock(spinlock_t *lock)

I will try to remember to add that to the tip tree merge tomorrow.

> > Without the revert CONFIG_PREEMPT_RT=y, after the revert it is not set
> > and spinlock_check is only defined for !defined(CONFIG_PREEMPT_RT).  
> 
> Right, that moved PREEMPT_RT out of the preemption choice. Now I'm not
> sure we want it =y for all{yes,mod}config. Is the below the right
> incantation to avoid this?
> 
> ---
> diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> index 7c1b29a3a491..54ea59ff8fbe 100644
> --- a/kernel/Kconfig.preempt
> +++ b/kernel/Kconfig.preempt
> @@ -88,7 +88,7 @@ endchoice
>  
>  config PREEMPT_RT
>  	bool "Fully Preemptible Kernel (Real-Time)"
> -	depends on EXPERT && ARCH_SUPPORTS_RT
> +	depends on EXPERT && ARCH_SUPPORTS_RT && !COMPILE_TEST
>  	select PREEMPTION
>  	help
>  	  This option turns the kernel into a real-time kernel by replacing

Yeah, that will do it.

-- 
Cheers,
Stephen Rothwell