-
Notifications
You must be signed in to change notification settings - Fork 27
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
The C language runtime fails on the compilation step when there are global variable declarations without initializers #282
Comments
Hey Ravi! Thanks for the very thorough bug report. Particularly for going out of your way to find a reproduction and to test it in another env. I'll look into this when I have a chance, I'm currently travelling for work but should be back next week. If you're interested in investigating further I'd be interested to see what is coming out over STDERR. If you look in the web console it should be logging it. |
Hey Ben, Thanks for the quick response. We will continue to debug this at our end. We basically use your wasi runtime within our product which has use cases around executing user code within the browser. I will post here further findings. For now, here's what's on the console of runno.dev (the non-zero exit code referred below is 134 - click here for the line of code on the main branch):
There are a number of debug statements for WASI calls, which probably are more useful. |
If you try out the WASI playground on https://runno.dev/wasi with the same binary, flags, files, etc you should be able to see the STDOUT/STDERR which will help understand what Clang is doing. Alternatively that stuff will be in the debug logs, but you have to expand them in the browser console. |
I've just had a look at yeah, there's nothing coming out. Interesting problem! Might be a bug in an internal implementation detail of the filesystem. |
I've got a Draft PR up with a reproducing test that fails here (#283). I'll work on figuring out the cause next. |
@taybenlor, looks like the following claim I made is not exactly correct.
The clang wasm there is identical to the one in runno. The reason why it worked there but not on runno is that the file name there is marked as Now I am fairly confident that the issue is with the clang.wasm. Looks like you seem to have inherited this clang.wasm from @binji's fork of llvm (directly or indirectly) & we may have to find & resolve a bug in the source repo there. Please let me know if there are any further findings from your end. |
Thanks for the extra context! Yeah I absolutely use the It's possible for me to change the way Runno works to save the file as |
Yeah, making that change doesn't make sense. That's not the right solution because that'd mean the supposed C runtime would support C++ features such as classes, etc. I am trying to see if I can build clang wasm, based on the limited information available from @binji on his repos & the talks he gave. Please post here in case you do have any other solution. |
I'm very much not an expert in clang, or C, or your use case. I guess what I'd want to know is what the expected behaviour from Clang is, and whether there is some other way to trigger it or work around it. Some outstanding questions:
No need to answer them just trying to get stuff out of my brain. |
the code must compile fine without clang erroring out
yep, but not much luck. We identified the exact same backtrace whether used with wasmtime or in browser
Didn't try to figure out from the mangled names in the backtrace. I don't plan to spend time on this. Perhaps it is too ambitious, but I am trying to see if I can build the latest llvm tools (including clang) to wasm.
It appears to be a bug in the WASI port because the same works fine directly on the x86_64 version of clang 8.0.1 (that's the version of clang.wasm too) when tried on godbolt |
Okay, it sounds like this is well out of my area of expertise. Best of luck! Keep me updated. |
I want to mention that there has been more effort recently being put into compiling LLVM+Clang to Wasm: https://discourse.llvm.org/t/rfc-building-llvm-for-webassembly/79073 (see specifically comment 36). |
Trying with clang as the runtime choice, any global variable declarations in the supplied C program results in the following error:
The same works with clangpp runtime.
I tried to emulate the same error by cloning https://github.com/binji/wasm-clang & making changes to the clang options there. I used the exact same ones as what runno is passing (basically, had to remove -x c++ from the args to clang to mimic runno's options). It works with the exact same root fs & wasm as runno's & it works fine there without any issues.
The main difference seems to be with the memory/fs implementation between runno & binji/wasm-clang.
The text was updated successfully, but these errors were encountered: