rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: Fix build error
@ 2024-10-14 19:52 Eder Zulian
  2024-10-14 20:31 ` Boqun Feng
  2024-10-14 20:38 ` Miguel Ojeda
  0 siblings, 2 replies; 8+ messages in thread
From: Eder Zulian @ 2024-10-14 19:52 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel
  Cc: williams, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, tmgross

When CONFIG_DEBUG_SPINLOCK=y and CONFIG_PREEMPT_RT=y the following build
error occurs:

    In file included from rust/helpers/helpers.c:22:
    rust/helpers/spinlock.c: In function ‘rust_helper___spin_lock_init’:
    rust/helpers/spinlock.c:10:30: error: implicit declaration of function ‘spinlock_check’; did you mean ‘spin_lock_bh’? [-Wimplicit-function-declaration]
       10 |         __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
          |                              ^~~~~~~~~~~~~~
          |                              spin_lock_bh
    rust/helpers/spinlock.c:10:30: error: passing argument 1 of ‘__raw_spin_lock_init’ makes pointer from integer without a cast [-Wint-conversion]
       10 |         __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
          |                              ^~~~~~~~~~~~~~~~~~~~
          |                              |
          |                              int
    In file included from ./include/linux/wait.h:9,
                     from ./include/linux/wait_bit.h:8,
                     from ./include/linux/fs.h:6,
                     from ./include/linux/highmem.h:5,
                     from ./include/linux/bvec.h:10,
                     from ./include/linux/blk_types.h:10,
                     from ./include/linux/blkdev.h:9,
                     from ./include/linux/blk-mq.h:5,
                     from rust/helpers/blk.c:3,
                     from rust/helpers/helpers.c:10:
    ./include/linux/spinlock.h:101:52: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘int’
      101 |   extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
          |                                    ~~~~~~~~~~~~~~~~^~~~
    make[2]: *** [scripts/Makefile.build:229: rust/helpers/helpers.o] Error 1

Error observed while building a rt-debug kernel for aarch64.

On a PREEMPT_RT build, spin locks have been mapped to rt_mutex types, so
avoid the raw_spinlock_init call for RT.

Suggested-by: Clark Williams <williams@redhat.com>

Signed-off-by: Eder Zulian <ezulian@redhat.com>
---
 rust/helpers/spinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
index acc1376b833c..924c1a380448 100644
--- a/rust/helpers/spinlock.c
+++ b/rust/helpers/spinlock.c
@@ -6,7 +6,7 @@
 void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
 				  struct lock_class_key *key)
 {
-#ifdef CONFIG_DEBUG_SPINLOCK
+#if defined(CONFIG_DEBUG_SPINLOCK) && !defined(CONFIG_PREEMPT_RT)
 	__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
 #else
 	spin_lock_init(lock);
-- 
2.46.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-04 11:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 19:52 [PATCH] rust: Fix build error Eder Zulian
2024-10-14 20:31 ` Boqun Feng
2024-10-16 23:48   ` Eder Zulian
2024-10-14 20:38 ` Miguel Ojeda
2024-10-14 20:58   ` Boqun Feng
2024-10-17  0:15   ` Eder Zulian
2024-10-17 13:24     ` Miguel Ojeda
2024-11-04 11:09       ` Eder Zulian

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).