aboutsummaryrefslogtreecommitdiff
path: root/cmake/platforms/emscripten.cmake
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-04-06 09:58:21 +0100
committerBen Harris <bjh21@bjh21.me.uk>2023-04-06 23:05:52 +0100
commitd505f08f671c2f0a3fdd0b7d733e4ce987aa4786 (patch)
tree7fded9e6ea6501c4c9c1fa48e420ad2158c975e5 /cmake/platforms/emscripten.cmake
parentb5f87e6175db229e3e84e054ce23a1194cc535e4 (diff)
downloadpuzzles-d505f08f671c2f0a3fdd0b7d733e4ce987aa4786.zip
puzzles-d505f08f671c2f0a3fdd0b7d733e4ce987aa4786.tar.gz
puzzles-d505f08f671c2f0a3fdd0b7d733e4ce987aa4786.tar.bz2
puzzles-d505f08f671c2f0a3fdd0b7d733e4ce987aa4786.tar.xz
js: explicitly tell Emscripten which browsers to target
Emscripten has settings indicating which browser versions it should build code for. These are now by default slightly newer than I'd been targeting with my hand-written JavaScript. They also don't include Firefox 48, which KaiOS 2.5 is based on. This commit adds CMake variables to set the minimum versions that we pass to Emscripten. They default to the earliest versions with WebAssembly support, except that Firefox 48 is also supported. I think the main consequence of this change is to stop Emscripten using sign-extension and mutable-globals in WebAssembly, which it's done by default since version 3.1.26.
Diffstat (limited to 'cmake/platforms/emscripten.cmake')
-rw-r--r--cmake/platforms/emscripten.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/platforms/emscripten.cmake b/cmake/platforms/emscripten.cmake
index ac7a739..c84a3c7 100644
--- a/cmake/platforms/emscripten.cmake
+++ b/cmake/platforms/emscripten.cmake
@@ -6,6 +6,20 @@ set(CMAKE_EXECUTABLE_SUFFIX ".js")
set(WASM ON
CACHE BOOL "Compile to WebAssembly rather than plain JavaScript")
+# The minimal versions here are the ones that Puzzles' own JavaScript
+# is written for. For most browsers, that's the earliest version with
+# WebAssembly support according to https://caniuse.com/wasm. For
+# Firefox we go back to Firefox 48 because that's what KaiOS 2.5 is
+# based on.
+set(MIN_FIREFOX_VERSION 48 CACHE STRING
+ "Oldest major version of Firefox to target")
+set(MIN_SAFARI_VERSION 110000 CACHE STRING
+ "Oldest version of desktop Safari to target (XXYYZZ for version XX.YY.ZZ)")
+set(MIN_EDGE_VERSION 16 CACHE STRING
+ "Oldest version of (non-Chromium-based) Edge to target")
+set(MIN_CHROME_VERSION 57 CACHE STRING
+ "Oldest version of Chrome to target")
+
find_program(HALIBUT halibut)
if(NOT HALIBUT)
message(WARNING "HTML documentation cannot be built (did not find halibut)")
@@ -44,6 +58,11 @@ set(CMAKE_C_LINK_FLAGS "\
-s ENVIRONMENT=web \
-s EXPORTED_FUNCTIONS='[${emcc_export_string}]' \
-s EXPORTED_RUNTIME_METHODS='[cwrap]' \
+-s MIN_FIREFOX_VERSION=${MIN_FIREFOX_VERSION} \
+-s MIN_SAFARI_VERSION=${MIN_SAFARI_VERSION} \
+-s MIN_EDGE_VERSION=${MIN_EDGE_VERSION} \
+-s MIN_CHROME_VERSION=${MIN_CHROME_VERSION} \
+-s MIN_NODE_VERSION=0x7FFFFFFF \
-s STRICT_JS=1")
if(WASM)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s WASM=1")