second-state / microservice-rust-mysql

A template project for building a database-driven microservice in Rust and run it in the WasmEdge sandbox.
Apache License 2.0
345 stars 53 forks source link

Compile error when `crossbeam-utils v0.8.13` in MacOS Big Sur 12.6.1 #7

Closed morristai closed 1 year ago

morristai commented 1 year ago

Hi, just a newbie here, want to ask if anyone occurred this issue by following README.md? Thanks

➤ RUST_BACKTRACE=1 cargo build --target wasm32-wasi --release
   Compiling crossbeam-utils v0.8.13
   Compiling serde_derive v1.0.147
   Compiling cfg-if v1.0.0
   Compiling itoa v1.0.4
   Compiling proc-macro-hack v0.5.19
   Compiling frunk_core v0.4.1
   Compiling minimal-lexical v0.2.1
   Compiling num-traits v0.2.15
   Compiling libloading v0.7.4
error: failed to run custom build command for `crossbeam-utils v0.8.13`

Caused by:
  process didn't exit successfully: `/Users/morris_tai/Documents/Whynot/microservice-rust-mysql/target/release/build/crossbeam-utils-e10b4f58993e0ccd/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /Users/morris_tai/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.13/build-common.rs:8:18
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
     2: core::panicking::panic_bounds_check
               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:84:5
     3: <usize as core::slice::index::SliceIndex<[T]>>::index
     4: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
     5: build_script_build::convert_custom_linux_target
     6: build_script_build::main
     7: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
hydai commented 1 year ago

Maybe related to this issue: https://github.com/WasmEdge/rust-mysql-simple-wasi/pull/5

MediosZ commented 1 year ago

This error is caused by a recent commit of crossbeam

We will fix this with crossbeam.

juntao commented 1 year ago

Can we fix our dependency to a specific version of crossbeam for now? It may take time for them to release a new version.

MediosZ commented 1 year ago

yes, adding these lines in Cargo.toml will fix this issue temporarily on Linux

[patch.crates-io]
crossbeam-utils = { git = "https://github.com/crossbeam-rs/crossbeam.git", rev="46d0aeb" }
crossbeam-queue = { git = "https://github.com/crossbeam-rs/crossbeam.git", rev="46d0aeb" }
crossbeam-epoch = { git = "https://github.com/crossbeam-rs/crossbeam.git", rev="46d0aeb" }

However, it doesn't work on macOS because libz can not be compiled for wasi. This can be fixed by editing async_mysql

juntao commented 1 year ago

I mean to change the deps in mysql_async_wasi to fix it at a version of crossbeam that works?

MediosZ commented 1 year ago

Fixing the version of crossbeam doesn't work cause we do not depend on crossbeam-utils directly. but adding these patches to async_mysql works indeed.

MediosZ commented 1 year ago

Crossbeam has fixed the problem. It should work on linux without any modification. But for macos, we need to modify async_mysql a bit.

MediosZ commented 1 year ago

It should work for now. @morristai If there are any other problems, please let us know.

morristai commented 1 year ago

It works now, you guys are awesome!! 💯