Building mlua with Luau JIT enabled fails on Android/aarch64 because the linker cannot resolve the __clear_cache symbol required by Luau's JIT code allocator.
Environment
- Android aarch64
- Termux
- Rust target:
aarch64-linux-android
mlua features:
mlua = { version = "0.12.0", features = ["luau", "luau-jit", "vendored"] }
Error
During linking:
ld.lld: error: undefined symbol: __clear_cache
referenced by CodeAllocator.cpp
flushInstructionCache(unsigned char*, unsigned long)
The error happens inside Luau JIT code:
luau/CodeGen/src/CodeAllocator.cpp
Tested versions
mlua 0.11.6
Dependencies:
mlua-sys 0.10.0
luau0-src 0.18.3+luau709
The build can succeed after adding a manual __clear_cache stub, but Luau JIT execution can trigger a SIGTRAP.
mlua 0.12.0
Dependencies:
mlua-sys 0.11.0
luau0-src 0.20.7+luau728
The same missing symbol happens during linking.
Workaround
Adding a manual stub allows the linker to continue:
#[unsafe(no_mangle)]
pub extern "C" fn __clear_cache(
_begin: *mut u8,
_end: *mut u8,
) {
}
However, this is only a workaround and may not be the correct solution for JIT instruction cache invalidation.
Expected behavior
mlua with luau-jit should build successfully on Android/aarch64 without requiring users to manually define __clear_cache.
Additional information
The same Luau JIT configuration works on other platforms where __clear_cache is available.
It appears that the Android/aarch64 build needs a proper implementation or compatibility handling for instruction cache flushing when using Luau JIT.
Building
mluawith Luau JIT enabled fails on Android/aarch64 because the linker cannot resolve the__clear_cachesymbol required by Luau's JIT code allocator.Environment
aarch64-linux-androidmluafeatures:Error
During linking:
ld.lld: error: undefined symbol: __clear_cache
The error happens inside Luau JIT code:
luau/CodeGen/src/CodeAllocator.cpp
Tested versions
mlua 0.11.6
Dependencies:
mlua-sys 0.10.0
luau0-src 0.18.3+luau709
The build can succeed after adding a manual __clear_cache stub, but Luau JIT execution can trigger a SIGTRAP.
mlua 0.12.0
Dependencies:
mlua-sys 0.11.0
luau0-src 0.20.7+luau728
The same missing symbol happens during linking.
Workaround
Adding a manual stub allows the linker to continue:
However, this is only a workaround and may not be the correct solution for JIT instruction cache invalidation.
Expected behavior
mlua with luau-jit should build successfully on Android/aarch64 without requiring users to manually define __clear_cache.
Additional information
The same Luau JIT configuration works on other platforms where __clear_cache is available.
It appears that the Android/aarch64 build needs a proper implementation or compatibility handling for instruction cache flushing when using Luau JIT.