diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c --- a/compiler-rt/lib/builtins/clear_cache.c +++ b/compiler-rt/lib/builtins/clear_cache.c @@ -46,6 +46,12 @@ #include #endif +#if defined(__linux__) && (defined(__riscv) && (__riscv_xlen == 64)) +#include +#include +#include +#endif + // The compiler generates calls to __clear_cache() when creating // trampoline functions on the stack for use with nested functions. // It is expected to invalidate the instruction cache for the @@ -84,6 +90,10 @@ #else compilerrt_abort(); #endif +#elif defined(__linux__) && (defined(__riscv) && (__riscv_xlen == 64)) + // The only available flag is SYS_RISCV_FLUSH_ICACHE_LOCAL + // see linux/arch/riscv/include/asm/cacheflush.h + __riscv_flush_icache(start, end, 0); #elif defined(__linux__) && defined(__mips__) const uintptr_t start_int = (uintptr_t)start; const uintptr_t end_int = (uintptr_t)end;