Hello Genodians,
A couple of months ago I started wondering how hard would it be to add Genode support to clang. Since I nowadays have bit of extra free time on my hands I decided to give this a try. As one may guess adding support for a new platform to a complex codebase like llvm/clang is a relatively big undertaking so I decided that for the first stage I want to limit the scope of the work a bit.
1. Clang running on already supported "host" platform (in my case Linux) to compile code for Genode on x86_64, x86_32, arm_v7a and arm_v8a architectures. No support for running clang and all the llvm utils on Genode itself. 2. Try to use as many llvm tools as possible (llvm-ar instead of GNU ar, llvm-objcopy instead of GNU objcopy, etc), but don't try to replace GCC toolchain completely if it requires major effort (ex clang integrated as instead of GNU as, ld.lld instead of ld.bfd, etc). 3. Use libstdc++, libsupc++, libgcc instead of respective llvm replacements.
With those goals I started hacking and fast forwards those few months I've mostly achieved my goal. I currently have Clang 11.0.0 port able to compile working binaries for all the target architectures when using base-hw and base-linux. Obviously this did require a bunch of changes in Genode codebase itself, but most issues found were relatively simple and generally not specific to clang itself. For example clang is much better at spotting unused variables in the code, see the following PR: https://github.com/genodelabs/genode/pull/3938
When using clang I also managed to stumble upon some code relying on undefined behaviour, which happens to produce different results in clang than it does in GCC, ex: https://github.com/genodelabs/genode/pull/3941
Overall the number of problems encountered was lower than I expected, which I think puts Genode codebase in very positive light.
As one may easily guess there is still a lot of code Genode project consists of which I haven't even tried building, yet.
The reaason I'm writing this email is to ask if Genode project would be potentially interested in having clang support in the main repo? I know that officialy supporting another compiler might not be an interesting prospect for the project and I won't mind if the answer is no. Its enough for me if generic fixes I make get merged :). If there is an interest in clang support however, I'll be happy to spend a few evenings cleaning up my work and making a few more PRs out of it. If needed I can also push my remaing clang support patches in the existing, slightly chaotic form, to some branch so Genode developers can see how much work having clang support in Genode would entail.
/ptw