Skip to content

Deprecate unused --llvm-opts command line argument #13750

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

Merged
merged 1 commit into from
Mar 24, 2021
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
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Current Trunk
- Lists that are passed on the command line can now skip the opening an closing
braces, allowing for simpler, more readable settings. e.g.
`-s EXPORTED_FUNCTIONS=foo,bar`
- Remove/deprecate no longer used `--llvm-opts` command line option. Any
arguments not processed by emcc will be passed through to clang directly
these days.
- Values returned from `sysconf` now more closely match the definitions found in
header files and in upstream musl (#13713).
- `DISABLE_EXCEPTION_CATCHING=2` is now deprecated since it can be inferred from
Expand Down
20 changes: 0 additions & 20 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,6 @@ Options that are modified or new in *emcc* are listed below:
happens in "-O2" and above, and when no "-g" option was specified
to prevent minification.

"--llvm-opts <level>"
[compile+link] Enables LLVM optimizations, relevant when we call
the LLVM optimizer (which is done when building source files to
object code). Possible "level" values are:

* "0": No LLVM optimizations (default in -O0).

* "1": LLVM "-O1" optimizations (default in -O1).

* "2": LLVM "-O2" optimizations.

* "3": LLVM "-O3" optimizations (default in -O2+).

You can also specify arbitrary LLVM options, e.g.:

--llvm-opts "['-O3', '-somethingelse']"

You normally don't need to specify this option, as "-O" with an
optimization level will set a good value.

"-flto"
[compile+link] Enables link-time optimizations (LTO).

Expand Down
10 changes: 1 addition & 9 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def __init__(self):
self.profiling_funcs = False
self.tracing = False
self.emit_symbol_map = False
self.llvm_opts = None
self.use_closure_compiler = None
self.closure_args = []
self.js_transform = None
Expand Down Expand Up @@ -1010,11 +1009,6 @@ def uniquename(name):
if options.thread_profiler:
options.post_js += open(shared.path_from_root('src', 'threadprofiler.js')).read() + '\n'

if options.llvm_opts is None:
options.llvm_opts = LLVM_OPT_LEVEL[shared.Settings.OPT_LEVEL]
elif type(options.llvm_opts) == int:
options.llvm_opts = ['-O%d' % options.llvm_opts]

if options.memory_init_file is None:
options.memory_init_file = shared.Settings.OPT_LEVEL >= 2

Expand Down Expand Up @@ -2559,12 +2553,10 @@ def consume_arg_file():
# Let -O default to -O2, which is what gcc does.
options.requested_level = arg[2:] or '2'
if options.requested_level == 's':
options.llvm_opts = ['-Os']
options.requested_level = 2
shared.Settings.SHRINK_LEVEL = 1
settings_changes.append('INLINING_LIMIT=50')
elif options.requested_level == 'z':
options.llvm_opts = ['-Oz']
options.requested_level = 2
shared.Settings.SHRINK_LEVEL = 2
settings_changes.append('INLINING_LIMIT=25')
Expand All @@ -2573,7 +2565,7 @@ def consume_arg_file():
logger.warning('--js-opts ignored when using llvm backend')
consume_arg()
elif check_arg('--llvm-opts'):
options.llvm_opts = parse_value(consume_arg(), expect_list=True)
diagnostics.warning('deprecated', '--llvm-opts is deprecated. All non-emcc args are passed through to clang.')
elif arg.startswith('-flto'):
if '=' in arg:
shared.Settings.LTO = arg.split('=')[1]
Expand Down
2 changes: 0 additions & 2 deletions site/source/docs/compiling/Building-Projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ However, sometimes you may want slightly different optimizations on certain file
.. note:: Unfortunately each build-system defines its own mechanisms for setting compiler and optimization methods. **You will need to work out the correct approach to set the LLVM optimization flags for your system**.

- Some build systems have a flag like ``./configure --enable-optimize``.
- You can control whether LLVM optimizations are run using ``--llvm-opts N`` where N is an integer in the range 0-3. Sending ``-O2 --llvm-opts 0`` to *emcc* during all compilation stages will disable LLVM optimizations but utilize JavaScript optimizations. This can be useful when debugging a build failure.


JavaScript/WebAssembly optimizations are specified in the final step (sometimes called "link", as that step typically also links together a bunch of files that are all compiled together into one JavaScript/WebAssembly output). For example, to compile with :ref:`-O1 <emcc-O1>`:

Expand Down
17 changes: 0 additions & 17 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,6 @@ Options that are modified or new in *emcc* are listed below:

.. note:: This is only relevant when :term:`minifying` global names, which happens in ``-O2`` and above, and when no ``-g`` option was specified to prevent minification.

.. _emcc-llvm-opts:

``--llvm-opts <level>``
[compile+link]
Enables LLVM optimizations, relevant when we call the LLVM optimizer (which is done when building source files to object code). Possible ``level`` values are:

- ``0``: No LLVM optimizations (default in -O0).
- ``1``: LLVM ``-O1`` optimizations (default in -O1).
- ``2``: LLVM ``-O2`` optimizations.
- ``3``: LLVM ``-O3`` optimizations (default in -O2+).

You can also specify arbitrary LLVM options, e.g.::

--llvm-opts "['-O3', '-somethingelse']"

You normally don't need to specify this option, as ``-O`` with an optimization level will set a good value.

.. _emcc-lto:

``-flto``
Expand Down
2 changes: 1 addition & 1 deletion tests/fuzz/23.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,5 +476,5 @@ int main (int argc, char* argv[])
return 0;
}

// /usr/bin/python Dev/emscripten/emcc -O2 --llvm-opts 3 Dev/emscripten/tests/fuzz/temp_fuzzcode29254_.cpp -o Dev/emscripten/tests/fuzz/temp_fuzzcode29254_.js -I Dev/csmith/runtime
// /usr/bin/python Dev/emscripten/emcc -O2 Dev/emscripten/tests/fuzz/temp_fuzzcode29254_.cpp -o Dev/emscripten/tests/fuzz/temp_fuzzcode29254_.js -I Dev/csmith/runtime

2 changes: 1 addition & 1 deletion tests/fuzz/24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4808,5 +4808,5 @@ XXX percentage an existing variable is used: 85.1
********************* end of statistics **********************/


// /usr/bin/python /media/alon/2f9a30d7-6124-42d9-87c5-3c80cb70ec54/home/alon/Dev/emscripten/emcc -O3 --llvm-opts 3 newfail_11275_1.cpp -I /home/alon/Dev/csmith/runtime -s ALLOW_MEMORY_GROWTH=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_WHITELIST='["_main"]'
// /usr/bin/python /media/alon/2f9a30d7-6124-42d9-87c5-3c80cb70ec54/home/alon/Dev/emscripten/emcc -O3 newfail_11275_1.cpp -I /home/alon/Dev/csmith/runtime -s ALLOW_MEMORY_GROWTH=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_WHITELIST='["_main"]'

6 changes: 1 addition & 5 deletions tests/fuzz/csmith_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
opts = '-Oz'
print('opt level:', opts)

llvm_opts = []
if random.random() < 0.5:
llvm_opts = ['--llvm-opts', str(random.randint(0, 3))]

print('Tried %d, notes: %s' % (tried, notes))
print('1) Generate source')
extra_args = []
Expand Down Expand Up @@ -115,7 +111,7 @@

def try_js(args=[]):
shared.try_delete(filename + '.js')
js_args = [shared.EMCC, fullname, '-o', filename + '.js'] + [opts] + llvm_opts + CSMITH_CFLAGS + args + ['-w']
js_args = [shared.EMCC, fullname, '-o', filename + '.js'] + [opts] + CSMITH_CFLAGS + args + ['-w']
if TEST_BINARYEN:
if random.random() < 0.5:
js_args += ['-g']
Expand Down
6 changes: 2 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6589,7 +6589,7 @@ def test_demangle_stacks(self, extra_args):
self.set_setting('DEMANGLE_SUPPORT')
self.set_setting('ASSERTIONS')
# ensure function names are preserved
self.emcc_args += ['--profiling-funcs', '--llvm-opts', '0']
self.emcc_args += ['--profiling-funcs']
self.do_core_test('test_demangle_stacks.cpp', assert_returncode=NON_ZERO)
if not self.has_changed_setting('ASSERTIONS'):
print('without assertions, the stack is not printed, but a message suggesting assertions is')
Expand All @@ -6598,9 +6598,7 @@ def test_demangle_stacks(self, extra_args):

def test_demangle_stacks_symbol_map(self):
self.set_setting('DEMANGLE_SUPPORT')
if '-O' in str(self.emcc_args) and '-O0' not in self.emcc_args and '-O1' not in self.emcc_args and '-g' not in self.emcc_args:
self.emcc_args += ['--llvm-opts', '0']
else:
if '-O' not in str(self.emcc_args) or '-O0' in self.emcc_args or '-O1' in self.emcc_args or '-g' in self.emcc_args:
self.skipTest("without opts, we don't emit a symbol map")
self.emcc_args += ['--emit-symbol-map']
self.do_runf(test_file('core', 'test_demangle_stacks.cpp'), 'abort', assert_returncode=NON_ZERO)
Expand Down