5

How to check if a pallet can be compiled to no-std/WASM?

I ran:

cargo build --no-default-features --target wasm32-unknown-unknown

But this didn't work. IIUC, we need some ENV to build the pallet to WASM.

And I don't want to add this pallet to runtime and build the entire runtime to verify this, which takes a lot of time each time.

I can compile the entire runtime, but if I try to compile the pallet with the command above, I got:

The following warnings were emitted during compilation:

warning: src/helpers.c:1:10: fatal error: 'setjmp.h' file not found
warning: #include <setjmp.h>
warning:          ^~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `wasmtime-runtime v1.0.2`

Caused by:
  process didn't exit successfully: `/root/code/darwinia-network/darwinia/target/debug/build/wasmtime-runtime-d7265199eb92a3b8/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=src/helpers.c
  TARGET = Some("wasm32-unknown-unknown")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DCFG_TARGET_OS_unknown" "-DCFG_TARGET_ARCH_wasm32" "-o" "/root/code/darwinia-network/darwinia/target/wasm32-unknown-unknown/debug/build/wasmtime-runtime-3f0543a6492357d6/out/src/helpers.o" "-c" "src/helpers.c"
  cargo:warning=src/helpers.c:1:10: fatal error: 'setjmp.h' file not found
  cargo:warning=#include <setjmp.h>
  cargo:warning=         ^~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DCFG_TARGET_OS_unknown" "-DCFG_TARGET_ARCH_wasm32" "-o" "/root/code/darwinia-network/darwinia/target/wasm32-unknown-unknown/debug/build/wasmtime-runtime-3f0543a6492357d6/out/src/helpers.o" "-c" "src/helpers.c" with args "clang" did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...

I added the setjmp.h to the path. And the problem above was resolved.

But I got a lot of xxx not found issues. And I realized those .h are all lib32. So, I believe we need an ENV to compile this. x86_64 host can not compile this natively.

6

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.