Stream: wasmtime

Topic: Building for RISCV64 no longer working


view this post on Zulip Mats Brorsson (Nov 15 2023 at 09:47):

I have been able to build for RISCV64 before, but since the repo I updated yesterday (321294a5d21f7006a959ba378ebd32782a76d3d2) building on RISCV64 fails on wasmtime-runtime v16.0.0 with the following error:

error: failed to run custom build command for `wasmtime-runtime v16.0.0 (/home/ace5g/shared/wasmtime/crates/runtime)`

Caused by:
  process didn't exit successfully: `/home/ace5g/shared/wasmtime/target/release/build/wasmtime-runtime-d1197a7c0d12cf2e/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=src/helpers.c
  TARGET = Some("riscv64gc-unknown-linux-gnu")
  OPT_LEVEL = Some("3")
  HOST = Some("riscv64gc-unknown-linux-gnu")
  CC_riscv64gc-unknown-linux-gnu = None
  CC_riscv64gc_unknown_linux_gnu = None
  HOST_CC = None
  CC = Some("clang-15")
  CFLAGS_riscv64gc-unknown-linux-gnu = None
  CFLAGS_riscv64gc_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "clang-15" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=riscv64-unknown-linux-gnu" "-Wall" "-Wextra" "-DCFG_TARGET_OS_linux" "-DCFG_TARGET_ARCH_riscv64" "-DVERSIONED_SUFFIX=_16_0_0" "-o" "/home/ace5g/shared/wasmtime/target/release/build/wasmtime-runtime-2c4c2ea10989c7f1/out/src/helpers.o" "-c" "src/helpers.c"
  cargo:warning=src/helpers.c:55:7: error: __builtin_setjmp is not supported for the current target
  cargo:warning=  if (platform_setjmp(buf) != 0) {
  cargo:warning=      ^~~~~~~~~~~~~~~~~~~~
  cargo:warning=src/helpers.c:39:30: note: expanded from macro 'platform_setjmp'
  cargo:warning=#define platform_setjmp(buf) __builtin_setjmp(buf)
  cargo:warning=                             ^~~~~~~~~~~~~~~~~~~~~
  cargo:warning=src/helpers.c:65:3: error: __builtin_longjmp is not supported for the current target
  cargo:warning=  platform_longjmp(*buf, 1);
  cargo:warning=  ^~~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=src/helpers.c:40:36: note: expanded from macro 'platform_longjmp'
  cargo:warning=#define platform_longjmp(buf, arg) __builtin_longjmp(buf, arg)
  cargo:warning=                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=2 errors generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang-15" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=riscv64-unknown-linux-gnu" "-Wall" "-Wextra" "-DCFG_TARGET_OS_linux" "-DCFG_TARGET_ARCH_riscv64" "-DVERSIONED_SUFFIX=_16_0_0" "-o" "/home/ace5g/shared/wasmtime/target/release/build/wasmtime-runtime-2c4c2ea10989c7f1/out/src/helpers.o" "-c" "src/helpers.c" with args "clang-15" did not execute successfully (status code exit status: 1).

Any insights on how to fix this are appreciated.

view this post on Zulip Afonso Bordado (Nov 15 2023 at 11:55):

:wave: Hey,

I was able to reproduce this both natively and while cross compiling. This only seems to happen when compiling with clang as the C compiler.

It looks like there is already a workaround for S390X and AArch64 in helper.c, so you might want to enable that temporarily. I'm going to submit a PR enabling that for RISC-V as well

view this post on Zulip Afonso Bordado (Nov 15 2023 at 12:11):

Here's the PR: https://github.com/bytecodealliance/wasmtime/pull/7541

👋 Hey, As reported in zulip, it looks like clang does not expose __builtin_{set,long}jmp for some platforms. This was a known issue previously for AArch64 and S390X, but it looks like it also affec...

view this post on Zulip Mats Brorsson (Nov 15 2023 at 12:28):

Afonso Bordado said:

:wave: Hey,

I was able to reproduce this both natively and while cross compiling. This only seems to happen when compiling with clang as the C compiler.

It looks like there is already a workaround for S390X and AArch64 in helper.c, so you might want to enable that temporarily. I'm going to submit a PR enabling that for RISC-V as well

Thanks, that works. But how would you otherwise go about and force the use of gcc instead of clang? I am completely new to build scripts so it's a mystery for me.

view this post on Zulip Afonso Bordado (Nov 15 2023 at 12:49):

I was able to reproduce this using CC=clang cargo build, so it might work to replace that with gcc in your usecase?


Last updated: Nov 22 2024 at 16:03 UTC