| ... | @@ -28,6 +28,10 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { | ... | @@ -28,6 +28,10 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 28 | .aarch64, .aarch64_be => true, | 28 | .aarch64, .aarch64_be => true, |
| 29 | else => false, | 29 | else => false, |
| 30 | }; | 30 | }; |
| | 31 | const loongarch64 = switch (arch) { |
| | 32 | .loongarch64 => true, |
| | 33 | else => false, |
| | 34 | }; |
| 31 | const mips = switch (arch) { | 35 | const mips = switch (arch) { |
| 32 | .mips, .mipsel, .mips64, .mips64el => true, | 36 | .mips, .mipsel, .mips64, .mips64el => true, |
| 33 | else => false, | 37 | else => false, |
| ... | @@ -159,6 +163,12 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { | ... | @@ -159,6 +163,12 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 159 | // On Darwin, sys_icache_invalidate() provides this functionality | 163 | // On Darwin, sys_icache_invalidate() provides this functionality |
| 160 | sys_icache_invalidate(start, end - start); | 164 | sys_icache_invalidate(start, end - start); |
| 161 | exportIt(); | 165 | exportIt(); |
| | 166 | } else if (os == .linux and loongarch64) { |
| | 167 | // See: https://github.com/llvm/llvm-project/blob/cf54cae26b65fc3201eff7200ffb9b0c9e8f9a13/compiler-rt/lib/builtins/clear_cache.c#L94-L95 |
| | 168 | asm volatile ( |
| | 169 | \\ ibar 0 |
| | 170 | ); |
| | 171 | exportIt(); |
| 162 | } | 172 | } |
| 163 | } | 173 | } |
| 164 | | 174 | |