aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-01 18:45:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-03 15:31:05 -0700
commit8b68c8ada6845886bebe698a35bea27858d07db0 (patch)
tree63e95d611f6a4f4b0edb3b8088f7c5725d5de41d /emscripten.py
parent218696cdd2af0f6a96b7bb506c60c845ab36852f (diff)
fix relocation of global linkable variables, enable iostream module linking test
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py
index 7d9dd1a2..eeee26e4 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -481,11 +481,12 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
''.join([' var ' + g + '=+env.' + g + ';\n' for g in basic_float_vars])
# In linkable modules, we need to add some explicit globals for global variables that can be linked and used across modules
if settings.get('MAIN_MODULE') or settings.get('SIDE_MODULE'):
+ assert settings.get('TARGET_LE32'), 'TODO: support x86 target when linking modules (needs offset of 4 and not 8 here)'
for key, value in forwarded_json['Variables']['globals'].iteritems():
if value.get('linkable'):
- init = str(forwarded_json['Variables']['indexedGlobals'][key])
- if settings.get('SIDE_MODULE'): init = '(H_BASE+' + init + ')|0'
- asm_global_vars += ' var %s=%s;\n' % (key, init)
+ init = forwarded_json['Variables']['indexedGlobals'][key] + 8 # 8 is Runtime.GLOBAL_BASE / STATIC_BASE
+ if settings.get('SIDE_MODULE'): init = '(H_BASE+' + str(init) + ')|0'
+ asm_global_vars += ' var %s=%s;\n' % (key, str(init))
# sent data
the_global = '{ ' + ', '.join(['"' + math_fix(s) + '": ' + s for s in fundamentals]) + ' }'