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?
I remain confused about the dup, but the reason for the missing cabi_realloc appears to be using lto="thin"
for release mode
If this goes away when disabling LTO you might be running into this issue perhaps?
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: Dec 23 2024 at 12:05 UTC