--- orc/orcprogram-x86.c.orig 2026-08-11 17:29:40.000000000 -0600 +++ orc/orcprogram-x86.c 2026-08-11 21:33:42.000000000 -0600 @@ -13,8 +13,12 @@ #include #if defined(__APPLE__) +#include +// Not available in Tiger. +#if MAC_OS_X_VERSION_MIN_REQUIRED > 1040 #include #endif +#endif #if defined(_WIN32) #include @@ -1219,8 +1223,21 @@ orc_x86_flush_cache (OrcCode *code) { #if defined(__APPLE__) +// https://gcc.gnu.org/onlinedocs/gcc-4.2.3/gcc/X86-Built_002din-Functions.html +// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sys_dcache_flush.3.html +// sys_icache_invalidate and sys_dcache_flush were introduced in Mac OS X 10.5. +// On Intel, sys_icace_invalidate is a no-op. GCC builtin can be used for dcache. +// However GCC builtin only does 64 bytes. We need to do it for code->code_size. +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 + unsigned char *p = (unsigned char *)code->code; + size_t i; + for (i = 0; i < code->code_size; i += 64) { + __builtin_ia32_clflush(p + i); + } +#else sys_dcache_flush(code->code, code->code_size); sys_icache_invalidate(code->exec, code->code_size); +#endif #elif defined (_WIN32) HANDLE h_proc = GetCurrentProcess();