aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-05 20:40:36 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-05 20:46:47 -0800
commit97407b218c6d816e964f1faa1420db46ea1fec3c (patch)
tree0d8f80bec7b58bb5f021ddf88227799d35314061
parent3a2cf7e0b1e66dfdccbb49d0ef38b20d0369a533 (diff)
make -Os like -O2 but also disable inlining
-rwxr-xr-xemcc17
-rwxr-xr-xtests/runner.py2
2 files changed, 11 insertions, 8 deletions
diff --git a/emcc b/emcc
index f644b924..d773dd85 100755
--- a/emcc
+++ b/emcc
@@ -706,19 +706,21 @@ try:
absolute_warning_shown = False
+ settings_changes = []
+
for i in range(len(newargs)):
newargs[i] = newargs[i].strip() # On Windows Vista (and possibly others), excessive spaces in the command line leak into the items in this array, so trim e.g. 'foo.cpp ' -> 'foo.cpp'
if newargs[i].startswith('-O'):
# Let -O default to -O2, which is what gcc does.
requested_level = newargs[i][2:] or '2'
if requested_level == 's':
- print >> sys.stderr, 'emcc: warning: -Os is ignored (use -O0, -O1, -O2)'
- else:
- try:
- opt_level = int(requested_level)
- assert 0 <= opt_level <= 3
- except:
- raise Exception('Invalid optimization level: ' + newargs[i])
+ requested_level = 2
+ settings_changes.append('INLINING_LIMIT=50')
+ try:
+ opt_level = int(requested_level)
+ assert 0 <= opt_level <= 3
+ except:
+ raise Exception('Invalid optimization level: ' + newargs[i])
newargs[i] = ''
elif newargs[i].startswith('--llvm-opts'):
check_bad_eq(newargs[i])
@@ -842,7 +844,6 @@ try:
if closure:
assert os.path.exists(shared.CLOSURE_COMPILER), 'emcc: fatal: Closure compiler (%s) does not exist' % shared.CLOSURE_COMPILER
- settings_changes = []
for i in range(len(newargs)):
if newargs[i] == '-s':
if is_minus_s_for_emcc(newargs, i):
diff --git a/tests/runner.py b/tests/runner.py
index e4c7a1e1..5adafddd 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -8510,6 +8510,7 @@ Options that are modified or new in %s include:
(['-o', 'something.js', '-O2'], 2, None, 0, 1),
(['-o', 'something.js', '-O2', '--closure', '0'], 2, None, 0, 0),
(['-o', 'something.js', '-O2', '-g'], 2, None, 0, 0),
+ (['-o', 'something.js', '-Os'], 2, None, 0, 1),
(['-o', 'something.js', '-O3'], 3, None, 1, 1),
(['-o', 'something.js', '-O3', '--closure', '0'], 3, None, 0, 0),
# and, test compiling to bitcode first
@@ -8561,6 +8562,7 @@ Options that are modified or new in %s include:
(['-s', 'ASM_JS=1', '-O2', '-g'], lambda generated: 'var i1 = 0' not in generated, 'registerize is cancelled by -g'),
(['-s', 'INLINING_LIMIT=0'], lambda generated: 'function _dump' in generated, 'no inlining without opts'),
(['-O3', '-s', 'INLINING_LIMIT=0', '--closure', '0'], lambda generated: 'function _dump' not in generated, 'lto/inlining'),
+ (['-Os', '--llvm-lto', '1'], lambda generated: 'function _dump' in generated, '-Os disables inlining'),
(['-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'),