-
Notifications
You must be signed in to change notification settings - Fork 13
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
WIP: Add clang support #236
base: master
Are you sure you want to change the base?
Conversation
Depends on #232 ... |
Thanks a lot! 🎉 I'll have a look in the next days.
Looks like it is using the wrong library. The compat-toolchain is a cross-compiling toolchain! That should never use libraries from the host. (BTW, the CI build failed because Bob was not updated on ci.bobbuildtool.dev. I've fixed that.) |
Add devel/clang to build clang and some more llvm tools. To be able to use clang as a drop in replacement for gcc also provide some wrapper scripts + a helper class. This allows to use clang by inheriting of clang-class.
By inheriting clang from cpackage all cpackage using recipes are using clang as compiler. Unfortunatelly clang finds more warning making some packages fail if they are using -Werror. As most of them are using autotools disable clang for autotools based packages. Any other recipes could set `USE_CLANG` to 0 in their privateEnvironment to stay at gcc.
I added a small patch to work around the issue with the zstd lib. Looks like the cmake parameter is not passed to the native configuration when cross compiling and a shared zstd is the default... |
I'm still rebasing our ~4 years old basement to the upstream basement / basement-gnu-linux. Turns out building the latest mesa3d for intel requires llvm-libs + (ocaml) bindings as well. I'm in progress of reworking this... |
Thanks. That is very much appreciated! I'm still pondering about how we should exactly integrate clang support. I think there are two use cases:
I would consider the need for LLVM to be somewhat independent of this. Clang is really the C/C++ compiler frontend for LLVM and serves as a drop-in replacement for gcc. Packages that need LLVM can still be compiled with gcc, they just need the tooling and/or the library. AFAICT rust bindgen is such an example too. Then there is also But because there certainly are packages that cannot be compiled with clang, I would not make this a global decision. Instead, a project may enable clang for parts of the dependency tree. How to enable clang without modifying existing recipes is still something where I have no good idea to be honest. BTW, there seems to be Yocto layer and there they seem to have a rather large blacklist of incompatible packages. Additionally, the layer seems to modify many other recipes. |
ATM we only have use-case 1, but with some additional requirements. We're compiling our packages with both, gcc and clang to get different warnings or errors. We're also using different version to check if it breaks with an older version and so on. Obviously we don't want to edit the recipe to switch between clang and gcc. This is done in the clang-class either setting We're not using For me it would be also fine to upstream only the llvm-recipe (I think it should go to |
Having support for clang in basement totally makes sense. It's just a question how it is done exactly. The The recipe itself could be named |
Add support for clang and provide wrappers + to use it as a "drop-in" replacement for gcc.
The clang-class could be used to set CC and CXX to the clang wrappers so that the remaining recipe could stay untouched.
By adding clang to cpackage it becomes the default compiler, but since there are many autotools-based packages not compiling with clang I disabled clang within the autotools class. So only cmake and meson packages are using clang.
I haven't compiled all packages with clang so this might break some packages. But at least for the packages we're using it works this way. As an alternative it would be also possible to selectively enable clang for packages where it has been tested. 🤷
There is one known issue I couldn't solve - it doesn't compile outside the sandbox:
I guess this is because the host-compat-gcc is too old to work on my (arch-based) system...