Live data from Hacker News

When can glibc be built with Clang?

maskray.me

11–20 of 30 posts

Re: When can glibc be built with Clang?

#12
post #8

Earlier quoted context omitted.

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.

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.

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?

#13

Earlier quoted context omitted.

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.

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

source? llvm 13?

Re: When can glibc be built with Clang?

#14

Zig builds its own copy of glibc with clang on a whole bunch of architectures: https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...

Are you sure about that?

> And finally, we certainly do not ship the build system of glibc with Zig! I manually inspected, audited, and analyzed glibc's build system, and then by hand wrote code in the Zig compiler which hooks into Zig's caching system and performs a minimal build of only these start files, as needed.

It sounds to me like they build glibc using its own build system, but they use Zig to build the statically-linked glue code necessary to dynamically link to a system glibc. This allows cross-compiling to a glibc target without having glibc installed locally. Certainly very impressive.

Re: When can glibc be built with Clang?

#15
post #9
post #3

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.

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 pr…

> 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?

#16
post #15
post #9

Earlier quoted context omitted.

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 pr…

> 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.

Sad to say there are still tons of those ancient systems in production use.

Re: When can glibc be built with Clang?

#17
post #15
post #9

Earlier quoted context omitted.

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 pr…

> 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.

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?

#18
post #8
post #4

Earlier quoted context omitted.

I looked and didn't see any answer to... is there a difference in performance of the gcc vs llvm compiled kernel?

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.

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?

#19
post #14

Zig builds its own copy of glibc with clang on a whole bunch of architectures: https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...

Are you sure about that? > And finally, we certainly do not ship the build system of glibc with Zig! I manually inspected, audited, and analyzed glibc's build system, and then by hand wrote code in the Zig compiler which hooks into Zig's caching system and performs a minimal build of only these start files, as needed. It sounds to me like they build glibc using its own build system, but they use Zig to build the stat…

You’re right - Many thanks for the clarification.

Re: When can glibc be built with Clang?

#20
post #8

Earlier quoted context omitted.

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.

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.

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.

Post reply on HN