fix relocation of global linkable variables, enable iostream module linking test

This commit is contained in:
Alon Zakai 2013-07-01 18:45:02 -07:00
Родитель 218696cdd2
Коммит 8b68c8ada6
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -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]) + ' }'

Просмотреть файл

@ -1605,6 +1605,7 @@ function JSify(data, functionsOnly, givenFunctions) {
if (phase == 'pre' && !Variables.generatedGlobalBase) {
Variables.generatedGlobalBase = true;
// Globals are done, here is the rest of static memory
assert((TARGET_LE32 && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules
print('STATIC_BASE = ' + Runtime.GLOBAL_BASE + ';\n');
print('STATICTOP = STATIC_BASE + ' + Runtime.alignMemory(Variables.nextIndexedOffset) + ';\n');
}

Просмотреть файл

@ -10764,8 +10764,6 @@ f.close()
finally:
del os.environ['EMCC_FORCE_STDLIBS']
return # TODO
# iostream usage in one and std::string in both
test('iostream', r'''
#include <iostream>