Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "-Ofast" #21494

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,12 @@ def consume_arg_file():
requested_level = 1
settings.SHRINK_LEVEL = 0
settings.DEBUG_LEVEL = max(settings.DEBUG_LEVEL, 1)
elif requested_level == 'fast':
# TODO(https://github.com/emscripten-core/emscripten/issues/21497):
# If we ever map `-ffast-math` to `wasm-opt --fast-math` then
# then we should enable that too here.
requested_level = 3
settings.SHRINK_LEVEL = 0
sbc100 marked this conversation as resolved.
Show resolved Hide resolved
else:
settings.SHRINK_LEVEL = 0
settings.OPT_LEVEL = validate_arg_level(requested_level, 3, 'invalid optimization level: ' + arg, clamp=True)
Expand Down
14 changes: 7 additions & 7 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ def test_dumpmachine(self):

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

@parameterized({
'c': [EMCC, '.c'],
'cxx': [EMXX, '.cpp']})
'cxx': [EMXX, '.cpp']
})
def test_emcc_3(self, compiler, suffix):
# handle singleton archives
self.run_process([compiler, '-c', test_file('hello_world' + suffix), '-o', 'a.o'])
Expand All @@ -538,9 +540,7 @@ def test_emcc_3(self, compiler, suffix):
delete_file(path)

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

def test_os_oz(self):
for opt in ['-O1', '-O2', '-Os', '-Oz', '-O3', '-Og']:
def test_opt_levels(self):
for opt in ['-O1', '-O2', '-Os', '-Oz', '-O3', '-Og', '-Ofast']:
print(opt)
proc = self.run_process([EMCC, '-v', test_file('hello_world.c'), opt], stderr=PIPE)
self.assertContained(opt, proc.stderr)
Expand Down
Loading