Stream: wit-bindgen

Topic: module does not export a function named `cabi_realloc``


view this post on Zulip benwis (Feb 25 2024 at 20:40):

Hello again! Things are getting weirder. Yesterday I built this project with the same command in debug mode with cargo component with the below command.

RUSTFLAGS='-L /opt/wasi-sdk-21.0/share/wasi-sysroot/lib/wasm32-wasi -lstatic=c++ -lstatic=c++abi' CXXSTDLIB=c++ CC=/opt/wasi-sdk-21.0/bin/clang CXX=/opt/wasi-sdk-21.0/bin/clang++ CXXFLAGS="-fno-exceptions"  cargo component build

However, if I added the --release flag, I get this error:

error: module does not export a function named `cabi_realloc`

I thought maybe it was an issue with old stuff, as I had forgotten the realloc flag on wit-bindgen. But now I get this error:

  cargo:warning=src/./tree.c:138:23: error: call to undeclared function 'dup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  cargo:warning=  138 |   FILE *file = fdopen(dup(fd), "a");

I tried reverting adding the feature, but alas it remains broken. Is there something else I need to include to make this work?

view this post on Zulip benwis (Feb 25 2024 at 21:19):

I remain confused about the dup, but the reason for the missing cabi_realloc appears to be using lto="thin" for release mode

view this post on Zulip Alex Crichton (Feb 26 2024 at 15:33):

If this goes away when disabling LTO you might be running into this issue perhaps?

using wit-bindgen version 0.19.1, when I: cargo component build --release with [profile.release] lto = "fat" # anything other than false I get the error: error: module does not export a function na...

view this post on Zulip benwis (Feb 26 2024 at 18:08):

Yep, this is exactly what I'm experiencing. I did stumble upon turning off lto as the solution, so this is on par :) Thanks for sharing


Last updated: Nov 22 2024 at 16:03 UTC