Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate symbols when building with wasi-sdk 20 #11

Open
kesmit13 opened this issue Mar 22, 2023 · 4 comments
Open

Duplicate symbols when building with wasi-sdk 20 #11

kesmit13 opened this issue Mar 22, 2023 · 4 comments

Comments

@kesmit13
Copy link

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)
@kesmit13
Copy link
Author

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.

@kesmit13
Copy link
Author

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.

@kesmit13
Copy link
Author

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.

@kateinoigakukun
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants