@@ -34,7 +34,7 @@ def get_tools(env: "SConsEnvironment"):
3434
3535
3636def get_opts ():
37- from SCons .Variables import BoolVariable
37+ from SCons .Variables import BoolVariable , EnumVariable
3838
3939 return [
4040 ("initial_memory" , "Initial WASM memory (in MiB)" , 32 ),
@@ -57,6 +57,13 @@ def get_opts():
5757 "Use Emscripten PROXY_TO_PTHREAD option to run the main application code to a separate thread" ,
5858 False ,
5959 ),
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+ ),
6067 ]
6168
6269
@@ -303,3 +310,14 @@ def configure(env: "SConsEnvironment"):
303310 # This workaround creates a closure that prevents the garbage collector from freeing the WebGL context.
304311 # We also only use WebGL2, and changing context version is not widely supported anyway.
305312 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+ elif env ["memory64" ] == "wasm64" :
318+ memory64_value = 1
319+ else :
320+ # "wasm32+64bitptrs"
321+ memory64_value = 2
322+ env .Append (CCFLAGS = [f"-sMEMORY64={ memory64_value } " ])
323+ env .Append (LINKFLAGS = [f"-sMEMORY64={ memory64_value } " ])
0 commit comments