wasm3 / wasm3-rs

Rust wrapper for Wasm3, the fastest WebAssembly interpreter
MIT License
160 stars 44 forks source link

Can't compile with build-bindgen #20

Closed jiayihu closed 4 years ago

jiayihu commented 4 years ago

I can't get to compile to crate in any way. I've installed clang from brew and also MacOS Xcode devtools, but if I use the build-bindgen features I get the following error:

Caused by:
  process didn't exit successfully: `/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/debug/build/wasm3-sys-c75d8740be89c22d/build-script-build` (exit code: 101)
  --- stderr
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_va_list.h:32:9: error: unknown type name '__darwin_va_list'
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_size_t.h:31:9: error: unknown type name '__darwin_size_t'
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture, err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported, err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/machine/types.h:37:2: error: architecture not supported, err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_va_list.h:32:9: error: unknown type name '__darwin_va_list', err: true
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_size_t.h:31:9: error: unknown type name '__darwin_size_t', err: true
  fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true
  thread 'main' panicked at 'Failed to generate bindings: ()', /Users/jiayihu/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm3-sys-0.1.2/build.rs:121:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Trying instead to compile it without the bindgen feature results in the following error:

error: failed to run custom build command for `wasm3-sys v0.1.2`

Caused by:
  process didn't exit successfully: `/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/debug/build/wasm3-sys-ed19931fe417e3c8/build-script-build` (exit code: 101)
  --- stderr
  wasm3/source/m3_core.h:11:10: fatal error: 'stdio.h' file not found
  wasm3/source/m3_core.h:11:10: fatal error: 'stdio.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate bindings: ()', /Users/jiayihu/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.55.1/src/main.rs:54:36
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  thread 'main' panicked at 'Failed to run bindgen: ExitStatus(ExitStatus(256))', /Users/jiayihu/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm3-sys-0.1.2/build.rs:80:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I've also tried to just run clang -v a.c where a.c contains only an include of stdio.h and it works without issue, meaning it's able to find the header file. So the issue is in rust bindgen or something in this crate I suppose.

Veykril commented 4 years ago

Are you certain that you properly set up clang? I unfortunately do not have access to a MacOS machine so I can't test this and the stderr output doesn't really help me out either. But I do believe this problem lies with either you clang setup or bindgen itself from looking through its issue tracker.

jiayihu commented 4 years ago

I think I resolved the issue because I'm cross compiling to thumbv7em-none-eabi as target. By running

BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/local/opt/gcc-arm-none-eabi/arm-none-eabi" cargo build

Seems to work, although another issue appears.

The following warnings were emitted during compilation:

warning: wasm3/source/m3_api_wasi.c: In function 'convert_clockid':
warning: wasm3/source/m3_api_wasi.c:144:52: error: 'CLOCK_MONOTONIC' undeclared (first use in this function); did you mean '__WASI_CLOCK_MONOTONIC'?
warning:      case __WASI_CLOCK_MONOTONIC:            return CLOCK_MONOTONIC;
warning:                                                     ^~~~~~~~~~~~~~~
warning:                                                     __WASI_CLOCK_MONOTONIC
warning: wasm3/source/m3_api_wasi.c:144:52: note: each undeclared identifier is reported only once for each function it appears in
warning: wasm3/source/m3_api_wasi.c:145:52: error: 'CLOCK_PROCESS_CPUTIME_ID' undeclared (first use in this function); did you mean '__WASI_CLOCK_PROCESS_CPUTIME_ID'?
warning:      case __WASI_CLOCK_PROCESS_CPUTIME_ID:   return CLOCK_PROCESS_CPUTIME_ID;
warning:                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
warning:                                                     __WASI_CLOCK_PROCESS_CPUTIME_ID
warning: wasm3/source/m3_api_wasi.c:147:52: error: 'CLOCK_THREAD_CPUTIME_ID' undeclared (first use in this function); did you mean 'CLOCK_PROCESS_CPUTIME_ID'?
warning:      case __WASI_CLOCK_THREAD_CPUTIME_ID:    return CLOCK_THREAD_CPUTIME_ID;
warning:                                                     ^~~~~~~~~~~~~~~~~~~~~~~
warning:                                                     CLOCK_PROCESS_CPUTIME_ID
warning: In file included from wasm3/source/m3_api_wasi.c:12:0:
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_fdstat_get':
warning: wasm3/source/m3_api_wasi.c:310:31: error: 'O_DSYNC' undeclared (first use in this function); did you mean 'O_SYNC'?
warning:                         ((fl & O_DSYNC)     ? __WASI_FDFLAG_DSYNC     : 0) |
warning:                                ^
warning: wasm3/source/m3_api_defs.h:37:58: note: in definition of macro 'm3ApiWriteMem16'
warning:  #  define m3ApiWriteMem16(ptr, val)  { * (u16 *)(ptr) = (val); }
warning:                                                           ^~~
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_seek':
warning: wasm3/source/m3_api_wasi.c:353:11: warning: implicit declaration of function 'lseek'; did you mean 'fseek'? [-Wimplicit-function-declaration]
warning:      ret = lseek(fd, offset, whence);
warning:            ^~~~~
warning:            fseek
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_path_open':
warning: wasm3/source/m3_api_wasi.c:422:58: error: 'O_DSYNC' undeclared (first use in this function); did you mean 'O_SYNC'?
warning:                  ((fs_flags & __WASI_FDFLAG_DSYNC)      ? O_DSYNC     : 0) |
warning:                                                           ^~~~~~~
warning:                                                           O_SYNC
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_read':
warning: wasm3/source/m3_api_wasi.c:474:19: warning: implicit declaration of function 'read'; did you mean 'fread'? [-Wimplicit-function-declaration]
warning:          int ret = read (fd, addr, len);
warning:                    ^~~~
warning:                    fread
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_write':
warning: wasm3/source/m3_api_wasi.c:509:19: warning: implicit declaration of function 'write'; did you mean 'fwrite'? [-Wimplicit-function-declaration]
warning:          int ret = write (fd, addr, len);
warning:                    ^~~~~
warning:                    fwrite
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_close':
warning: wasm3/source/m3_api_wasi.c:524:15: warning: implicit declaration of function 'close'; did you mean 'pclose'? [-Wimplicit-function-declaration]
warning:      int ret = close(fd);
warning:                ^~~~~
warning:                pclose
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_clock_res_get':
warning: wasm3/source/m3_api_wasi.c:596:9: warning: implicit declaration of function 'clock_getres' [-Wimplicit-function-declaration]
warning:      if (clock_getres(clk, &tp) != 0) {
warning:          ^~~~~~~~~~~~
warning: wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_clock_time_get':
warning: wasm3/source/m3_api_wasi.c:618:9: warning: implicit declaration of function 'clock_gettime'; did you mean 'localtime'? [-Wimplicit-function-declaration]
warning:      if (clock_gettime(clk, &tp) != 0) {
warning:          ^~~~~~~~~~~~~
warning:          localtime

error: failed to run custom build command for `wasm3-sys v0.1.2`

Caused by:
  process didn't exit successfully: `/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/debug/build/wasm3-sys-ed19931fe417e3c8/build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("thumbv7em-none-eabi")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-apple-darwin")
  CC_thumbv7em-none-eabi = None
  CC_thumbv7em_none_eabi = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_thumbv7em-none-eabi = None
  CFLAGS_thumbv7em_none_eabi = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("dsp,mclass,thumb-mode,v5te,v6,v6k,v6t2,v7")
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_optimize.o" "-c" "wasm3/source/m3_optimize.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_compile.o" "-c" "wasm3/source/m3_compile.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_api_libc.o" "-c" "wasm3/source/m3_api_libc.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_env.o" "-c" "wasm3/source/m3_env.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_exec.o" "-c" "wasm3/source/m3_exec.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_bind.o" "-c" "wasm3/source/m3_bind.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_info.o" "-c" "wasm3/source/m3_info.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_emit.o" "-c" "wasm3/source/m3_emit.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_parse.o" "-c" "wasm3/source/m3_parse.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_module.o" "-c" "wasm3/source/m3_module.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_api_tracer.o" "-c" "wasm3/source/m3_api_tracer.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_core.o" "-c" "wasm3/source/m3_core.c"
  exit code: 0
  running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_api_wasi.o" "-c" "wasm3/source/m3_api_wasi.c"
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'convert_clockid':
  cargo:warning=wasm3/source/m3_api_wasi.c:144:52: error: 'CLOCK_MONOTONIC' undeclared (first use in this function); did you mean '__WASI_CLOCK_MONOTONIC'?
  cargo:warning=     case __WASI_CLOCK_MONOTONIC:            return CLOCK_MONOTONIC;
  cargo:warning=                                                    ^~~~~~~~~~~~~~~
  cargo:warning=                                                    __WASI_CLOCK_MONOTONIC
  cargo:warning=wasm3/source/m3_api_wasi.c:144:52: note: each undeclared identifier is reported only once for each function it appears in
  cargo:warning=wasm3/source/m3_api_wasi.c:145:52: error: 'CLOCK_PROCESS_CPUTIME_ID' undeclared (first use in this function); did you mean '__WASI_CLOCK_PROCESS_CPUTIME_ID'?
  cargo:warning=     case __WASI_CLOCK_PROCESS_CPUTIME_ID:   return CLOCK_PROCESS_CPUTIME_ID;
  cargo:warning=                                                    ^~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=                                                    __WASI_CLOCK_PROCESS_CPUTIME_ID
  cargo:warning=wasm3/source/m3_api_wasi.c:147:52: error: 'CLOCK_THREAD_CPUTIME_ID' undeclared (first use in this function); did you mean 'CLOCK_PROCESS_CPUTIME_ID'?
  cargo:warning=     case __WASI_CLOCK_THREAD_CPUTIME_ID:    return CLOCK_THREAD_CPUTIME_ID;
  cargo:warning=                                                    ^~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=                                                    CLOCK_PROCESS_CPUTIME_ID
  cargo:warning=In file included from wasm3/source/m3_api_wasi.c:12:0:
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_fdstat_get':
  cargo:warning=wasm3/source/m3_api_wasi.c:310:31: error: 'O_DSYNC' undeclared (first use in this function); did you mean 'O_SYNC'?
  cargo:warning=                        ((fl & O_DSYNC)     ? __WASI_FDFLAG_DSYNC     : 0) |
  cargo:warning=                               ^
  cargo:warning=wasm3/source/m3_api_defs.h:37:58: note: in definition of macro 'm3ApiWriteMem16'
  cargo:warning= #  define m3ApiWriteMem16(ptr, val)  { * (u16 *)(ptr) = (val); }
  cargo:warning=                                                          ^~~
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_seek':
  cargo:warning=wasm3/source/m3_api_wasi.c:353:11: warning: implicit declaration of function 'lseek'; did you mean 'fseek'? [-Wimplicit-function-declaration]
  cargo:warning=     ret = lseek(fd, offset, whence);
  cargo:warning=           ^~~~~
  cargo:warning=           fseek
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_path_open':
  cargo:warning=wasm3/source/m3_api_wasi.c:422:58: error: 'O_DSYNC' undeclared (first use in this function); did you mean 'O_SYNC'?
  cargo:warning=                 ((fs_flags & __WASI_FDFLAG_DSYNC)      ? O_DSYNC     : 0) |
  cargo:warning=                                                          ^~~~~~~
  cargo:warning=                                                          O_SYNC
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_read':
  cargo:warning=wasm3/source/m3_api_wasi.c:474:19: warning: implicit declaration of function 'read'; did you mean 'fread'? [-Wimplicit-function-declaration]
  cargo:warning=         int ret = read (fd, addr, len);
  cargo:warning=                   ^~~~
  cargo:warning=                   fread
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_write':
  cargo:warning=wasm3/source/m3_api_wasi.c:509:19: warning: implicit declaration of function 'write'; did you mean 'fwrite'? [-Wimplicit-function-declaration]
  cargo:warning=         int ret = write (fd, addr, len);
  cargo:warning=                   ^~~~~
  cargo:warning=                   fwrite
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_fd_close':
  cargo:warning=wasm3/source/m3_api_wasi.c:524:15: warning: implicit declaration of function 'close'; did you mean 'pclose'? [-Wimplicit-function-declaration]
  cargo:warning=     int ret = close(fd);
  cargo:warning=               ^~~~~
  cargo:warning=               pclose
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_clock_res_get':
  cargo:warning=wasm3/source/m3_api_wasi.c:596:9: warning: implicit declaration of function 'clock_getres' [-Wimplicit-function-declaration]
  cargo:warning=     if (clock_getres(clk, &tp) != 0) {
  cargo:warning=         ^~~~~~~~~~~~
  cargo:warning=wasm3/source/m3_api_wasi.c: In function 'm3_wasi_unstable_clock_time_get':
  cargo:warning=wasm3/source/m3_api_wasi.c:618:9: warning: implicit declaration of function 'clock_gettime'; did you mean 'localtime'? [-Wimplicit-function-declaration]
  cargo:warning=     if (clock_gettime(clk, &tp) != 0) {
  cargo:warning=         ^~~~~~~~~~~~~
  cargo:warning=         localtime
  exit code: 1

  --- stderr

  error occurred: Command "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "wasm3/source" "-Dd_m3LogOutput=0" "-Dd_m3HasWASI" "-Dd_m3Use32BitSlots=1" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-9764b8bd4a89ecee/out/wasm3/source/m3_api_wasi.o" "-c" "wasm3/source/m3_api_wasi.c" with args "arm-none-eabi-gcc" did not execute successfully (status code exit code: 1).

It seems like I'm unable to compile wasm3/source with arm-none-eabi-gcc, do you have any idea?

Veykril commented 4 years ago

This might be on me, given that it only seems to fail due to wasi stuff. Can you see if this also happens when building without the wasi feature?

wasm3 = { version = *, default-features = false, features = ["std", "use-32bit-slots"] }
Veykril commented 4 years ago

Looks like for some reason it doesn't find this header/the defines in there https://github.com/wasm3/wasm3/blob/a207a3328ff64a3392a575f112582f6d4c12a5d7/source/extra/wasi_core.h

jiayihu commented 4 years ago

Can't compile it using wasm3 = { version = *, default-features = false, features = ["std", "use-32bit-slots"] } because I'm in no_std with thumbv7em-none-eabi target. If I just use features = ["use-32bit-slots"] the error is much nicer:

error: no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait.

warning: unused import: `rtic::cyccnt::U32Ext`
  --> src/main.rs:12:5
   |
12 | use rtic::cyccnt::U32Ext;
   |     ^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `rprint`
  --> src/main.rs:13:18
   |
13 | use rtt_target::{rprint, rprintln, rtt_init_print};
   |                  ^^^^^^

error: `#[alloc_error_handler]` function required, but not found

error[E0308]: mismatched types
  --> src/main.rs:34:41
   |
34 |         let mut cp: rtic::Peripherals = cx.core;
   |                     -----------------   ^^^^^^^ expected struct `rtic::Peripherals`, found struct `cortex_m::Peripherals`
   |                     |
   |                     expected due to this

error: aborting due to 3 previous errors; 2 warnings emitted

For more information about this error, try `rustc --explain E0308`.
error: could not compile `fedra`.

To learn more, run the command again with --verbose.

For some reason the code that was working before including wasm3 now gives error, but I can ignore it for now. The main error is the absense of an allocator, probably because you are assuming std is available right? In no_std I don't have an allocator. I've also noticed that BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/local/opt/gcc-arm-none-eabi/arm-none-eabi" is not needed anymore, so I fear that the previous error is just covered by these simpler one.

Veykril commented 4 years ago

The crate still relies on alloc atm due to the use of ref counted pointers as this makes the api easier to use. I couldn't come up with an api that didn't rely on that yet. So for some reason enabling wasi doesn't work properly for you here but I'm not sure why to be honest.

jiayihu commented 4 years ago

Not a big issue atm, I'd like just being able to do 2+2 in WASM πŸ˜„ So for now it means that I have to implement an allocator, maybe one from phil's tutorial? https://os.phil-opp.com/allocator-designs/#implementation-for-locked-bumpallocator

Veykril commented 4 years ago

Maybe you can use https://github.com/rust-embedded/alloc-cortex-m? I'm not well versed in embedded dev so just throwing that inπŸ˜„

Rolling your own ofc would also work.

jiayihu commented 4 years ago

Alright, forgot about that one thanks! Okay I'll let you know then, thanks very much for the kind support

Veykril commented 4 years ago

No problem. Just letting you know that I don't know though whether I can look into the wasi problem atm as its been quite a bit since i properly worked on this crate myself + I only have a windows and a linux machine to test with so I cant even reproduce this problem.

jiayihu commented 4 years ago

No worries, any help is appreciated πŸ˜„ So, I've made some progress and implemented the cortex-m allocator and compiling wasm3 as wasm3 = { version = "0.1.3", default-features = false, features = ["use-32bit-slots"] }. The error has changed again:

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "--eh-frame-hdr" "-L" "/Users/jiayihu/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.12rvl8um31ikxij6.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.17e1ruwxo52p5j50.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.17vt1z4jwfc1ye1t.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1adb915dtge40hh1.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1ctvawf79ayfrdt5.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1cza3gyxdww8zfdx.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1ddl8unnku1zbe1j.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1k9txlwoxihufolt.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1xeabrzp8i9z20vi.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.1xfx7k65lww94231.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.24rpjoer682ww6w4.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.28nvnl2midrq7c0u.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.2itww06aecj6g2ng.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.2jzcx7czgbl77zb6.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.2rwz09crtd1cpguq.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.2xbn0ejriosz45rx.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.33qtikoyfynlizk4.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.33tjyyu7xpcm7t0z.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3hrf6vfsmpl5x6dy.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3ljfphv376on7wxl.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3lo54g5h1yg70nbh.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3m9ffdl877b2d310.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3oo6i44l4ja2tecs.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.3z0n7s62i3qd9qpa.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.43bk6g7kzpv51brc.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.447ampr8384uetmi.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.46txpz8sbgflutcl.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.4cnp73w8x9s5tab4.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.4ojl9j7b526phsh1.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.4pxs9pq8pnw5e6qb.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.4y5p9fbubfmkhfpa.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.57l5e4cjlt6mnwi4.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.5bb6ukiq00hpoaw4.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.5dks4mjv8p8ci2s1.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.5f3lt79n7mv48pb.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.7a8b5q5xuxb3z5s.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.bpqngdahmkri14w.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.dc3cvhvvlvc16u9.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.eheij37k9nvzdrc.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.epnts6fm14gaegb.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.hfplrizdee6y4s.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.jlyo1ij8kja8qlj.rcgu.o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.qk9t5it2z2dv2kb.rcgu.o" "-o" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/fedra-8a1512198683e0bb.6x8j1dpjumn4k2t.rcgu.o" "--gc-sections" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/debug/deps" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/cortex-m-1c8832b3a93ffbd4/out" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/cortex-m-rt-c0b8ba38757d0045/out" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/stm32f4-c0d865e64b21c665/out" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/stm32f4-5ccb3059afd2c5d7/out" "-L" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/build/wasm3-sys-59326edd03bd96a2/out" "-L" "/Users/jiayihu/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib" "-Bstatic" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/librtic-2304e38c31850b4c.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libheapless-223bb0050ae44cce.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libhash32-417d7e8d020caf17.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libbyteorder-58cd702822bed75f.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/librtic_core-ac8bb5421dc8d769.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3-243527ca176c9080.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcty-0719685c2179d5c6.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libstm32f4xx_hal-b743c956fdc8a4e7.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/librand_core-d65b878d0c07df6d.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcast-186ea434bdf4fa39.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libstm32f4-f8fcd97c0517c50c.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libembedded_hal-eafacd1f122d333c.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libvoid-e4abc962b36d9cf2.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libnb-93b822edadec9678.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libnb-0f1b804e324c9c3a.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libstm32f4-e8dae4c6198a70c6.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/librtt_target-3f6244f562d775ea.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libufmt_write-5bee2391a7412416.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcortex_m_rt-3a2f5eb8a72158e7.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libr0-29f1b688ebc12b00.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/liballoc_cortex_m-2f750aeb645b73cf.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/liblinked_list_allocator-80abbdd5e9bd4c58.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcortex_m-bafab45d930b5c00.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libvolatile_register-bb5c3d295ec008a9.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libvcell-7cd9c68afefdc448.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libbare_metal-6bec0069af0ca3b0.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libaligned-265561d215218a01.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libas_slice-656d5f4d02c91500.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libstable_deref_trait-e4e273b027da4a81.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libgeneric_array-0c256ac54eee78d8.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libgeneric_array-3790c2edc01aefd9.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libtypenum-162a30db6435727a.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/liballoc-51bc88b34f1dde7a.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/librustc_std_workspace_core-3ab25030d96cd63e.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcore-ecdb46d11a90eebd.rlib" "/Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcompiler_builtins-a6005efe4d7b4433.rlib" "-Tlink.x" "-Bdynamic"
  = note: rust-lld: error: undefined symbol: __aeabi_d2f
          >>> referenced by m3_exec.h:138 (wasm3/source/m3_exec.h:138)
          >>>               m3_compile.o:(op_f32_Equal_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:139 (wasm3/source/m3_exec.h:139)
          >>>               m3_compile.o:(op_f32_NotEqual_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:140 (wasm3/source/m3_exec.h:140)
          >>>               m3_compile.o:(op_f32_LessThan_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:140 (wasm3/source/m3_exec.h:140)
          >>>               m3_compile.o:(op_f32_LessThan_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:141 (wasm3/source/m3_exec.h:141)
          >>>               m3_compile.o:(op_f32_GreaterThan_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:141 (wasm3/source/m3_exec.h:141)
          >>>               m3_compile.o:(op_f32_GreaterThan_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:142 (wasm3/source/m3_exec.h:142)
          >>>               m3_compile.o:(op_f32_LessThanOrEqual_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:142 (wasm3/source/m3_exec.h:142)
          >>>               m3_compile.o:(op_f32_LessThanOrEqual_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:143 (wasm3/source/m3_exec.h:143)
          >>>               m3_compile.o:(op_f32_GreaterThanOrEqual_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:143 (wasm3/source/m3_exec.h:143)
          >>>               m3_compile.o:(op_f32_GreaterThanOrEqual_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced 95 more times
          >>> did you mean: __aeabi_i2f
          >>> defined in: /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libcompiler_builtins-a6005efe4d7b4433.rlib(compiler_builtins-a6005efe4d7b4433.compiler_builtins.5m18htbu-cgu.11.rcgu.o)

          rust-lld: error: undefined symbol: copysignf
          >>> referenced by m3_exec.h:196 (wasm3/source/m3_exec.h:196)
          >>>               m3_compile.o:(op_f32_CopySign_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:196 (wasm3/source/m3_exec.h:196)
          >>>               m3_compile.o:(op_f32_CopySign_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:196 (wasm3/source/m3_exec.h:196)
          >>>               m3_compile.o:(op_f32_CopySign_ss) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: copysign
          >>> referenced by m3_exec.h:197 (wasm3/source/m3_exec.h:197)
          >>>               m3_compile.o:(op_f64_CopySign_sr) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:197 (wasm3/source/m3_exec.h:197)
          >>>               m3_compile.o:(op_f64_CopySign_rs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:197 (wasm3/source/m3_exec.h:197)
          >>>               m3_compile.o:(op_f64_CopySign_ss) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: ceilf
          >>> referenced by m3_exec.h:222 (wasm3/source/m3_exec.h:222)
          >>>               m3_compile.o:(op_f32_Ceil_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:222 (wasm3/source/m3_exec.h:222)
          >>>               m3_compile.o:(op_f32_Ceil_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: ceil
          >>> referenced by m3_exec.h:222 (wasm3/source/m3_exec.h:222)
          >>>               m3_compile.o:(op_f64_Ceil_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:222 (wasm3/source/m3_exec.h:222)
          >>>               m3_compile.o:(op_f64_Ceil_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: floorf
          >>> referenced by m3_exec.h:223 (wasm3/source/m3_exec.h:223)
          >>>               m3_compile.o:(op_f32_Floor_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:223 (wasm3/source/m3_exec.h:223)
          >>>               m3_compile.o:(op_f32_Floor_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: floor
          >>> referenced by m3_exec.h:223 (wasm3/source/m3_exec.h:223)
          >>>               m3_compile.o:(op_f64_Floor_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:223 (wasm3/source/m3_exec.h:223)
          >>>               m3_compile.o:(op_f64_Floor_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: truncf
          >>> referenced by m3_exec.h:224 (wasm3/source/m3_exec.h:224)
          >>>               m3_compile.o:(op_f32_Trunc_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:224 (wasm3/source/m3_exec.h:224)
          >>>               m3_compile.o:(op_f32_Trunc_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: trunc
          >>> referenced by m3_exec.h:224 (wasm3/source/m3_exec.h:224)
          >>>               m3_compile.o:(op_f64_Trunc_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:224 (wasm3/source/m3_exec.h:224)
          >>>               m3_compile.o:(op_f64_Trunc_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: sqrtf
          >>> referenced by m3_exec.h:225 (wasm3/source/m3_exec.h:225)
          >>>               m3_compile.o:(op_f32_Sqrt_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:225 (wasm3/source/m3_exec.h:225)
          >>>               m3_compile.o:(op_f32_Sqrt_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: sqrt
          >>> referenced by m3_exec.h:225 (wasm3/source/m3_exec.h:225)
          >>>               m3_compile.o:(op_f64_Sqrt_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:225 (wasm3/source/m3_exec.h:225)
          >>>               m3_compile.o:(op_f64_Sqrt_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: rintf
          >>> referenced by m3_exec.h:226 (wasm3/source/m3_exec.h:226)
          >>>               m3_compile.o:(op_f32_Nearest_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:226 (wasm3/source/m3_exec.h:226)
          >>>               m3_compile.o:(op_f32_Nearest_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: rint
          >>> referenced by m3_exec.h:226 (wasm3/source/m3_exec.h:226)
          >>>               m3_compile.o:(op_f64_Nearest_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:226 (wasm3/source/m3_exec.h:226)
          >>>               m3_compile.o:(op_f64_Nearest_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: __ctzdi2
          >>> referenced by m3_exec.h:260 (wasm3/source/m3_exec.h:260)
          >>>               m3_compile.o:(op_u64_Ctz_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:260 (wasm3/source/m3_exec.h:260)
          >>>               m3_compile.o:(op_u64_Ctz_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: __popcountsi2
          >>> referenced by m3_exec.h:262 (wasm3/source/m3_exec.h:262)
          >>>               m3_compile.o:(op_u32_Popcnt_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:262 (wasm3/source/m3_exec.h:262)
          >>>               m3_compile.o:(op_u32_Popcnt_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: __popcountdi2
          >>> referenced by m3_exec.h:263 (wasm3/source/m3_exec.h:263)
          >>>               m3_compile.o:(op_u64_Popcnt_r) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_exec.h:263 (wasm3/source/m3_exec.h:263)
          >>>               m3_compile.o:(op_u64_Popcnt_s) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: strcmp
          >>> referenced by m3_env.c:738 (wasm3/source/m3_env.c:738)
          >>>               m3_env.o:(m3_CallWithArgs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib
          >>> referenced by m3_parse.c:434 (wasm3/source/m3_parse.c:434)
          >>>               m3_parse.o:(ParseSection_Custom) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: strtoul
          >>> referenced by m3_env.c:764 (wasm3/source/m3_env.c:764)
          >>>               m3_env.o:(m3_CallWithArgs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: strtoull
          >>> referenced by m3_env.c:766 (wasm3/source/m3_env.c:766)
          >>>               m3_env.o:(m3_CallWithArgs) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: undefined symbol: vsnprintf
          >>> referenced by m3_env.c:944 (wasm3/source/m3_env.c:944)
          >>>               m3_env.o:(m3Error) in archive /Users/jiayihu/Desktop/Repo/fedra-thesis/fedra/target/thumbv7em-none-eabi/debug/deps/libwasm3_sys-ef0b0e338ce81248.rlib

          rust-lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)

Seems like it isn't able to use normal C functions, maybe bacause of the thumbv7em-none-eabi target. I'll investigate a bit

Veykril commented 4 years ago

That looks like its missing libc for linking.

Veykril commented 4 years ago

This could partially be caused by my buildscript though. It's not the best and it is definitely missing some things.

jiayihu commented 4 years ago

Some progress again, although it may not help too much because AFAIK this crate doesn't use cmake. But being unable to compile it with bindgen, I resorted to trying to compile the original wasm3 and after some nasty issues with clang I was able to solve it: https://github.com/wasm3/wasm3/issues/174

It's also compiled with WASI support, so the issue is something about bindgen or the buildscript, not wasm3 or clang I suppose.

Veykril commented 4 years ago

The buildscript is supposed to replace the cmake configuration, but as you might be able to tell as well, it's not complete. So it might be missing a flag required for your platform to work atm.

jiayihu commented 4 years ago

21 solved the issue for me. There is still an open question about how to deal with wasm3 compilation flags because compiling the C code for embedded and linking with Rust lld results in missing intrinsics, which could be avoided setting d_m3HasFloat and d_m3FixedHeap if one desires it. But that's another issue, we can close this one