google / XNNPACK

High-efficiency floating-point neural network inference operators for mobile, server, and Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when building to WASM SIMD with emsdk

Volcomix opened this issue · comments

I'm building TFLite with XNNPACK to WASM SIMD and the build is failing since this commit.

The build is relying on emsdk with a setup very similar to the one used in tfjs so I believe tfjs wasm backend will also face the same issue.

I opened an issue in the following repository where you could find more details about the investigation and the configuration.

[177 / 1,157] Compiling XNNPACK/src/f32-avgpool/9p8x-minmax-wasm-c1.c; 2s processwrapper-sandbox ... (2 actions running)
ERROR: /github/home/.cache/bazel/_bazel_root/0a7049196223eb41bb90aa2e8797b78e/external/XNNPACK/BUILD.bazel:4672:19: C++ compilation of rule '@XNNPACK//:wasm_ukernels' failed (Exit 1): emcc.sh failed: error executing command external/emsdk/emscripten_toolchain/emcc.sh '--sysroot=external/emscripten_bin_linux/emscripten/cache/sysroot' -fdiagnostics-color -fno-strict-aliasing -funsigned-char -no-canonical-prefixes -DNDEBUG ... (remaining 66 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox emcc.sh failed: error executing command external/emsdk/emscripten_toolchain/emcc.sh '--sysroot=external/emscripten_bin_linux/emscripten/cache/sysroot' -fdiagnostics-color -fno-strict-aliasing -funsigned-char -no-canonical-prefixes -DNDEBUG ... (remaining 66 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/XNNPACK/src/x32-pad/wasmsimd.c:32:24: error: implicit declaration of function 'wasm_v128_load32_splat' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  const v128_t vfill = wasm_v128_load32_splat(fill_value);
                       ^
external/XNNPACK/src/x32-pad/wasmsimd.c:32:24: note: did you mean 'wasm_v16x8_load_splat'?
external/emscripten_bin_linux/lib/clang/13.0.0/include/wasm_simd128.h:70:1: note: 'wasm_v16x8_load_splat' declared here
wasm_v16x8_load_splat(const void *__mem) {
^
external/XNNPACK/src/x32-pad/wasmsimd.c:32:16: error: initializing 'const v128_t' (vector of 4 'int32_t' values) with an expression of incompatible type 'int'
  const v128_t vfill = wasm_v128_load32_splat(fill_value);
               ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
emcc: error: '/github/home/.cache/bazel/_bazel_root/0a7049196223eb41bb90aa2e8797b78e/sandbox/processwrapper-sandbox/1173/execroot/__main__/external/emscripten_bin_linux/bin/clang -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -Xclang -iwithsysroot/include/SDL -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=14 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -flegacy-pass-manager -Werror=implicit-function-declaration --sysroot=/github/home/.cache/bazel/_bazel_root/0a7049196223eb41bb90aa2e8797b78e/external/emscripten_bin_linux/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat --sysroot=external/emscripten_bin_linux/emscripten/cache/sysroot -fdiagnostics-color -fno-strict-aliasing -funsigned-char -no-canonical-prefixes -DNDEBUG -fomit-frame-pointer -O3 -Wall -DPTHREADPOOL_NO_DEPRECATED_API -iquote external/XNNPACK -iquote bazel-out/wasm-opt/bin/external/XNNPACK -iquote external/FP16 -iquote bazel-out/wasm-opt/bin/external/FP16 -iquote external/FXdiv -iquote bazel-out/wasm-opt/bin/external/FXdiv -iquote external/pthreadpool -iquote bazel-out/wasm-opt/bin/external/pthreadpool -Ibazel-out/wasm-opt/bin/external/FP16/_virtual_includes/FP16 -Ibazel-out/wasm-opt/bin/external/FXdiv/_virtual_includes/FXdiv -Ibazel-out/wasm-opt/bin/external/pthreadpool/_virtual_includes/pthreadpool -isystem external/XNNPACK/include -isystem bazel-out/wasm-opt/bin/external/XNNPACK/include -isystem external/XNNPACK/src -isystem bazel-out/wasm-opt/bin/external/XNNPACK/src -isystem external/FP16/include -isystem bazel-out/wasm-opt/bin/external/FP16/include -isystem external/FXdiv/include -isystem bazel-out/wasm-opt/bin/external/FXdiv/include -isystem external/pthreadpool/include -isystem bazel-out/wasm-opt/bin/external/pthreadpool/include -Wno-error=unused-function -msimd128 -Iinclude -Isrc -std=c99 -O2 -iwithsysroot/include/c++/v1 -iwithsysroot/include/compat -iwithsysroot/include -isystem external/emscripten_bin_linux/lib/clang/13.0.0/include -MD -MF bazel-out/wasm-opt/bin/external/XNNPACK/_objs/wasm_ukernels/1/wasmsimd.d -c -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -Werror external/XNNPACK/src/x32-pad/wasmsimd.c -o bazel-out/wasm-opt/bin/external/XNNPACK/_objs/wasm_ukernels/1/wasmsimd.o' failed (1)
Target //:tflite-simd failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 59.927s, Critical Path: 8.59s
INFO: 52 processes: 6 internal, 46 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

You need to update the Emscripten SDK you use.

Thank you for the answer @Maratyszcza.
I followed these instructions from emsdk/bazel (same setup as tfjs) which is supposed to always load the latest version of emsdk (2.0.25 currently).

Is that what you mean?

I'm not sure we can specify versions for the inner tools packaged through this bazel toolchain.

I doubt this is the latest version. I references emsdk revision from March.

Indeed I followed the instructions without changing anything instead of specifying a more recent archive of emsdk. The bazel scripts only load the latest SDK prior to the specified archive.

Fixed in this commit: Volcomix/virtual-background@6bffb3e

Thank you for your help.