emit memory initialization file by default in -O2+

This commit is contained in:
Alon Zakai 2014-07-03 14:48:19 -07:00
Родитель b82c5cffeb
Коммит e6811d0e2d
4 изменённых файлов: 23 добавлений и 19 удалений

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

@ -156,11 +156,11 @@ Options that are modified or new in %s include:
opt levels, see apply_opt_level() in
tools/shared.py and also src/settings.js.)
-O2 As -O1, plus various js-level optimizations and
LLVM -O3 optimizations. This is the recommended
setting for a release build: slower compilation
time in return for the smallest and fastest
output.
-O2 As -O1, plus various js-level optimizations, LLVM
-O3 optimizations, and memory init file generation
(--memory-init-file 1). This is a good setting
for an optimized build: runs much faster than
-O1, and compiles much faster than -O3.
-Os Like -O2 with extra optimizations for size.
@ -482,7 +482,8 @@ Options that are modified or new in %s include:
--memory-init-file <on> 0: Do not emit a separate memory initialization
file, keep the static initialization inside
the generated JavaScript as text (default)
the generated JavaScript as text (default
in -O0 and -O1)
1: Emit a separate memory initialization file
in binary format. This is more efficient than
storing it as text inside JavaScript, but does
@ -495,7 +496,7 @@ Options that are modified or new in %s include:
stuff has happened and it is safe to call
library functions, as main() will only be
called at that time. You can also call
addOnPreMain from a preRun.)
addOnPreMain from a preRun.) (default in -O2+)
-Wno-warn-absolute-paths If not specified, the compiler will warn about any
uses of absolute paths in -I and -L command line
@ -823,7 +824,7 @@ try:
emrun = False
jcache = False
save_bc = False
memory_init_file = False
memory_init_file = None
use_preload_cache = False
no_heap_copy = False
proxy_to_worker = False
@ -1075,6 +1076,7 @@ try:
if js_opts is None: js_opts = opt_level >= 2
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if opt_level == 0: debug_level = 4
if memory_init_file is None: memory_init_file = opt_level >= 2
if llvm_lto is None and bind:
logging.debug('running lto for embind') # XXX this is a workaround for a pointer issue
@ -1357,7 +1359,7 @@ try:
assert not shared.Settings.MAIN_MODULE
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE:
assert not memory_init_file, 'memory init file is not supported with module linking'
memory_init_file = False # memory init file is not supported with module linking
assert shared.Settings.ASM_JS, 'module linking requires asm.js output (-s ASM_JS=1)'
shared.Settings.LINKABLE = 1 # TODO: add FORCE_DCE option for the brave people that do want to dce here and in side modules
debug_level = max(debug_level, 2)

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

@ -240,11 +240,11 @@ process(sys.argv[1])
if output_processor is not None:
output_processor(open(filename + '.o.js').read())
if self.emcc_args is not None and 'ASM_JS=1' in self.emcc_args:
if self.emcc_args is not None:
if '--memory-init-file' in self.emcc_args:
memory_init_file = int(self.emcc_args[self.emcc_args.index('--memory-init-file')+1])
else:
memory_init_file = 0
memory_init_file = '-O2' in self.emcc_args or '-O3' in self.emcc_args
if memory_init_file:
assert '/* memory initializer */' not in open(filename + '.o.js').read()
else:

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

@ -2834,11 +2834,8 @@ The current type of b is: 9
self.skip('todo in fastcomp')
return False
if self.emcc_args and '--memory-init-file' in self.emcc_args:
for i in range(len(self.emcc_args)):
if self.emcc_args[i] == '--memory-init-file':
self.emcc_args = self.emcc_args[:i] + self.emcc_args[i+2:]
break
if self.emcc_args:
self.emcc_args += ['--memory-init-file', '0']
if Settings.ASM_JS:
Settings.DLOPEN_SUPPORT = 1
@ -4037,7 +4034,7 @@ def process(filename):
try_delete(mem_file)
self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\n'),
post_build=post, extra_emscripten_args=['-H', 'libc/fcntl.h'])
if self.emcc_args and '--memory-init-file' in self.emcc_args:
if self.emcc_args and '-O2' in self.emcc_args:
assert os.path.exists(mem_file)
def test_files_m(self):
@ -6816,7 +6813,7 @@ asm1 = make_run("asm1", compiler=CLANG, emcc_args=["-O1"])
asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2"])
asm3 = make_run("asm3", compiler=CLANG, emcc_args=["-O3"])
asm2f = make_run("asm2f", compiler=CLANG, emcc_args=["-O2", "-s", "PRECISE_F32=1"])
asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1", "-s", "SAFE_HEAP=1"])
asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "-s", "SAFE_HEAP=1"])
# Legacy test modes -
slow2 = make_run("slow2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=0"], env={"EMCC_FAST_COMPILER": "0"})

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

@ -208,7 +208,6 @@ Options that are modified or new in %s include:
(['-O2', '-g2'], lambda generated: '// The Module object' not in generated, 'with -g2, no comments in shell code'),
(['-O2', '-g3'], lambda generated: '// The Module object' in generated, 'with -g3, yes comments in shell code'),
(['-O2', '-profiling'], lambda generated: '// The Module object' in generated or os.environ.get('EMCC_FAST_COMPILER') == '0', 'with -profiling, yes comments in shell code (in fastcomp)'),
]:
print params, text
self.clear()
@ -278,6 +277,12 @@ f.close()
output = Popen([PYTHON, compiler, path_from_root('tests', 'hello_world' + suffix), '--js-transform', '%s t.py' % (PYTHON)], stdout=PIPE, stderr=PIPE).communicate()
assert open('a.out.js').read() == 'transformed!', 'Transformed output must be as expected'
for opts in [0, 1, 2, 3]:
print 'mem init in', opts
self.clear()
output = Popen([PYTHON, compiler, path_from_root('tests', 'hello_world.c'), '-O' + str(opts)], stdout=PIPE, stderr=PIPE).communicate()
assert os.path.exists('a.out.js.mem') == (opts >= 2), 'mem file should exist in -O2+'
# TODO: Add in files test a clear example of using disablePermissions, and link to it from the wiki
# TODO: test normal project linking, static and dynamic: get_library should not need to be told what to link!
# TODO: deprecate llvm optimizations, dlmalloc, etc. in emscripten.py.