-
Notifications
You must be signed in to change notification settings - Fork 191
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
Make errno a macro like on other platforms #411
Comments
As long as there is no overhead, I don't see why we wouldn't just follow upstream musl on this. However, I think you would need to show that doing so didn't adding any overhead. |
ABI compatibility between wasi-libc and Emscripten would be error-prone at best, because the libc's have numerous differences which would lead to silent breakage. Also, while ABI compatibility has its advantages, it also has major |
I know there are some historical differences between filesystem constants, but otherwise they both use musl and seem largely compatible, at least enough to work for my usecase. I don't want to add undue maintenance burden and certainly don't expect any guarantees on ABI compatibility going forward, but I thought this particular difference is small enough to fix, and, if anything, might make the maintenance tiny bit simpler by reducing customized surface area vs just using what musl does. |
I'm not familiar with your use case, but even if it's small today, there's a risk it could grow in scope over time, or that other people might see what you're doing and want to do the same thing. For many projects, those are goals :-). |
That's a risk, yes, and, yes, secretly I'd hope someday Emscripten could actually be compatible with wasi-libc when in STANDALONE_WASM mode, but in this particular project I'm doing so much dangerous stuff already one more thing doesn't change much 😅 But basically I want to link a library built with Rust wasm32-wasi with Emscripten application built in STANDALONE_WASM mode. I could build Rust to wasm32-unknown-emscripten as well but historically that target in Rust is a bit problematic / undermaintained + it's crucial for me for that library to not depend on any of Emscripten's own custom imports which wasm32-unknown-emscripten can't guarantee even in STANDALONE_WASM mode (it all depends on features used) but wasm32-wasi can. Either way, I thought this particular issue with thread-local might be worth looking at in isolation. |
Currently wasi-libc makes errno a globally visible thread-local variable:
wasi-libc/libc-bottom-half/cloudlibc/src/libc/errno/errno.c
Line 87 in 38f4894
This differs from most other platforms - including underlying musl libc
wasi-libc/libc-top-half/musl/include/errno.h
Lines 10 to 21 in 38f4894
errno
as just a macro that calls an internal function.Would it be possible to change this to align the behaviour? I know it's somewhat niche usecase, but it seems to be the only big difference that prevents linking pre-existing object files produced by
clang -target wasm32-wasi
with Emscripten executables (emscripten-core/emscripten#19236) as object files depend onerrno
and it's not declared anywhere except wasi-libc.The text was updated successfully, but these errors were encountered: