Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
MIPS on Linux support #1075
MIPS on Linux support #1075
Comments
As far as I can tell, there are only a few things required to add support for such a target:
I can't think of anywhere else where changes would be necessary. After the appropriate changes are added, you should be able to build for MIPS by supplying an appropriate LLVM target to the |
Is there specific MIPS hardware you are looking to support? |
@deadprogram This issue seems to be regarding a Linux target, rather than baremetal. |
Yeah, It would be great to have bare metal support for mips24kc out of the box since that's basically used by most routers. UPDATE:It seems that after manually building LLVM as mentioned in Getting Started doesn't contain mips arch as a target
|
Are you interested in baremetal or Linux support?
Yes, you need to modify this line to add Mips to the enabled targets: Line 157 in a9ba6eb It may be easier to instead use a prebuilt version of LLVM, which you can easily install on MacOS and most Linux distributions. It will have Mips already included as a target (no need to rebuild LLVM). |
Thank you for the tip, I was already digging inside, getting that little mipsy mips support in LLVM
I am honestly interested in having it work in both Linux and bare metal but I do understand that bringing bare metal support is a bit out of my skill scope, but I am very eager to learn and contribute UPDATE:Well, after some tinkering around, I was successfully able to compile mipsel targeted binaries (statically linked) and as well as executing them Here are the file size differences between golang compiled binaries and tinygo:
package main
func main() {
print("HELLO\n")
} Note: the binaries were compiled with omitted DWARF debugging information as well as symbol table generation using a brief
What's interesting here is the produced (by default) dynamically linked binary that is small in size albeit depending on libc.so.6 (glibC) which is missing by default on OpenWRT (muslC), so in order to fix this, an openwrt musl toolchain should be used but this out of the scope of this issue but I will eventually document that as soon as I'm finished. |
I'm also interrested on compiling for MTK7628NN with Linux support. With Go I select GOARCH=mipsle GOMIPS=softfloat. |
@olarriga this is not yet implemented, see my first comment on this issue |
Yes, it's possible and beautiful, I'm currently working on it, will have a PR and a documentation published soon. UPDATE:Currently the compilation is spewing a warning concerning wrong floating point setting but the binary is functioning properly, yet to figure out where to put the -msoft-float flag in tinygo/llvm given that the musl toolchain already uses -msoft-float
UPDATE:Seems like -msoft-float flag is being ignored by llvm/clang, but considering that the binaries are working properly, it isn't critical atm. UPDATE:After having configured both the mips and mipsel toolchains, I went ahead and tried to compile a sample golang code using the fmt library, the compiler spewed the following:
I figured that UPDATE:After hours of thorough studying of mips specs and docs, I have found out that the /o32 ABI only has 4 argument registers which is less than syscall6 arg length UPDATE:I had no luck in assembling a working solution so far so it's a roadblock at the moment, basically everything works but syscalls |
You probably need to set a flag (
Ah really, they are passing syscall arguments on the stack? That complicates things a bit. |
It seems that tinygo doesn't not support MIPS based embedded devices out of the box, although LLVM does support the following:
My intent is to execute the tinygo compiled binary within a mipsel linux box, no bare metal support, so I assume that's feasible considering llvm support.
This would be extremely useful for routers with a limited set of storage and ram.