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

IndexError: list assignment index out of range in create_asm_consts_wasm #10148

Closed
akolybelnikov opened this issue Jan 5, 2020 · 11 comments
Closed

Comments

@akolybelnikov
Copy link

I'm getting the following error while trying to run a build:

Traceback (most recent call last):
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emcc.py", line 3560, in <module>
              sys.exit(run(sys.argv))
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emcc.py", line 2131, in run
              final = shared.Building.emscripten(final, target + '.mem', js_libraries)
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/tools/shared.py", line 2158, in emscripten
              emscripten.run(infile, outfile, memfile, js_libraries)
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emscripten.py", line 2606, in run
              return temp_files.run_and_clean(lambda: emscripter(
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/tools/tempfiles.py", line 105, in run_and_clean
              return func()
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emscripten.py", line 2607, in <lambda>
              infile, outfile_obj, memfile, libraries, shared.COMPILER_ENGINE, temp_files, shared.DEBUG)
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emscripten.py", line 2215, in emscript_wasm_backend
              asm_consts, asm_const_funcs = create_asm_consts_wasm(forwarded_json, metadata)
            File "/usr/local/Cellar/emscripten/1.38.44/libexec/emscripten.py", line 2347, in create_asm_consts_wasm
              asm_consts[int(k)] = const
          IndexError: list assignment index out of range

Here is my version info:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.44
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
shared:WARNING: LLVM version appears incorrect (seeing "9.0", expected "10.0")
shared:INFO: (Emscripten: Running sanity checks)

Also, I have no idea why it expects to see LLVM "10.0".

@tlively
Copy link
Member

tlively commented Jan 6, 2020

Did you install emscripten using emsdk? It looks like maybe you didn't due to the "LLVM version appears incorrect" warning. Since the LLVM wasm backend and Emscripten are co-developed, it is not expected that Emscripten will work with arbitrary LLVM versions. I strongly recommend installing via emsdk, but if you must assemble your own emscripten installation, then check for known-compatible versions of the various tools at https://chromium.googlesource.com/emscripten-releases/.

All upstream LLVM commits after the LLVM 9.0 branch point have version 10.0. Emscripten uses a tip-of-tree build of LLVM, so it expects one of these 10.0 builds.

@akolybelnikov
Copy link
Author

I haven't installed emsdk manually, it's being installed by cargo web. The warning about the LLVM version is ok, as long as it remains a warning, but the error above interferes with the build.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 9, 2020

From the error message it looks like you are using the homebrew version of emscripten, so it could be a configuration issue.

Can you trying installing via the emsdk and see if you get the same results? If that works then I would recommend filing a bug with the homebrew package.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 9, 2020

Ok I took a deeper look. I does indeed look like a mismatch between the version of binaryen and version of emscripten that are being used together.

The following change to binaryen changed the output in a way that would make the above exception occur:
WebAssembly/binaryen#2408

This change to binaryen landed 2 months ago after the 1.39.1 release of emscripten. By comparison your version of emscripten is 4 months old. So it looks like the homebrew package is somehow misconfigured.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 9, 2020

Can you run the failing command with EMCC_DEBUG=1 so I can confirm my suspicion?

@tlively
Copy link
Member

tlively commented Jan 9, 2020

@akolybelnikov I filed a bug on cargo-web about updating their Emscripten support. For now I would use emsdk to install Emscripten manually as a workaround https://emscripten.org/docs/getting_started/downloads.html.

@akolybelnikov
Copy link
Author

@sbc100 , here is the error with EMCC_DEBUG=1:

https://gist.github.com/akolybelnikov/6ba29273b16cc885d702de75fcebd6f8

@sbc100
Copy link
Collaborator

sbc100 commented Jan 9, 2020

Yes, it looks like you /usr/local/opt/binaryen is too recent. Do you know where that comes from?

@akolybelnikov
Copy link
Author

Honestly, no idea. I followed the docs here: https://github.com/koute/cargo-web and cargo installed Emscripten in the background, and that's what I have in .emscripten :

# Note: If you put paths relative to the home directory, do not forget
# os.path.expanduser

# Note: On Windows, remember to escape backslashes! I.e. LLVM='c:\llvm\'
# is not valid, but LLVM='c:\\llvm\\' and LLVM='c:/llvm/'
# are.

import os

# This is used by external projects in order to find emscripten.  It is not used
# by emscripten itself.
EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN', '/usr/local/Cellar/emscripten/1.38.44/libexec')) # directory

LLVM_ROOT = os.path.expanduser(os.getenv('LLVM', '/usr/local/opt/llvm/bin')) # directory
BINARYEN_ROOT = os.path.expanduser(os.getenv('BINARYEN', '/usr/local/opt/binaryen')) # if not set, we will use it from ports

# Add this if you have manually built the JS optimizer executable (in
# Emscripten/tools/optimizer) and want to run it from a custom location.
# Alternatively, you can set this as the environment variable
# EMSCRIPTEN_NATIVE_OPTIMIZER.
# EMSCRIPTEN_NATIVE_OPTIMIZER='/path/to/custom/optimizer(.exe)'

# See below for notes on which JS engine(s) you need
NODE_JS = os.path.expanduser(os.getenv('NODE', '/Users/akolybelnikov/.nvm/versions/node/v12.12.0/bin/node')) # executable
SPIDERMONKEY_ENGINE = [os.path.expanduser(os.getenv('SPIDERMONKEY', 'js'))] # executable
V8_ENGINE = os.path.expanduser(os.getenv('V8', 'd8')) # executable

JAVA = 'java' # executable

# CLOSURE_COMPILER = '..' # define this to not use the bundled version

################################################################################


# Pick the JS engine to use for running the compiler. This engine must exist, or
# nothing can be compiled.
#
# This should be left on node.js, as that is the VM we test running the
# compiler in. Other VMs may or may not work.

COMPILER_ENGINE = NODE_JS


# All JS engines to use when running the automatic tests. Not all the engines in
# this list must exist (if they don't, they will be skipped in the test runner).
#
# Recommendation: If you already have node installed, use that. If you can, also
#                 build spidermonkey from source as well to get more test
#                 coverage.

JS_ENGINES = [NODE_JS] # add this if you have spidermonkey installed too, SPIDERMONKEY_ENGINE]

# Other options
#
# FROZEN_CACHE = True # never clears the cache, and disallows building to the cache

@sbc100
Copy link
Collaborator

sbc100 commented Jan 16, 2020

I would file a bug with cargo-web then. It clear the binaryen version is wrong here. If its ok with you we can close this bug?

@akolybelnikov
Copy link
Author

Thank you all for the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants