Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(native): link libm, which is why every shipped Android template lacked bytecode

yhh88b1fa161248
diff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.js
index de0cd2edb..6409d3495 100644
--- a/build-tools/tasks/native.js
+++ b/build-tools/tasks/native.js
@@ -188,6 +188,19 @@ async function precompileBundleBytecode(rootDir, genDir, quickjs) {
'else()',
' target_compile_options(mkbc PRIVATE -w)',
'endif()',
+ // QuickJS needs libm, and finds it the same way its own build does.
+ // Linking nothing is what the old direct-compiler call did, which is
+ // why this step failed on every Linux runner — including the one that
+ // builds the Android template every release ships.
+ 'find_library(M_LIBRARIES m)',
+ 'if(M_LIBRARIES)',
+ ' target_link_libraries(mkbc PRIVATE ${M_LIBRARIES})',
+ 'endif()',
+ 'target_link_libraries(mkbc PRIVATE ${CMAKE_DL_LIBS})',
+ 'find_package(Threads)',
+ 'if(Threads_FOUND)',
+ ' target_link_libraries(mkbc PRIVATE Threads::Threads)',
+ 'endif()',
].join('\n') + '\n', 'utf8');
await runCommand('cmake', ['-S', buildDir, '-B', buildDir, '-DCMAKE_BUILD_TYPE=Release'],
{ cwd: rootDir, silent: true });