@@ -34,7 +34,7 @@ def get_tools(env: "SConsEnvironment"):
34
34
35
35
36
36
def get_opts ():
37
- from SCons .Variables import BoolVariable
37
+ from SCons .Variables import BoolVariable , EnumVariable
38
38
39
39
return [
40
40
("initial_memory" , "Initial WASM memory (in MiB)" , 32 ),
@@ -57,6 +57,13 @@ def get_opts():
57
57
"Use Emscripten PROXY_TO_PTHREAD option to run the main application code to a separate thread" ,
58
58
False ,
59
59
),
60
+ EnumVariable (
61
+ "memory64" ,
62
+ "Set Emscripten MEMORY64 mode" ,
63
+ "wasm32" ,
64
+ ["wasm32" , "wasm64" , "wasm32+64bitptrs" ],
65
+ {"no" : "wasm32" , "yes" : "wasm64" , "0" : "wasm32" , "1" : "wasm64" , "2" : "wasm32+64bitptrs" },
66
+ ),
60
67
]
61
68
62
69
@@ -303,3 +310,16 @@ def configure(env: "SConsEnvironment"):
303
310
# This workaround creates a closure that prevents the garbage collector from freeing the WebGL context.
304
311
# We also only use WebGL2, and changing context version is not widely supported anyway.
305
312
env .Append (LINKFLAGS = ["-sGL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0" ])
313
+
314
+ # Set 32-bit or 64-bit pointers.
315
+ if env ["memory64" ] == "wasm32" :
316
+ memory64_value = 0
317
+ else :
318
+ env .Append (CPPDEFINES = ["WASM_MEMORY64_ENABLED" ])
319
+ if env ["memory64" ] == "wasm64" :
320
+ memory64_value = 1
321
+ else :
322
+ # "wasm32+64bitptrs"
323
+ memory64_value = 2
324
+ env .Append (CCFLAGS = [f"-sMEMORY64={ memory64_value } " ])
325
+ env .Append (LINKFLAGS = [f"-sMEMORY64={ memory64_value } " ])
0 commit comments