Skip to content

Commit 1c46054

Browse files
committed
Add support for "-Ofast"
Based on #11884
1 parent 71cee0e commit 1c46054

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

emcc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,12 @@ def consume_arg_file():
11471147
requested_level = 1
11481148
settings.SHRINK_LEVEL = 0
11491149
settings.DEBUG_LEVEL = max(settings.DEBUG_LEVEL, 1)
1150+
elif requested_level == 'fast':
1151+
# TODO(https://github.com/emscripten-core/emscripten/issues/21497):
1152+
# If we ever map `-ffast-math` to `wasm-opt --fast-math` then
1153+
# then we should enable that too here.
1154+
requested_level = 3
1155+
settings.SHRINK_LEVEL = 0
11501156
else:
11511157
settings.SHRINK_LEVEL = 0
11521158
settings.OPT_LEVEL = validate_arg_level(requested_level, 3, 'invalid optimization level: ' + arg, clamp=True)

test/test_other.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ def test_dumpmachine(self):
490490

491491
@parameterized({
492492
'c': [EMCC, '.c'],
493-
'cxx': [EMXX, '.cpp']})
493+
'cxx': [EMXX, '.cpp']
494+
})
494495
def test_emcc_2(self, compiler, suffix):
495496
# emcc src.cpp -c and emcc -c src.cpp -o src.[o|foo|so] ==> should always give an object file
496497
for args in [[], ['-o', 'src.o'], ['-o', 'src.foo'], ['-o', 'src.so']]:
@@ -513,7 +514,8 @@ def test_bc_output_warning(self):
513514

514515
@parameterized({
515516
'c': [EMCC, '.c'],
516-
'cxx': [EMXX, '.cpp']})
517+
'cxx': [EMXX, '.cpp']
518+
})
517519
def test_emcc_3(self, compiler, suffix):
518520
# handle singleton archives
519521
self.run_process([compiler, '-c', test_file('hello_world' + suffix), '-o', 'a.o'])
@@ -538,9 +540,7 @@ def test_emcc_3(self, compiler, suffix):
538540
delete_file(path)
539541

540542
@is_slow_test
541-
@parameterized({
542-
'c': [EMCC],
543-
'cxx': [EMXX]})
543+
@with_both_compilers
544544
def test_emcc_4(self, compiler):
545545
# Optimization: emcc src.cpp -o something.js [-Ox]. -O0 is the same as not specifying any optimization setting
546546
# link_param are used after compiling first
@@ -4687,9 +4687,8 @@ def test_fs_after_main(self):
46874687
self.run_process([EMXX, test_file('fs_after_main.cpp')])
46884688
self.assertContained('Test passed.', self.run_js('a.out.js'))
46894689

4690-
def test_os_oz(self):
4691-
for opt in ['-O1', '-O2', '-Os', '-Oz', '-O3', '-Og']:
4692-
print(opt)
4690+
def test_opt_levels(self):
4691+
for opt in ['-O1', '-O2', '-Os', '-Oz', '-O3', '-Og', '-Ofast']:
46934692
proc = self.run_process([EMCC, '-v', test_file('hello_world.c'), opt], stderr=PIPE)
46944693
self.assertContained(opt, proc.stderr)
46954694
self.assertContained('hello, world!', self.run_js('a.out.js'))

0 commit comments

Comments
 (0)