Skip to contentSkip to conversation

Add __clear_cache declaration for clang

PATCH In review Khem Raj 3 participants 3 messages Jun 11, 2024 – Oct 12, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 Add __clear_cache declaration for clang

__clear_cache was enabled on RISCV recently with 7352ba02390116f1cd6a9b583860ba28aa0a1b7a however it fails to compile with clang19 on RISCV
With this error

hugemmap15.c:51:2: error: call to undeclared function '__clear_cache'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

      51 |         __clear_cache(p, p + COPY_SIZE);
         |         ^
Cc Hui Min Mina Chou <[email protected]>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +1 -0
index a84ba6476..856e22ff3 100644
@@ -21,6 +21,7 @@
 
 #if defined(__clang__)
 	#pragma clang optimize off
+	void __clear_cache(void *start, void *end);
 #endif
 
 #define _GNU_SOURCE
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 7 lines

__clear_cache was enabled on RISCV recently with 7352ba02390116f1cd6a9b583860ba28aa0a1b7a however it fails to compile with clang19 on RISCV
With this error

hugemmap15.c:51:2: error: call to undeclared function '__clear_cache'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

      51 |         __clear_cache(p, p + COPY_SIZE);
         |         ^

This sounds like a clnag bug. The __clear_cache() is a pre-defined function and as such the signature should be part of the compiler.

Is the call even supported by clang19 on RISCV?

Quoted 21 lines
Cc Hui Min Mina Chou <[email protected]>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +1 -0
index a84ba6476..856e22ff3 100644
@@ -21,6 +21,7 @@
 
 #if defined(__clang__)
 	#pragma clang optimize off
+	void __clear_cache(void *start, void *end);
 #endif
 
 #define _GNU_SOURCE
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Khem, Cyril,

Quoted 5 lines

Hi!

Quoted 3 lines

__clear_cache was enabled on RISCV recently with 7352ba02390116f1cd6a9b583860ba28aa0a1b7a however it fails to compile with clang19 on RISCV
With this error

Quoted 8 lines
Quoted 3 lines

hugemmap15.c:51:2: error: call to undeclared function '__clear_cache'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

      51 |         __clear_cache(p, p + COPY_SIZE);
         |         ^

This sounds like a clnag bug. The __clear_cache() is a pre-defined function and as such the signature should be part of the compiler.

Is the call even supported by clang19 on RISCV?

I think Cyril is correct. IMHO __clear_cache() on riscv64 was added in

https://github.com/llvm/llvm-project/commit/9d469b5988bfb1c2e99533f863b1f9eb5b0c58b7

which was added in llvmorg-20.1.0-rc1.

BTW we have m4 check for __clear_cache(), I'll send a patch.

Kind regards,
Petr

Quoted 16 lines
Quoted 16 lines
Cc Hui Min Mina Chou <[email protected]>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +1 -0
index a84ba6476..856e22ff3 100644
@@ -21,6 +21,7 @@
 
 #if defined(__clang__)
 	#pragma clang optimize off
+	void __clear_cache(void *start, void *end);
 #endif
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp