aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc14
-rwxr-xr-xtests/runner.py8
2 files changed, 17 insertions, 5 deletions
diff --git a/emcc b/emcc
index 4a821591..19f07fbd 100755
--- a/emcc
+++ b/emcc
@@ -508,11 +508,15 @@ try:
for i in range(len(newargs)):
if newargs[i].startswith('-O'):
- try:
- opt_level = int(newargs[i][2])
- assert 0 <= opt_level <= 3
- except:
- raise Exception('Invalid optimization level: ' + newargs[i])
+ requested_level = newargs[i][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])
newargs[i] = ''
elif newargs[i].startswith('--llvm-opts'):
check_bad_eq(newargs[i])
diff --git a/tests/runner.py b/tests/runner.py
index 37a8d597..02e0428e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7178,6 +7178,14 @@ f.close()
# 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.
+ def test_Os(self):
+ for opt in ['s', '0']:
+ output = Popen(['python', EMCC, path_from_root('tests', 'hello_world.c'), '-O' + opt], stdout=PIPE, stderr=PIPE).communicate()
+ assert len(output[0]) == 0, output[0]
+ assert ('emcc: warning: -Os is ignored (use -O0, -O1, -O2)' in output[1]) == (opt == 's'), 'warn on -Os when necessary'
+ assert os.path.exists('a.out.js'), '\n'.join(output)
+ self.assertContained('hello, world!', run_js('a.out.js'))
+
def test_catch_undef(self):
open(os.path.join(self.get_dir(), 'test.cpp'), 'w').write(r'''
#include <vector>