diff options
-rwxr-xr-x | em++ (renamed from em++.py) | 0 | ||||
-rwxr-xr-x | emcc (renamed from emcc.py) | 34 | ||||
-rw-r--r-- | tests/runner.py | 7 |
3 files changed, 34 insertions, 7 deletions
@@ -96,24 +96,48 @@ import sys import os import subprocess +DEBUG = 0 + ################### XXX print >> sys.stderr, '***This is a WORK IN PROGRESS***' ################### XXX -print >> sys.stderr, 'emcc.py: ', ' '.join(sys.argv) +if DEBUG: print >> sys.stderr, 'emcc.py: ', ' '.join(sys.argv) __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +# Handle some global flags +if sys.argv[1] == '--version': + print '''emcc 2.X +This is drop-in compiler replacement for Emscripten +http://emscripten.org + ''' + exit(0) +elif sys.argv[1] == '--help': + print '''OVERVIEW: Emscripten "gcc-compatible" driver script, using LLVM/Clang + Many but not all gcc options can be used. + +USAGE: emcc [options] <inputs> + +OPTIONS: + -O0 No optimization. Enables runtime assertions. This is the default. + -O1 Basic optimizations. Disables runtime assertions. + -O2 Like -O2, but includes loop recreation optimization (relooper). + -O3 Like -O3, but includes closure compiler advanced optimizations. + Use with care and read the closure compiler docs. +''' + exit(0) + # If this is a configure-type thing, just do that CONFIGURE_CONFIG = os.environ.get('EMMAKEN_JUST_CONFIGURE') CMAKE_CONFIG = 'CMakeFiles/cmTryCompileExec.dir' in ' '.join(sys.argv)# or 'CMakeCCompilerId' in ' '.join(sys.argv) if CONFIGURE_CONFIG or CMAKE_CONFIG: compiler = 'g++' if 'CXXCompiler' in ' '.join(sys.argv) or os.environ.get('EMMAKEN_CXX') else 'gcc' cmd = [compiler] + EMSDK_OPTS + sys.argv[1:] - print >> sys.stderr, 'emcc.py, just configuring: ', cmd + if DEBUG: print >> sys.stderr, 'emcc.py, just configuring: ', cmd exit(os.execvp(compiler, cmd)) try: @@ -207,14 +231,14 @@ try: newargs = sys.argv[1:] for i in range(len(newargs)): if newargs[i].startswith('-O'): - print >> sys.stderr, 'emcc.py: WARNING: Optimization flags (-Ox) are ignored in emcc. Tell emscripten.py to do that, or run LLVM opt.' + if DEBUG: print >> sys.stderr, 'emcc.py: WARNING: Optimization flags (-Ox) are ignored in emcc. Tell emscripten.py to do that, or run LLVM opt.' newargs[i] = '' newargs = [ arg for arg in newargs if arg is not '' ] + CC_ADDITIONAL_ARGS newargs.append('-emit-llvm') if not use_linker: newargs.append('-c') else: - print >> sys.stderr, 'Just copy.' + if DEBUG: print >> sys.stderr, 'Just copy.' shutil.copy(sys.argv[-1], sys.argv[-2]) exit(0) @@ -222,7 +246,7 @@ try: #f.write('Calling: ' + ' '.join(newargs) + '\n\n') #f.close() - print >> sys.stderr, "Running:", call, ' '.join(newargs) + if DEBUG: print >> sys.stderr, "Running:", call, ' '.join(newargs) os.execvp(call, [call] + newargs) except Exception, e: diff --git a/tests/runner.py b/tests/runner.py index 480e77ae..121f20b5 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -4457,17 +4457,20 @@ TT = %s class other(RunnerCore): def test_emcc(self): pass + # TODO: make sure all of these match gcc + # -- options: check these, warn about errors. valid gcc ones are help, version. Ours should be -- too, not -. # emcc src.cpp ==> should give a .js file # emcc -O0 src.cpp ==> same as without -O0 (i.e., assertions, etc.) # emcc -O1 src.cpp ==> no assertions, basic optimizations, plus eliminator, but no reloop # emcc -O2 src.cpp ==> plus reloop # emcc -O3 src.cpp ==> plus closure compiler - # emcc -typed-arrays=x .. ==> should use typed arrays - # emcc -llvm-opts=x .. ==> pick level of LLVM optimizations (default is 0, to be safe) + # emcc --typed-arrays=x .. ==> should use typed arrays + # emcc --llvm-opts=x .. ==> pick level of LLVM optimizations (default is 0, to be safe) # emcc src.cpp -c ==> should give a .bc file # linking - TODO # annotate each .bc with emscripten info, like "compiled with -O2: do the O2 opts when going to final .js" # warn if linking files with different annotations etc. + # use llvm metadata, example: !0 = metadata !{i32 720913, i32 0, i32 4, metadata !"/dev/shm/tmp/src.cpp", metadata !"/dev/shm/tmp", metadata !"clang version 3.0 (tags/RELEASE_30/rc3)", i1 true, i1 false, metadata !"EMSCRIPTEN:O3", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] # TODO: when ready, switch tools/shared building to use emcc over emmaken def test_eliminator(self): |