IRIX Network Forums
Cross-compiling CI builds for IRIX - Printable Version

+- IRIX Network Forums (//forums.irixnet.org)
+-- Forum: SGI/MIPS (//forums.irixnet.org/forum-3.html)
+--- Forum: Development/Porting (//forums.irixnet.org/forum-9.html)
+--- Thread: Cross-compiling CI builds for IRIX (/thread-3337.html)



Cross-compiling CI builds for IRIX - c0mpyl3 - 01-08-2022

This is my first post, so I hope it's a good one.

I have an open source C++20 project called Hajime (no relation to anime) which has cross-platform compatibility as one of its hallmark goals. It's also hosted on GitHub so I get access to their Actions VMs. Because of that, I've set up Actions to compile Hajime for 14 (!) different platforms on every commit. With all of the most common combinations covered, I thought IRIX would be the obvious next step as the SGI workstations are probably powerful enough to run the associated software and are just common enough to be practical. 

To give some background, Hajime is "startup script" made for Minecraft Java Edition server software. The Java servers are essentially single-threaded (although there have been about 10 years of optimizations made to improve that) and don't require too much processing power for simple tasks. The memory requirements also fall in what a typical SGI machine could do (2-4GB is enough) so targeting IRIX seems like low-hanging fruit.

The problem is how to get IRIX builds working with GitHub Actions. The VMs they offer are pretty limited: Ubuntu, macOS, and Windows. I know that you can get Clang/LLVM working natively and through cross-compiling. However, the problem with this is that we can't spend too much time using the VMs or accessing the finished build artifacts will be annoyingly slow. I've had to solve a similar problem for compiling to ARM macOS (GitHub only offers x86 VMs), RISC-V/ARM64/ARM32hf/ARM32l/etc Linux, and any kind of FreeBSD. So, for IRIX, here's a braindump of all the possible options:

- Download a premade cross-compiler package. This is easy, but the available options are limited, and the available packages we can use for this generally target Linux. This is what I did for the Hajime Linux builds.

- Use a CMake build option. This is slightly harder and it provides some neat options, but I don't think any premade options can actually be used for IRIX. This is what I used for targeting ARM64 Windows.

- Add a Clang target flag. This only works for Apple Clang without any extra setup.

- Download an installation image, mount it, and use its libraries as a Clang sysroot. This option is extremely clever and it's the easiest way to cross-compile for FreeBSD in a Linux VM.

- Download a VM, run it, and connect to it to run a script. This is the hardest option but it theoretically works for any platform that you can make a VM with. If the architecture  is different, then just use emulation. This is the only option that Hajime doesn't use.

With all this considered, I think getting Hajime available for IRIX is possible. Here's some general notes on the whole process:

- There are a few premade MIPS cross-compile packages available for Ubuntu. If I were OK with only targeting Linux on MIPS (but still running on SGI) then this would take only seconds to implement in GHA.

- Hajime doesn't use any special GUI APIs, so we can stick to pure POSIX compat.

- Hajime has a few Windows-specific code additions but those don't matter here.

- Hajime requires C++20 but might be able to work with C++17 with a couple changes.

- If FreeBSD has good ABI compat, then I could easily target Hajime for that.

- I don't have any SGI hardware myself, but I'm open to emulating IRIX or doing some other fancy method to get it working.

- A link to the project: https://github.com/Slackadays/Hajime

Any ideas for what I can do going forward?


RE: Cross-compiling CI builds for IRIX - Raion - 01-08-2022

Hello c0mpy13.

Thanks for joining up, and let me welcome you to the forums.

The first question I have for you is /why/ IRIX? IRIX doesn't support Minecraft, because it is limited to ancient versions of Java. You wouldn't have any way to test the resultant code.

Assuming you want to press onwards, I have a number of caveat emptors to give you:

1. IRIX is not possible to virtualize or emulate for development purposes. Yes, you can absolutely run qemu-irix to run the compiler, but it's not designed for that. Qemu-irix was only ever designed as an N64 hacking tool to allow for source decompilation of N64 games using IRIX's compiler suites. Yes, you can run IRIX in MAME, but it's like a real world 10MHz R4000 CPU, meaning IRIX will not run well or fast enough to make compile times worth it. About 2 years ago, I compiled GCC on an R5000 Challenge S for shits and giggles. I had to run it single-threaded, have plenty of swap, and it took 3.5 days. An R5000 is much faster, so how fast will this take you?

2. Yes, you can cross-compile IRIX using LLVM or GCC. But it's not well-documented, and while plenty of people do it, less has been tested with C++20 codegen than say, C++11. Most people aren't targeting the latest and greatest C++ for IRIX because the OS hardware is simply pretty slow. What can you run that's C++20?

3. There's basically no way to test it from my understanding? We can't run recent Java. 1.3 is the latest I think.

Anyways, let me answer:

IRIX and FreeBSD are too different. ABI isn't anywhere near similar. IRIX's closest relatives are Solaris 8 and 9. And even then, those ABIs are different enough you can't depend on it.

My suggestion if you insist: Cross-compile using a toolchain out there on github, or ask nicely for access from one of our members with the necessary gear. Vvuk comes to mind as a potential candidate?

Linux on MIPS/SGI hardware isn't really discussed on IRIXNet, but if you want to, put it in Other UNIX, the SGI/MIPS categories only really cover IRIX. It's not very functional. IRIX runs on a very specific version of MIPS. I would honestly suggest if you want a modern MIPS, target the XLP MIPS or Creator CI20.


RE: Cross-compiling CI builds for IRIX - c0mpyl3 - 01-09-2022

Thanks for the warm welcome! I've always had a little interest in SGI MIPS but I never did anything with it until now.

Regarding the Java requirement, it turns out that it's a common misconception that Hajime requires a Minecraft Java server. By itself, Hajime has no hard requirement for Java, but rather only has deep integration with it for configuring and setup. In fact, I even used the bc calculator for testing some of its latest "Java terminal" features which were nothing more than fancy POSIX file descriptors.

For actually making it work, I'll have to try building some cross-compile toolchain like you mentioned. If it isn't too hard to build then I could make a script to build it in the VM. If it is hard (very likely!) then I'll just build it once and put it on a fileserver for caching.

For the C++20 compat problem, it shouldn't be too difficult to manage because I use very few C++20 features, a couple C++17 and C++14 ones, and a boatload of C++11. However, I can see how it would get painful quickly.

Finally, if all else fails, I would just target XLP MIPS or even the special Mediatek MIPS SoCs that you commonly find in network routers. I have a Mikrotik that uses one and you could flash OpenWRT on it and have an instant MIPS development board.


RE: Cross-compiling CI builds for IRIX - Raion - 01-09-2022

I was not saying Haijme itself has a build or runtime dependency on Java, but rather the "Why port it to IRIX when we can't make actual use of it?" I don't know of any practical usage for Hajime here other than to say "I compiled C++20 for IRIX"

A lot of flowcharts for me that judge whether IRIX could benefit from an app would be as follows:

1. Does the app serve a purpose on IRIX?

This is the first step and the hardest one to answer. I usually first ask -- what is it that the app does? If it's, for example, a PCIe config utility, there's no point as none of the SGI MIPS stuff ever had PCIe, or if it deals with USB3 etc.

If it fits from a hardware dependency perspective, then you need to ask whether or not its functionality is provided by the OS. For instance, nobody is porting GDM or KDM or WingsDM to IRIX because we already have Clogin. Likewise, nobody is supporting GNOME or KDE because we don't need them, we have IID/IMD.

Finally, you need to ask yourself if it actually serves a purpose to the average user. Is it something an average user wants/needs?

2. Is the app feasible in terms of time and effort?

Whether or not something is a speciific C or C++ standard is often not the only blocker. For instance, when porting userspace commands, you need to check the headers included, whether or not they exist or have other headers providing the same/similar functions. Does the OS have the functions you need such as d_namelen for dirent, or sufficient unicode/wchar support? What about the mmap/malloc implementations? Are they safe and usable in this way?

This is way more low-level than you or I may normally think about it, but it's kind of important for IRIX. IRIX lacks unicode, many modern conveniences (i.e. no MAP_ANON, which btw, just use malloc(). MAP_ANON is not better or more useful) etc.

3. Is the end result going to be usable?

I can port GTK2/3 apps to IRIX, but are they going to look nice or run stably compared to native Motif apps? probably not.

I'm not going to discourage you from driving on here, but my personal view is "Why" When it's probably not relevant to our usage. at the end of the day, however, it doesn't matter to me or anyone else here. Do what makes you happy.