News for hackers. Stuff that matters.
Re:When can glibc be built with Clang? by qalmakka on Wednesday October 13, 2021 @02:32PM (#28855671)
Glibc has always been a whole rigamarole of nasty GCC-isms. I've been interested in building entire GNU/Linux systems with Clang for years, but I have always found a general lack of interest from both maintainers and the community.

It's nice to see that finally something is moving, especially now that Linux is also finally buildable with LLVM.

Re:When can glibc be built with Clang? by Karellen on Wednesday October 13, 2021 @04:57PM (#28857637)
A lot of the GNU tools have had dependencies on GNU-specific versions of classic tools because, for decades, the non-GNU versions sucked. Lots of hard-coded arbitrary limits (line lengths, file sizes, command line option counts), quadratic behaviours, crashes, weird corner cases.

Edit - also, lack of updates. POSIX added a new feature to a tool 5 years ago? Well, the built-in tool that came with your classic Unix probably still doesn't support it yet. The GNU tool does though.

If your build system effectively relies on GNU `make` because 75% of the other `make` implementations out there either barf on your makefile, or don't run the build steps correctly, despite it being valid according to the spec; and GNU `make` has a bunch of features that are really powerful and would allow you do some complex things more easily, or even do them at all; then why not just actually rely on GNU `make` and use the extensions?

Similarly, the bundled `cc`s with classic Unices (if they were provided at all) frequently had weird bugs or poor code generation that would go unfixed for years. If `gcc` was the only compiler you could rely on a) your users having access to, and b) to correctly compile your code; and it has a bunch of really cool features that make your code smaller or faster or cleaner, it's hard to resist that. Your code is still portable, because `gcc` is portable, and Free.

Re:When can glibc be built with Clang? by _jal on Wednesday October 13, 2021 @07:45PM (#28858910)
> Similarly, the bundled `cc`s with classic Unices (if they were provided at all

It has been a generation since it was common for people to pay for Unix, and then pay more for shitty developer tools.

That gcc has gone from savior to legacy in that time is a huge testament to the value the open source world has created. But I think people forget the bad old days pretty quickly.

Re:When can glibc be built with Clang? by pjmlp on Thursday October 14, 2021 @02:16AM (#28861057)
HP-UX, Aix, Solaris and mainframes POSIX environments are still around.

Additionally, embedded also has plenty of POSIX like OSes that arent' Linux based.

Re:When can glibc be built with Clang? by hackerbrother on Thursday October 14, 2021 @09:10PM (#28872619)
AIX is doing a lot better than HP-UX and Solaris are. In relative terms.
Re:When can glibc be built with Clang? by Ericson2314 on Friday October 15, 2021 @12:15AM (#28874214)
> That gcc has gone from savior to legacy in that time is a huge testament to the value the open source world has created

I hope GNU can turn itself around, but because having n+1 competing FOSS implementations is a huge boost. I just fear it is not a sustainable situation.

libgccjit and the new rust backend is a good sign.

Re:When can glibc be built with Clang? by GoblinSlayer on Friday October 15, 2021 @05:38AM (#28875936)
That's exactly an illustration that a few competitors is unhealthy for the ecosystem, and llvm isn't going to evolve as fast as it did.
Re:When can glibc be built with Clang? by Ericson2314 on Friday October 15, 2021 @04:19PM (#28882667)
If LLVM vanquishes GCC, you mean?
Re:When can glibc be built with Clang? by eschaton on Thursday October 14, 2021 @09:53PM (#28873081)
The thing is, you didn’t pay more for shitty developer tools. You paid more for good tools. The system compiler existed solely to enable kernel rebuilds prior to the advent of loadable kernel modules on most vendor UNIX platforms.
Re:When can glibc be built with Clang? by gumby on Thursday October 14, 2021 @12:32AM (#28860543)
Sad to say there are still tons of those ancient systems in production use.
Re:When can glibc be built with Clang? by e40 on Wednesday October 13, 2021 @02:48PM (#28855847)
I looked and didn't see any answer to... is there a difference in performance of the gcc vs llvm compiled kernel?
Re:When can glibc be built with Clang? by mjevans on Wednesday October 13, 2021 @03:49PM (#28856715)
They're different compilers so I assume the answer would be yes.

If it isn't possible to build currently I expect minimal clarifying changes wouldn't have much impact on runtime performance (where it compiled previously), but as mentioned in another post would lower the risk of bugs and maintenance burden with clearer code.

Portability, validation, across multiple platforms is one way of exposing bugs and weaknesses in logical description.

Re:When can glibc be built with Clang? by astrange on Thursday October 14, 2021 @05:51PM (#28870662)
> They're different compilers so I assume the answer would be yes.

They have highly similar designs (at least in the middle-end which is the important part), or did, but gcc's remaining large customers care most about optimizations so it's still somewhat ahead there.

Re:When can glibc be built with Clang? by stncls on Wednesday October 13, 2021 @04:25PM (#28857234)
Those are not necessarily comprehensive benchmarks, but it seems clang is doing very well in many workloads:

https://www.phoronix.com/scan.php?page=article&item=clang-lt...

Re:When can glibc be built with Clang? by voldacar on Wednesday October 13, 2021 @04:35PM (#28857346)
GCC with max optimization still generally produces faster binaries than clang, but clang is constantly improving and in a few years they will probably be very similar.
Re:When can glibc be built with Clang? by tambourine_man on Wednesday October 13, 2021 @05:40PM (#28858035)
Is that still true though? It was definitely the case some 5-10 years ago, but last time I checked they were pretty comparable, losing some, winning others.
Re:When can glibc be built with Clang? by voldacar on Wednesday October 13, 2021 @05:57PM (#28858185)
clang wins on some benchmarks, but gcc wins on over 50% of benchmarks, at least this always seems to be the case whenever I look it up.

If I were writing a program that needed to be really fast I would just compile with both on max optimizations and pick whichever was best. Most software isn't the linux kernel and will work fine with both compilers

Re:When can glibc be built with Clang? by qalmakka on Saturday October 16, 2021 @04:35AM (#28886406)
These benchmarks also don't reflect how good are the backends for different CPU architectures in GCC and LLVM.

For instance, GCC is by far the dominant compiler on GNU/Linux on x86, while LLVM has a almost total monopoly of AArch64 (think about Android NDK + iOS + macOS). I think it would be quite natural for the GCC AArch64 backend to get less focus compared to its x86 counterpart. It's a complicated landscape that is always full of gotchas, and that's why I don't like these kinds of benchmarks a lot.

Re:When can glibc be built with Clang? by pyler on Wednesday October 13, 2021 @06:41PM (#28858496)
source? llvm 13?
Re:When can glibc be built with Clang? by mhh__ on Thursday October 14, 2021 @03:17PM (#28868706)
It's still true. Basically it's even as makes no difference except for ones where GCC is still way ahead. Real world code has to be measured for each to decide.

The key takeaway is that GCC is still an extremely good compiler.

Re:When can glibc be built with Clang? by hulitu on Thursday October 14, 2021 @10:48AM (#28865004)
That's why they said since 5 years. My experience was that clang seems longer compiling but due to the fact i did not compiled the same program with clang and gcc i would not take it as a rule.
Re:When can glibc be built with Clang? by voldacar on Thursday October 14, 2021 @05:40PM (#28870535)
I was referring to performance of the compiled program, not the time it takes to compile it.
Re:When can glibc be built with Clang? by eschaton on Thursday October 14, 2021 @09:52PM (#28873065)
A lot of people who use terms like “GNU/Linux” see the spread of GNU-isms in code as a way to preach their gospel and entrench their politics in codebases. Fortunately the LLVM ecosystem implemented a lot of those, so they couldn’t be used as an excuse not to use LLVM-based tools.