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

Instruction requires: bulk-memory #23456

Open
fernwehist opened this issue Jan 18, 2025 · 7 comments
Open

Instruction requires: bulk-memory #23456

fernwehist opened this issue Jan 18, 2025 · 7 comments

Comments

@fernwehist
Copy link

fernwehist commented Jan 18, 2025

I just updated Emscripten from 3.1.57 to 4.0.1, and I got an error about bulk-memory
instruction while compiling C and C++ to WASM.

I used clang 19.1.7 and failed
I updated my clang 20-init and also failed

I attach the log of emcc, and same error with em++:

Version of emscripten/emsdk:
~$emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.1-git (89ce854)
clang version 19.1.7 (/home/runner/work/llvm-project/llvm-project/clang cd708029e0b2869e80abe31ddb175f7c35361f90)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/x/WASM/packages/clang_llvm_19.1.7/bin

Failing command line in full:
~$emcc ./demo/hello_world_c.c -o ./demo/build/hello_world_c_emscripten.wasm -sWASM=1
emcc: warning: LLVM version for clang executable "/home/x/WASM/packages/clang_llvm_19.1.7/bin/clang" appears incorrect (seeing "19.1", expected "20") [-Wversion-check]
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libc-debug.a... (this will be cached in "/home/x/WASM/packages/emscripten_4.0.1/emscripten/cache/sysroot/lib/wasm32-emscripten/libc-debug.a" for subsequent builds)
../../../system/lib/libc/emscripten_memcpy_bulkmem.S:19:5: error: instruction requires: bulk-memory
memory.copy 0, 0
^
../../../system/lib/libc/emscripten_memcpy_bulkmem.S:22:3: error: 3 superfluous return values
end_function
^
../../../system/lib/libc/emscripten_memset_bulkmem.S:19:4: error: instruction requires: bulk-memory
memory.fill 0
^
../../../system/lib/libc/emscripten_memset_bulkmem.S:22:3: error: 3 superfluous return values
end_function
^
emcc: error: subprocess 17/17 failed (returned 1)! (cmdline: /home/x/WASM/packages/emscripten_4.0.1/emscripten/emcc -c -Wall -fno-unroll-loops -std=c99 -D_XOPEN_SOURCE=700 -Wno-unused-result -fno-inline-functions -fno-builtin -Wno-ignored-attributes -Wno-macro-redefined -Wno-shift-op-parentheses -Wno-string-plus-int -Wno-missing-braces -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-pointer-sign -g -sSTRICT -Werror -I/home/x/WASM/packages/emscripten_4.0.1/emscripten/system/lib/libc/musl/src/internal -I/home/x/WASM/packages/emscripten_4.0.1/emscripten/system/lib/libc/musl/src/include -I/home/x/WASM/packages/emscripten_4.0.1/emscripten/system/lib/libc/musl/include -I/home/x/WASM/packages/emscripten_4.0.1/emscripten/system/lib/libc -I/home/x/WASM/packages/emscripten_4.0.1/emscripten/system/lib/pthread -ffile-prefix-map=/home/x/WASM/packages/emscripten_4.0.1/emscripten=/emsdk/emscripten -ffile-prefix-map=../../..=/emsdk/emscripten -fdebug-compilation-dir=/emsdk/emscripten -O2 ../../../system/lib/libc/emscripten_memcpy.c ../../../system/lib/libc/emscripten_memmove.c ../../../system/lib/libc/emscripten_memset.c ../../../system/lib/libc/emscripten_memcpy_bulkmem.S ../../../system/lib/libc/emscripten_memset_bulkmem.S ../../../system/lib/libc/emscripten_scan_stack.c)

Full link command and output with -v appended:

file attached: log_emcc_with_v_option.txt

log_emcc_with_v_option.txt

@sbc100
Copy link
Collaborator

sbc100 commented Jan 18, 2025

Emscripten is built to run on LLVM tip-of-tree (which is currently v20) and has bulk memory enabled by default. It looks like you are trying to use emscripten with LLVM 19.1.7 which is not going to work.

For more discussion on out support (or lack of it) for LLVM stable see #11362. I've recently started work on making that work: #23311. But for now I'm afraid this is WAI.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 18, 2025

I see from the output of your command you are even getting the corresponding warning message:

emcc: warning: LLVM version for clang executable "/home/x/WASM/packages/clang_llvm_19.1.7/bin/clang" appears incorrect (seeing "19.1", expected "20") [-Wversion-check]

@fernwehist
Copy link
Author

@sbc100 Yeah. I read that. Hmm but llvm 20 is still in progress I guess.
I will give a shot to build llvm20 :)

@sbc100
Copy link
Collaborator

sbc100 commented Jan 18, 2025

You can also install via emsdk which gives you prebuilt llvm and binaryen. Building you own llvm can be quite time consuming, and its not always easy to build the exact version that emscripten needs. If you use emsdk you always get a tests set of binaries.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 18, 2025

emscripten always uses the "in progress" or "tip-of-tree" version of llvm, and never (yet) the stable verison.

@fernwehist
Copy link
Author

UPDATE:

I updated my clang to 20-init, but still same error.
I will try use emscripten sdk instead.

@fernwehist
Copy link
Author

UPDATE:

SDK works well.
Hmm I will use emsdk instead of installing it manually.

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

2 participants