-
Notifications
You must be signed in to change notification settings - Fork 36
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
Native toolchain #25
Comments
https://github.com/McIkye/tools/tree/master/ld (AerieBSD toolchain. lacks mips support, but small and portable) |
Amended: we don't need PIC. I fixed the pcc bug. |
pcc has -msoft-float. So technically as long as it is able to write out asm for any random C file, we're only looking at improved optimization (via things like -mips32r2) and not filling in missing support. I've updated the original post to reflect where we are. I put GNU as 2.11.2 in the package repo for those looking to experiment. |
Thanks for a link to AerieBSD toolchain. The linker looks pretty clean compact. It definitely makes sense to consider it as an alternative solution. |
Smaller C has a number of language limitations (see the docs on project's page on github), which aren't necessarily show-stopping if we're talking about ANSI C, but necessitate some source code massaging (also, there are very few later language additions (C99) and no GNU C extensions, which you'll likely find in the OS code / library in a few places (e.g. 64-bit ints, weak attributes, etc)). Bootstrapping another compiler with it is pointless IMO. May be a good exercise, but probably no more than that. Good for small apps like those examples in RetroBSD. |
For completion, lcc has been added to the ports tree. It can't become a system compiler (bad license) but there's no reason it can't be used by people who want to use it, or just want to try an alternative to pcc. |
It would be good for LiteBSD to have a native toolchain. That way it could be self-hosting, we could have a real ports tree (or pkgsrc might be nice too, our ksh is enough to bootstrap pkgsrc).
The minimum toolchain has four parts: a C preprocessor, a C compiler, an assembler, and a linker.
Any and all help appreciated. Let's get LiteBSD self-hosting!
Here's where we are for each:
Preprocessor:
Most C compilers include a preprocessor but there are others out there if we want to use them (search pkgsrc for "cpp" to find some). RetroBSD uses pcpp from pcc. We also use a modified cpp.sh from OpenBSD for /usr/bin/cpp
Compiler:
pcc - compiles, it produces mips1 code only, does PIC (via the assembler), comes with a working preprocessor (pcpp), needs an external assembler and linker, miscompiles anything more complex than a basic program, libpcc works but libsoftfloat does not yet have MIPS support. I have been sending patches to upstream. This would be a good candidate for the system compiler if we can get enough people to work on it for MIPS: it is BSD licensed, a C11 compiler, small, and could potentially rid LiteBSD of its libgcc requirement (via libpcc and libsoftfloat). Does not include a C++ compiler but that is a potential future addition (a cxxcom exists). It appears to write out asm for any random C file I give it and has -msoft-float support. Future improvements would be further optimizations (such as -mips32r2) to make more compact/faster running code.
gcc - the beast is huge, written in C++, might be too big to run on LiteBSD(?), needs a nasty cross-native build to even determine if it would work, which has not been completed. Needs an external assembler and linker, usually GNU binutils. Supports everything. Includes a CPP and a C++ compiler. It is GPLv3 licensed: we could either not care (like NetBSD or DragonFly BSD) or aim to use gcc-4.2.1 (the last GPLv2 release) like OpenBSD does. Always a potential system compiler.
clang - also huge, also written in C++, might also be too big to run on LiteBSD: no work has been done to get llvm to run on LiteBSD. Includes its own C++ compler, CPP, and assembler (which is built-in, llvm-as will be a standalone application in llvm-3.8.0), requires an external linker (caveat: lld can statically link mipsel binaries but do not know if it can do anything else), supports everything, BSD licensed. FreeBSD uses this as its system compiler, DragonFly will move to this as one of their 2 supported system compilers, NetBSD has considered moving, OpenBSD has considered moving. A potential system compiler if it can run on LiteBSD.
smlrc - Supports RetroBSD, could likely be re-targeted for LiteBSD. Needs the rest of the suite. Unknown if could be a system compiler (but seems like yes, due to it having that distinction for RetroBSD). Unlike all of the above, is not a C11 compiler (it is C89/C99, which is enough for LiteBSD) but might be able to bootstrap pcc or an earlier gcc.
Assembler:
GNU as - Up to version 2.11 works. 2.12 and above segfault on startup (unknown if memory exhaustion or they're being miscompiled). GNU as 2.11.2 is in the LiteBSD package repo.
Serge's as - A GNU as syntax assembler. As long as it can assemble everything pcc and gcc (and smlrc) give it, it would be a perfectly good system assembler. The -k flag (produce PIC code) is currently unsupported but should be considered a hard requirement.
Other assemblers - ???
Linker:
GNU ld - Up to version 2.10 works (as in, doesn't segfault) but doesn't successfully link anything. Version 2.12 and above, same as GNU as. If it is miscompilation that is causing the problems, the problems are likely in libiberty or libbfd and affecting both programs.
LLVM lld - Likely able to link static binaries if it can run on LiteBSD
ELFtoolchain ld - Runs, fails to link anything (see my post on the forums).
The text was updated successfully, but these errors were encountered: