-
Notifications
You must be signed in to change notification settings - Fork 942
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
main: add support for LLVM 11 #1056
Conversation
Try to fix this problem #918 please, if it's possible in new LLVM... |
f463f0b
to
424ee98
Compare
Looks like a rebase is needed... |
63bb31a
to
ab71f83
Compare
In Fedora, we are already starting to use LLVM 11 for Fedora 33. I started testing out TinyGo 0.14.1 which obviously doesn't yet support it. I pulled the
|
Huh, I thought ditching thumb solved this, but maybe not?
I don't see how tinygo could create this by itself? Unfortunately, this looks like it could just be an LLVM bug? |
Surprisingly, updating to latest commit of wasi-libc (WebAssembly/wasi-libc@215adc8) 'just worked', and was able to compile. I'm not sure exactly which commit fixed it and if you want update directly to it (there are many large updates like the above-mentioned musl updates). This plus the
|
I reverted Clang/LLD/LLVM to 10 and this warning still happens, so I guess not? It's not specific to 11 at least. |
I missed it earlier, but this one is fixed by WebAssembly/wasi-libc#152. So the minimum commit to avoid the two diff errors is WebAssembly/wasi-libc@38b930a, which is about halfway between what TinyGo uses and the latest commit. |
The |
Looking into this now. |
0d82645
to
43ac6c2
Compare
Right now I'm hitting this:
... which I don't quite understand. |
I have made a separate PR to update the wasi-libc dependency: #1309 |
The tail-call thing seems to have to do with the $ go run . build -target wasm -wasm-abi=js -print-stacks -o channel.o testdata/channel.go
error: scheduler.go:76:15: in function runtime.chanSend.resume void (%runtime.chanSend.Frame*): WebAssembly 'tail-call' feature not enabled
exit status 1
$ go run . build -target wasm -wasm-abi=js -print-stacks -o channel.bc testdata/channel.go
$ go run . build -target wasm -wasm-abi=js -print-stacks -o channel.ll testdata/channel.go There seem to be many wasm features that are not listed in $ wasm-ld --features=+tail-call --allow-undefined --stack-first --export-all --no-demangle $TINYGOROOT/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a channel.bc -o channel.wasm
wasm-ld: error: scheduler.go:76:15: in function runtime.chanSend.resume void (%runtime.chanSend.Frame*): WebAssembly 'tail-call' feature not enabled
wasm-ld: error: scheduler.go:76:15: in function runtime.chanSelect.resume void (%runtime.chanSelect.Frame*): WebAssembly 'tail-call' feature not enabled
wasm-ld: error: scheduler.go:76:15: in function runtime.chanRecv.resume void (%runtime.chanRecv.Frame*): WebAssembly 'tail-call' feature not enabled I was able to get a further using
So if you can figure out how to transform that |
Another path with $ llc --filetype=obj --march=wasm32 -mcpu=bleeding-edge -o channel.o channel.ll but it maybe enables too much: $ wasm-ld --allow-undefined --stack-first --export-all --no-demangle $TINYGOROOT/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a -o channel.wasm channel.o
wasm-ld: error: 'atomics' feature is used by channel.o, so --shared-memory must be used and that then requires a larger memory size: $ wasm-ld --shared-memory --allow-undefined --stack-first --export-all --no-demangle $TINYGOROOT/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a -o channel.wasm channel.o
wasm-ld: error: maximum memory too small, 67344 bytes needed which compiles, but doesn't run: $ wasm-ld --shared-memory --max-memory=131072 --allow-undefined --stack-first --export-all --no-demangle $TINYGOROOT/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a -o channel.wasm channel.o
$ node targets/wasm_exec.js channel.wasm
[CompileError: WebAssembly.instantiate(): invalid memory limits flags @+718] I don't know what to fix there, but it does suggest that if you could figure out how to enable features like tail-call, but not the other stuff like atomics, you might be able compile and run. |
@QuLogic thanks a lot for all the research you did! Yes, it appears to be a target feature and |
Also, it's not a linker issue but a compiler issue. This is how you can reproduce it without invoking the linker:
|
This can be useful to test improvements in LLVM master and to make it possible to support LLVM 11 for the most part already before the next release. That also allows catching LLVM bugs early to fix them upstream. Note that tests do not yet pass for this LLVM version, but the TinyGo compiler can be built with the binaries from apt.llvm.org (at the time of making this commit).
I think I have a solution, let's see what CI thinks of it. |
Tests passed, so this should be ready for merging. The only thing I noticed was that the commit message is wrong (it says tests don't pass), if approved I can fix that while merging (or the one who merges it can fix it during "squash and merge"). In essence, to fix that last error I added a |
I compared code size and while it obviously changed, it went both ways. Some programs increased in size, others decreased. |
Do you mean with LLVM11, or with/without tail calls? |
With LLVM 11. With/without tail calls isn't really a useful statistic as it isn't enabled by default in any major browser and it wasn't enabled in LLVM 10 anyway (otherwise wasm output would not have worked in a browser). |
This one is fixed by #1368. Then this PR fixes everything else with LLVM 11. |
I suppose you're waiting for the final LLVM 11 release, but to let you know, I've already been building this against LLVM 11 on Rawhide and it's worked fine for all tests. |
LLVM 11 has just been released: https://lists.llvm.org/pipermail/llvm-announce/2020-October/000089.html |
I'm not waiting for anything - I'd like to see this PR merged. Is there anything blocking it? |
Getting CI failures such as
which appears in https://app.circleci.com/pipelines/github/tinygo-org/tinygo/3773/workflows/2ff8b6ab-e33b-4946-81e3-b68f66dae25d/jobs/19529 |
That should have been removed by #1308? Also, don't forget to merge the llvm11 branch in https://github.com/tinygo-org/go-llvm |
Just added #1437 which should correct that build error, I think? Just waiting for CI to finish. |
Yes, confirm that #1437 corrects that build error. |
That was for targets/wasm.json. Presumably targets/wasi.json was a copy of it, so also copied |
This can be useful to test improvements in LLVM master and to make it
possible to support LLVM 11 for the most part already before the next
release. That also allows catching LLVM bugs early to fix them upstream.
Note that tests do not yet pass for this LLVM version, but the TinyGo
compiler can be built with the binaries from apt.llvm.org (at the time
of making this commit).
One concrete example of what I want to do with this change is to test/improve AVR support: upstream master has a number of improvements that aren't included yet in LLVM 10.
Note that #1055 should be merged first.