Hello Marc, > The idea is to offer the builtin procedure > > __builtin__clear_cache (void *begin, void *end), > > which is provided at least by gcc and clang, in a portable manner. From > the documentation of gcc's version: > > "This function is used to flush the processor’s instruction cache for the > region of memory between begin inclusive and end exclusive. Some targets > require that the instruction cache be flushed, after modifying memory > containing code, in order to obtain deterministic behavior." > > Clients for such a procedure are, in particular, JIT compilers.
I can provide such a thing easily. In fact, I have it already sitting around on my disk since 2021 :-) > GNU > lightning currently calls libgcc's `__clear_cache' directly ([1]), but this > will fail on systems that do not have libgcc. And also, libgcc's __clear_cache does not always work. My comments say: /* GCC >= 4.3 has a GCC built-in. <https://gcc.gnu.org/onlinedocs/gcc-4.3.6/gcc/Other-Builtins.html> But it's sometimes not correctly implemented. So, I can provide the module's code. Can you provide a unit test for it? Bruno