diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-11-15 09:56:44 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-11-15 09:56:44 -0800 |
commit | 59612a8c0bb801c604542f6b7f560a8bfa5380cd (patch) | |
tree | 0a5c991f1018b4466b207104a984f5285b8edcfb | |
parent | 707845b881a6b9eaa75eb6e7273365721ada1fd9 (diff) |
ignore and warn about -Ox in emmaken
-rwxr-xr-x | tools/emmaken.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tools/emmaken.py b/tools/emmaken.py index ca02f258..f3ecefce 100755 --- a/tools/emmaken.py +++ b/tools/emmaken.py @@ -13,6 +13,14 @@ For example, compilation will be translated into calls to llvm-gcc with -emit-llvm, and linking will be translated into calls to llvm-link, and so forth. +emmaken 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: * With configure, do something like @@ -97,7 +105,6 @@ try: if os.environ.get('EMMAKEN_CXX'): CC = CXX - CC_ARG_SKIP = ['-O1', '-O2', '-O3'] CC_ADDITIONAL_ARGS = COMPILER_OPTS # + ['-g']? ALLOWED_LINK_ARGS = ['-f', '-help', '-o', '-print-after', '-print-after-all', '-print-before', '-print-before-all', '-time-passes', '-v', '-verify-dom-info', '-version' ] @@ -170,11 +177,15 @@ try: newargs.append(arg) elif not header: call = CXX if use_cxx else CC - newargs = [ arg for arg in sys.argv[1:] if arg not in CC_ARG_SKIP ] + CC_ADDITIONAL_ARGS - if 'conftest.c' not in files: - newargs.append('-emit-llvm') - if not use_linker: - newargs.append('-c') + newargs = sys.argv[1:] + for i in range(len(newargs)): + if newargs[i].startswith('-O'): + print >> sys.stderr, 'emmaken.py: WARNING: Optimization flags (-Ox) are ignored in emmaken. 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.' shutil.copy(sys.argv[-1], sys.argv[-2]) |