3 ms·
It's supported by Clang, so widely used in open source projects - systemd, libvirt, everything using glib, some Linux kernel tools, dracut, qemu, glibc, ..
by rwmj 4y ago
It's supported by Clang, so widely used in open source projects - systemd, libvirt, everything using glib, some Linux kernel tools, dracut, qemu, glibc, ..
- pjmlp 4y agoApparently, no one has bothered to update clang´s documentation on that regard, https://releases.llvm.org/14.0.0/tools/clang/docs/AttributeReference.html https://releases.llvm.org/14.0.0/tools/clang/docs/AttributeR... Many of those open source projects happen to only compile with GCC, exactly because they rely on GCC C. Google has spent several man years making the Linux kernel compilable with clang, and not all of it has reached upstream to this day.
- rwmj 4y agohttps://clang.llvm.org/docs/AttributeReference.html#cleanup https://clang.llvm.org/docs/AttributeReference.html#cleanup. We use it in several projects and compile those with clang. Here's nbdkit compiled with clang 14: https://gitlab.com/nbdkit/nbdkit/-/jobs/2814022460 https://gitlab.com/nbdkit/nbdkit/-/jobs/2814022460 checking whether clang is Clang... yes [...] checking if __attribute__((cleanup(...))) works with this compiler... yes
- pjmlp 4y agoThanks for the example.
- loeg 4y agoYes, Clang is pretty bad about updating their documentation of GCC features they support.
- ndesaulniers 4y ago> and not all of it has reached upstream to this day. Which parts haven't? Asking as the project lead.
- pjmlp 4y agoAs far as I can tell, only Linux Android compiles cleanly out of the box with clang, not so with regular Linux kernel. At least that is my impression from occasional Linux talks. By the way what's up with NDK, Android packages, and that roadmap with better C++ development? Thankfully no longer a problem of mine.
- ndesaulniers 4y ago> not so with regular Linux kernel. $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git $ cd linux $ make LLVM=1 -j$(nproc) defconfig all -s $ echo $? 0 $ See also the official kernel docs which describe more which architectures can be expected to compile cleanly out of the box. There are something like 10^6000 possible kernel configurations though, so no promises (regardless of toolchain). https://www.kernel.org/doc/html/latest/kbuild/llvm.html#supported-architectures https://www.kernel.org/doc/html/latest/kbuild/llvm.html#supp... We support clang-11 and newer. Linus Torvalds has been using clang to build the kernels he runs personally, for ~2 years now. https://lore.kernel.org/lkml/CAHk-=wiN1ujyVTgyt1GuZiyWAPfpLwwg-FY1V-J56saMyiA1Lg@mail.gmail.com/ https://lore.kernel.org/lkml/CAHk-=wiN1ujyVTgyt1GuZiyWAPfpLw... >> I build the kernel I actually _use_ with clang, and make sure it's clean in sane configurations Not sure what's going on these days in Android land, thankfully no longer a problem of mine.
- pjmlp 4y agoI stand corrected, and apparently the love for the NDK experience goes both ways.