wasi-vfs
wasi-vfs copied to clipboard
Duplicate symbols when building with wasi-sdk 20
I was getting a crash when initializing a wasm module that used wasi-vfs. I was using wasi-sdk 20 and thought that maybe I should build wasi-vfs against that to make sure that wasn't the issue. However, after getting it built, I get the following errors when attempting to link libwasi_vfs.a into a module. The libc included with wasi-sdk includes the rintf
and rint
functions already. I was wondering if you had run across this before, or if this is possibly an addition to one of wasi-vfs' dependencies?
wasm-ld: error: duplicate symbol: rintf
>>> defined in /opt/lib/libwasi_vfs.a(compiler_builtins-d324d30d7b4a99a9.compiler_builtins.50f24778-cgu.60.rcgu.o)
>>> defined in /opt/wasi-sdk-20.0+threads/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(math-builtins.o)
wasm-ld: error: duplicate symbol: rint
>>> defined in /opt/lib/libwasi_vfs.a(compiler_builtins-d324d30d7b4a99a9.compiler_builtins.50f24778-cgu.70.rcgu.o)
>>> defined in /opt/wasi-sdk-20.0+threads/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(math-builtins.o)
It does look like these functions have been in libc.a
for quite a while, so I'm guessing it's an updated dependency of wasi-vfs.
Even when I build with wasi-sdk 14, I get those errors, so I'm not sure what the difference is between your builds and mine.
Oh, I bet that the linker was filtering out the symbols if they weren't used. I'm compiling the pandas package of Python which does a lot of numeric computation and probably uses the rintf
and rint
functions, which then causes the linker to include those symbols. Since they are both defined in two separate places, I get this error.
It looks like rustc archives compiler_builtins implementations into .a
. The rust people implemented it by themselves https://github.com/rust-lang/compiler-builtins and the alloc library depends on it, so there is no way to avoid including compiler_builtins in .a unfortunately.
If we adopt the component model, this problem will be solved.