Skip to content

Commit

Permalink
Remove explicit support for JAVA and running closure compiler via java
Browse files Browse the repository at this point in the history
It should still be possible for a user to explictly run the java
version of closure using `EMCC_CLOSURE_ARGS=--platform=java` or
`--closure-args=--platform=java`, but this isn't something we need to
have explict support for and its not something we test.
  • Loading branch information
sbc100 committed Dec 14, 2023
1 parent e43f056 commit c5f8fa9
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 51 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ See docs/process.md for more on how version tagging works.
3.1.52 (in development)
-----------------------
- The `--default-obj-ext` command line flag was removed. (#20917)
- Remove JAVA from the list of `.emscripten` config file settings. In the
past we used this to run the java version of closure compiler.

3.1.51 - 12/13/23
-----------------
Expand Down
4 changes: 0 additions & 4 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ Options that are modified or new in *emcc* are listed below:
before the closure-compiled code runs, because then it will
reuse that variable.

* If closure compiler hits an out-of-memory, try adjusting
"JAVA_HEAP_SIZE" in the environment (for example, to 4096m for
4GB).

* Closure is only run if JavaScript opts are being done ("-O2" or
above).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ Open a terminal in the directory in which you installed Emscripten (on Windows o

.. note:: On Windows, invoke the tool with **emcc** instead of **./emcc**.

For example, the following output reports an installation where Java is missing:
For example, the following output reports that the correcrt version of clang
could not be found:

.. code-block:: none
:emphasize-lines: 3
emcc (Emscripten GCC-like replacement + linker emulating GNU ld) 1.21.0
shared:INFO: (Emscripten: Running sanity checks)
shared:WARNING: java does not seem to exist, required for closure compiler. -O2 and above will fail. You need to define JAVA in .emscripten
emcc: warning: LLVM version for clang executable "/usr/bin/clang" appears incorrect (seeing "16.0", expected "18") [-Wversion-check]
At this point you need to :ref:`Install and activate <fixing-missing-components-emcc>` any missing components. When everything is set up properly, ``emcc ---check`` should give no warnings, and if you just enter ``emcc`` (without any input files), it will give an error ::

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

- Consider using ``-sMODULARIZE`` when using closure, as it minifies globals to names that might conflict with others in the global scope. ``MODULARIZE`` puts all the output into a function (see ``src/settings.js``).
- Closure will minify the name of `Module` itself, by default! Using ``MODULARIZE`` will solve that as well. Another solution is to make sure a global variable called `Module` already exists before the closure-compiled code runs, because then it will reuse that variable.
- If closure compiler hits an out-of-memory, try adjusting ``JAVA_HEAP_SIZE`` in the environment (for example, to 4096m for 4GB).
- Closure is only run if JavaScript opts are being done (``-O2`` or above).

``--closure-args=<args>``
Expand Down
39 changes: 0 additions & 39 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,26 +454,6 @@ def get_closure_compiler():
return cmd


def check_closure_compiler(cmd, args, env, allowed_to_fail):
cmd = cmd + args + ['--version']
try:
output = run_process(cmd, stdout=PIPE, env=env).stdout
except Exception as e:
if allowed_to_fail:
return False
if isinstance(e, subprocess.CalledProcessError):
sys.stderr.write(e.stdout)
sys.stderr.write(str(e) + '\n')
exit_with_error('closure compiler (%s) did not execute properly!' % shared.shlex_join(cmd))

if 'Version:' not in output:
if allowed_to_fail:
return False
exit_with_error('unrecognized closure compiler --version output (%s):\n%s' % (shared.shlex_join(cmd), output))

return True


# Remove this once we require python3.7 and can use std.isascii.
# See: https://docs.python.org/3/library/stdtypes.html#str.isascii
def isascii(s):
Expand All @@ -488,25 +468,6 @@ def isascii(s):
def get_closure_compiler_and_env(user_args):
env = shared.env_with_node_in_path()
closure_cmd = get_closure_compiler()

native_closure_compiler_works = check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=True)
if not native_closure_compiler_works and not any(a.startswith('--platform') for a in user_args):
# Run with Java Closure compiler as a fallback if the native version does not work
user_args.append('--platform=java')
check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=False)

if config.JAVA and '--platform=java' in user_args:
# Closure compiler expects JAVA_HOME to be set *and* java.exe to be in the PATH in order
# to enable use the java backend. Without this it will only try the native and JavaScript
# versions of the compiler.
java_bin = os.path.dirname(config.JAVA)
if java_bin:
def add_to_path(dirname):
env['PATH'] = env['PATH'] + os.pathsep + dirname
add_to_path(java_bin)
java_home = os.path.dirname(java_bin)
env.setdefault('JAVA_HOME', java_home)

return closure_cmd, env


Expand Down
2 changes: 0 additions & 2 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
LLVM_ADD_VERSION = None
CLANG_ADD_VERSION = None
CLOSURE_COMPILER = None
JAVA = None
JS_ENGINES: List[List[str]] = []
WASMER = None
WASMTIME = None
Expand Down Expand Up @@ -130,7 +129,6 @@ def parse_config_file():
'LLVM_ADD_VERSION',
'CLANG_ADD_VERSION',
'CLOSURE_COMPILER',
'JAVA',
'JS_ENGINES',
'WASMER',
'WASMTIME',
Expand Down
2 changes: 0 additions & 2 deletions tools/config_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# This engine must exist, or nothing can be compiled.
NODE_JS = '{{{ NODE }}}' # executable

JAVA = 'java' # executable

################################################################################
#
# Test suite options:
Expand Down
2 changes: 1 addition & 1 deletion tools/scons/site_scons/site_tools/emscripten/emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def generate(env, emscripten_path=None, **kw):
'EMSCRIPTEN_SUPPRESS_USAGE_WARNING', 'NODE_PATH', 'EMCC_JSOPT_MIN_CHUNK_SIZE',
'EMCC_JSOPT_MAX_CHUNK_SIZE', 'EMCC_CORES', 'EMCC_NO_OPT_SORT',
'EMCC_BUILD_DIR', 'EMCC_DEBUG_SAVE', 'EMCC_SKIP_SANITY_CHECK',
'EM_PKG_CONFIG_PATH', 'EMCC_CLOSURE_ARGS', 'JAVA_HEAP_SIZE',
'EM_PKG_CONFIG_PATH', 'EMCC_CLOSURE_ARGS',
'EMCC_FORCE_STDLIBS', 'EMCC_ONLY_FORCED_STDLIBS', 'EM_PORTS', 'IDL_CHECKS', 'IDL_VERBOSE']:
if os.environ.get(var):
env['ENV'][var] = os.environ.get(var)
Expand Down

0 comments on commit c5f8fa9

Please sign in to comment.