[PATCH v4 4/6] rust: helpers: Use __builtin_memchr directly on s390
From: Jan Polensky
Date: Fri May 29 2026 - 11:23:23 EST
The __underlying_memchr macro from include/linux/fortify-string.h
is not being expanded correctly during Rust helpers compilation on
s390x architecture, causing a build failure:
rust/helpers/uaccess.c:40:16: error: implicit declaration of
function '__underlying_memchr'
The macro is defined as __builtin_memchr, so use the builtin
directly instead of relying on the macro expansion.
Reported-by: Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx>
Signed-off-by: Jan Polensky <japo@xxxxxxxxxxxxx>
---
rust/helpers/uaccess.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c
index d9625b9ee046..d4107426003e 100644
--- a/rust/helpers/uaccess.c
+++ b/rust/helpers/uaccess.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/uaccess.h>
+#include <linux/string.h>
__rust_helper unsigned long
rust_helper_copy_from_user(void *to, const void __user *from, unsigned long n)
@@ -27,3 +28,9 @@ unsigned long rust_helper__copy_to_user(void __user *to, const void *from, unsig
return _inline_copy_to_user(to, from, n);
}
#endif
+
+__rust_helper
+void *rust_helper_memchr(const void *s, int c, size_t n)
+{
+ return __builtin_memchr(s, c, n);
+}
--
2.53.0