From cb3e1b75ae9522b93aa0496fefa8ef65be22c0b4 Mon Sep 17 00:00:00 2001 From: Username404 Date: Thu, 29 Sep 2022 20:32:41 +0200 Subject: [PATCH] CMakeLists.txt: Disable SAFE_HEAP when using emscripten on Android Signed-off-by: Username404 --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff3c464..36193ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,12 @@ if (${IS_GNU} OR ${IS_CLANG}) if (NOT DEFINED EMSCRIPTEN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong -fstack-clash-protection") else() - set(CMAKE_EXE_LINKER_FLAGS "--closure 1 -sWASM=0 --memory-init-file 0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=1 -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sSTRICT=1 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 ${CMAKE_EXE_LINKER_FLAGS}") + if (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") # See https://github.com/WebAssembly/binaryen/issues/4519 + set(IS_HOST_NOT_ANDROID 1) + else() + set(IS_HOST_NOT_ANDROID 0) + endif() + set(CMAKE_EXE_LINKER_FLAGS "--closure 1 -sWASM=0 --memory-init-file 0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=${IS_HOST_NOT_ANDROID} -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sSTRICT=1 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 ${CMAKE_EXE_LINKER_FLAGS}") if (CMAKE_USE_PTHREADS_INIT) set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}") # Emscripten requires the -pthread flag set(CMAKE_EXE_LINKER_FLAGS "--closure-args=\"--compilation_level SIMPLE\" -sPROXY_TO_PTHREAD=1 ${CMAKE_EXE_LINKER_FLAGS}") # See https://github.com/emscripten-core/emscripten/issues/16706