-
Notifications
You must be signed in to change notification settings - Fork 915
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
Windows 386 build support #3353
Comments
Correct, windows/386 is not currently supported. (But we should really be printing a more useful error message here). I think windows/386 support can be added, but maintaining it will be some work. Can you describe why you need it? |
Creating tiny standalone utilities for x86-based Windows systems, with very weak CPUs (similar to Core 2 Duo) and limited RAM (up to 1GB). I can use the full Go, but tinyGo allows me to significantly reduce memory consumption. |
I started working on this and have a simple hello world printing before it crashes for yet unknown reasons. |
I did the other things i wanted to achieve, now it is just about that crash i cant debug. I parked the current work here for anyone who wants to take a look. |
My first guess would be that you use the wrong calling convention in task_stack_386_windows.S. You can try to build with |
I tried preserving xmm6 and xmm7 as mentioned here and also a hail mary approach with pushf/popf and pusha/popa, but it didnt help. When doing |
One thing i found when appending So it seems for 386 mingw adds a leading underscore by default to things and there is |
After some more testing it turns out the crash happens when the tinygo program exits, not during the run. Which just makes it much weirder. With scheduler and gc completely disabled and looking at the binary in ghidra, it really just printlns the message and then exits with code 0 as you would expect. (it looks just like a C hello world to be precise)
However, the linker issue above makes it impossible to write complex programs as you can not even import "time" without ending up in unresolved function calls due to the underscore issue.
I tried importing the relevant patches from upstream llvm into the local version which itself apparenly is a fork of llvm with patches and then recompile llvm, but it did not pick up on the option. |
xmm6 and xmm7 aren't mentioned there, where did you get them from?
...means that stack switching needs to preserve |
How I usually approach this is by familiarizing myself closely with the used calling convention, and then single stepping through the stack switching code to see where it goes wrong. |
Sorry, wrong link. Its that quote from stackoverflow
Oh i see, i need to preserve the so-called scratch registers. |
Sorry I made a mistake before. When I said:
That's wrong, the same registers need to be saved that are typically saved in a function call. Basically, the code is to switch to a different goroutine. It is called like a regular function call, and needs to preserve the same registers that are typically preserved in a function call. This means scratch registers can be clobbered, but all other registers need to be saved and restored. That means, I believe the set of registers that need to be saved and restored are: https://godbolt.org/z/79WTzvWE5 (plus of course the stack pointer).
There is probably only one calling convention, you just have to figure out which. I also recommend looking at the stack switching code for other architectures, it might help to figure out the pattern. |
Currently its a 1:1 copy from this. But until llvm is updated, this will be on hold. |
@BieHDC |
Yes it is about that option, but tinygo did not like linking against it. |
TinyGo needs to be updated to statically link against a particular LLVM version, unfortunately. You could however try to apply the llvm/llvm-project@fb19fa2 patch manually to the LLVM 16 tree. |
I tried that too together with that other patch that this one depends on, but in the end it still said that the option is unknown. Edit: i did try to play with that again by hardcoding AddUnderscores to false or true and it results in ether it not finding the mingw function definitions or it not finding tinygos exports because they do not have underscores (for example |
I am picking this up again as i got some time. Here is the current branch dev...BieHDC:tinygo:dev |
Did some experimenting myself, see: #4629 |
Are there plans to add x86 support?
Input:
$Env:GOARCH=386
tinygo build -no-debug -o result.exe
Result:
error: failed to hash file: open O:\TinyGo\src\runtime\asm_386_windows.S: The system cannot find the file specified.
The text was updated successfully, but these errors were encountered: