Cdk-rs 0.6.* can't run tests

It seems like after decoupling of ic0 crate from cdk-rs crate something went wrong.

I still can use cargo build for my projects, but not cargo test:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcAgGAPp/symbols.o" "/home/alexander/IdeaProjects/ic-stable-memory/target/debug/deps/ic_stable_memory-af206a0cde78a87c.10t3jbqh57ut461e.rcgu.o" "/home/alexander/IdeaProjects/ic-stable-memory/target/debug/deps/ic_stable_memory-af206a0cde78a87c.11543p07sull3p31.rcgu.o" "/home/alexander/IdeaProjects/ic-stable-memory/target/debug/deps/ic_stable_memory-af206a0cde78a87c.130geevnzwplkrxq.rcgu.o" "/home/alexander/IdeaProjects/ic-stable-memory/target/debug/deps/ic_stable_memory-...
  = note: /usr/bin/ld: /home/alexander/IdeaProjects/ic-stable-memory/target/debug/deps/libic_cdk-2146a3f3358a2c93.rlib(ic_cdk-2146a3f3358a2c93.ic_cdk.5f9620fa-cgu.8.rcgu.o): in function `ic_cdk::api::trap':
          /home/alexander/.cargo/registry/src/github.com-1ecc6299db9ec823/ic-cdk-0.6.5/src/api/mod.rs:20: undefined reference to `trap'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

How to fix?

Would appreciate some inputs on this because this is a blocker for using ic_cdk v0.6 onwards and candid v0.8 onwards in a project that relies on ic-stable-memory.

Thoughts?
@chenyan @lwshang Tagging you since you are the owners of the respective crates

We haven’t had a common way to run cargo test on rust canisters.
I speculate that your cargo test is targeting your host OS instead of wasm32. So the linker complained about symbol not found.

It used to work because ic-cdk defined virtual API endpoints for non-wasm32 targets which don’t link to extern functions, as can be seen in the source code before ic0 split.

I will soon add those virtual endpoints to ic0.

ic0 v0.18.6 is out with fix for this issue.

Bump ic0 in Cargo.lock should solve your issue now.

Now everything works as expected.
Thank you very much!