-
Notifications
You must be signed in to change notification settings - Fork 467
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
Fix WASI compilation for C++ #1083
Conversation
I will look into the changes requested, in the meantime, I think it should be better to use WASI sysroot and not rely on WASI SDK so that we can use standard clang and not wasi SDK bundled clang, I will try to look into this aswell |
FWIW, I don't think it's libc's job to automatically pass a flag like |
You mean the flag should still be user provided ? As exceptions are not supported on the target and WASI only support clang as a compiler right now, I think it does make sense to provide it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine I suppose, but I can't help but think this will cause problems in the future.
if self.get_target()?.contains("wasi") { | ||
let wasi_sysroot = self.wasi_sysroot()?; | ||
self.cargo_output.print_metadata(&format_args!( | ||
"cargo:rustc-flags=-L {}/lib/wasm32-wasi -lstatic=c++ -lstatic=c++abi", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took another look and realise it is hardcoded to wasi.
I don't like it, but I think it's ok given that the preview wasi is also wasi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
It LGTM now!
It seems that currently cc-rs cannot build c++ to WASI correctly, it is using clang instead of clang++, not declaring some unsupported features such as no-exceptions (WASI does not support exceptions), and not linking libc++ aswell that is coming from WASI SDK.
With this PR, I am hoping this could fix this and avoid some extra code such as .compiler("clang++") to fix it