Does not compile
Opened this issue · 9 comments
Hi! While I loved your project, none of it works "nowadays" ( = Ubuntu 22.04).
First it protests that there is no MIPS toolchain, even if one does install gcc, and if one adjusts the prefixes, still no successful compilation is achieved - in the end, anyway, I do not get the unix.hex. Is there any chance to "fight the bit rot" on this one? It is a real technological gem and I love it!
Hi Nino,
You are right: unfortunately it's hard to find valid GCC toolchain for PIC32 these days. I tried UECIDE: see branch https://github.com/RetroBSD/retrobsd/tree/uecide-toolchain. I was able to build kernel, but something is still wrong with a linker script for user binaries.
Sorry, I cannot spend much time on it now. Maybe someday. It should be possible to build Retrobsd on older versions of Ubuntu, using docker or something.
--Serge
Since RetroBSD is retro it is written in a retro style for a retro compiler. In order to get it to compile with a modern compiler (available here: https://github.com/MajenkoProjects/chipkit-compiler/releases/tag/v0.0.1) we need to "de-retroify" it. That means making sure there's no multiple definitions where an "extern" is implied and now essential (kconfig for example), and no lazy "implied int parameter type" function signatures. In fact IMHO we need to go through and remove all the old-style function signatures and implied integer types throughout the entire codebase and replace them with proper definitions.
That means changing everything that's like:
int usbclose (dev, flag, mode)
dev_t dev;
{
...
with a proper
int usbclose (dev_t dev, int flag, int mode) {
We can't have anything implied any more. It's just not allowed in modern C.
Also, while we're at it - is there really any need to ever use the register
keyword any more? After all, modern compilers now have a clue...
Ugh... the kernel is full of badly defined variables in header files. Quite frankly I'm surprised this ever worked...
The whole kernel compilation relies on "old" undefined behaviour of multiple definitions across TUs being collapsed into one definition. Now that isn't the case, it's strict about it. So all the definitions of variables in the kernel header files will have to be moved out into source files and replaced in the header files with proper extern
definitions. It's a real mess.
As for multiple definitions and need for "extern", it's all about violation of the One Definition Rule. Not long ago this rule was introduced in C++, and then people decided to back propagate it to C as well. So now we have to update our legacy code to make it suitable for modern compilers.
It's not a big deal to modify the kernel code to eliminate multiple variable definitions.
BTW, @majenkotech, what's your opinion about using clang for pic32? I know it's possible, but I never tried it myself.
I've enabled the Discussions tab. Feel free to move here: https://github.com/RetroBSD/retrobsd/discussions
BTW, @majenkotech, what's your opinion about using clang for pic32? I know it's possible, but I never tried it myself.
I have no opinion. I have only used it when it's been the default installed native compiler.
I saw something about clang for pic32 in the Twinbeam project: https://github.com/andeha/Twinbeam
Thought, maybe you tried it already.
Discussion continued here: #83
Hi Nino, You are right: unfortunately it's hard to find valid GCC toolchain for PIC32 these days. I tried UECIDE: see branch https://github.com/RetroBSD/retrobsd/tree/uecide-toolchain. I was able to build kernel, but something is still wrong with a linker script for user binaries. Sorry, I cannot spend much time on it now. Maybe someday. It should be possible to build Retrobsd on older versions of Ubuntu, using docker or something. --Serge
It's also possible to build RetroBSD with the GCC toolchain found here: https://github.com/RetroBSD/retrobsd/releases/tag/tools