diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-13 10:09:59 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-13 10:09:59 -0800 |
commit | c89d2ec4a460d7cfc49a605ecb0ebc8f9c151926 (patch) | |
tree | 4bc49373b077c25e67cf779d172d1ec0c727d8f0 | |
parent | 1224991a348c9f69cf7854de4e32ada049705f29 (diff) |
support for --typed-arrays in emcc
-rwxr-xr-x | emcc | 24 | ||||
-rw-r--r-- | tests/runner.py | 33 |
2 files changed, 12 insertions, 45 deletions
@@ -15,14 +15,6 @@ For example, compilation will be translated into calls to clang with -emit-llvm, and linking will be translated into calls to llvm-link, and so forth. -emcc is only meant to *COMPILE* source code into LLVM bitcode. It does -not do optimizations (in fact, it will disable -Ox flags and warn you -about that). The reason is that doing such optimizations early can lead -to bitcode that Emscripten cannot process properly, or can process but -not fully optimize. You can (and probably should) still run LLVM -optimizations though, by telling emscripten.py to do so (or run LLVM -opt yourself, but be careful with the parameters you pass). - Example uses: * For configure, instead of ./configure, cmake, etc., run emconfiguren.py @@ -68,11 +60,7 @@ Example uses: env.Replace(LD = LLVM_LD) TODO: Document all relevant setup changes -After setting that up, run your build system normally. It should generate -LLVM instead of the normal output, and end up with .ll files that you can -give to Emscripten. Note that this tool doesn't run Emscripten itself. Note -also that you may need to do some manual fiddling later, for example to -link files that weren't linked, and them llvm-dis them. +After setting that up, run your build system normally. Note the appearance of em++ instead of emcc for the C++ compiler. This is needed for cases where we get @@ -138,10 +126,7 @@ Options that are modified or new in %s include: passed into the emscripten compiler --typed-arrays <mode> 0: no typed arrays 1: parallel typed arrays - 2: shared typed arrays (default) - --llvm-opts <mode> 0: none (default) - 1: safe/portable - 2: unsafe/unportable + 2: shared (C-like) typed arrays (default) The target file, if specified (-o <target>), defines what will be generated: @@ -279,6 +264,11 @@ elif use_compiler: if newargs[i] == '-s': settings_changes.append(newargs[i+1]) newargs[i] = newargs[i+1] = '' + elif newargs[i].startswith('--typed-arrays'): + assert '=' not in newargs[i], 'Invalid typed arrays parameter (do not use "=")' + settings_changes.append('USE_TYPED_ARRAYS=' + newargs[i+1]) + newargs[i] = '' + newargs[i+1] = '' newargs = [ arg for arg in newargs if arg is not '' ] newargs += CC_ADDITIONAL_ARGS diff --git a/tests/runner.py b/tests/runner.py index 33e434e4..2a5be232 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -4896,33 +4896,7 @@ Most normal gcc/g++ options will work, for example: Options that are modified or new in %s include: -O0 No optimizations (default) - -O1 Simple optimizations and no runtime assertions - -O2 As -O1, plus code flow optimization (relooper) - Warning: Compiling with this takes a long time! - -O3 As -O2, plus dangerous optimizations that may - break things - -s OPTION=VALUE JavaScript code generation option - passed into the emscripten compiler - --typed-arrays <mode> 0: no typed arrays - 1: parallel typed arrays - 2: shared typed arrays (default) - --llvm-opts <mode> 0: none (default) - 1: safe/portable - 2: unsafe/unportable - -The target file, if specified (-o <target>), defines what will -be generated: - - <name>.js JavaScript (default) - <name>.o LLVM bitcode - <name>.bc LLVM bitcode - <name>.html HTML with embedded JavaScript - -The -c option (which tells gcc not to run the linker) will -also cause LLVM bitcode to be generated, as %s only generates -JavaScript in the final linking stage of building. - -''' % (shortcompiler, shortcompiler, shortcompiler), output[0], output[1]) +''' % (shortcompiler, shortcompiler), output[0], output[1]) # emcc src.cpp ==> writes to a.out.js, much like gcc clear() @@ -4965,12 +4939,15 @@ JavaScript in the final linking stage of building. if opt_level >= 1 and opt_level < 3: assert 'HEAP8[HEAP32[' in generated, 'eliminator should create compound expressions, and fewer one-time vars' # TODO: find a way to check it even with closure if opt_level >= 3: assert 'Module._main = ' in generated, 'closure compiler should have been run' - # emcc -s RELOOP=1 src.cpp ==> should pass -s to emscripten.py + # emcc -s RELOOP=1 src.cpp ==> should pass -s to emscripten.py. --typed-arrays is a convenient alias for -s USE_TYPED_ARRAYS for params, test, text in [ (['-s', 'USE_TYPED_ARRAYS=0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'), (['-s', 'USE_TYPED_ARRAYS=1'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'), ([], lambda generated: 'Module["_dump"]' not in generated, 'dump is not exported by default'), (['-s', 'EXPORTED_FUNCTIONS=["_main", "_dump"]'], lambda generated: 'Module["_dump"]' in generated, 'dump is now exported') + (['--typed-arrays', '0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'), + (['--typed-arrays', '1'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'), + (['--typed-arrays', '2'], lambda generated: 'new Uint16Array' in generated and 'new Uint32Array' in generated, 'typed arrays 2 selected'), ]: clear() output = Popen([compiler, path_from_root('tests', 'hello_world_loop.cpp')] + params, stdout=PIPE, stderr=PIPE).communicate() |