[HN Gopher] When can glibc be built with Clang?
       ___________________________________________________________________
        
       When can glibc be built with Clang?
        
       Author : zdw
       Score  : 63 points
       Date   : 2021-10-11 14:50 UTC (2 days ago)
        
 (HTM) web link (maskray.me)
 (TXT) w3m dump (maskray.me)
        
       | bombcar wrote:
       | These types of cleanups are great for identifying confusing code
       | (the first example is a perfect one where the compiler can figure
       | it out but the maintainer may not realize what's being done).
        
       | qalmakka wrote:
       | 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.
        
         | Karellen wrote:
         | 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.
        
         | e40 wrote:
         | I looked and didn't see any answer to... is there a difference
         | in performance of the gcc vs llvm compiled kernel?
        
           | voldacar wrote:
           | 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.
        
             | tambourine_man wrote:
             | 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.
        
               | voldacar wrote:
               | 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
        
               | pyler wrote:
               | source? llvm 13?
        
           | mjevans wrote:
           | 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.
        
           | stncls wrote:
           | 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...
        
       | williamstein wrote:
       | 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...
        
       | gpvos wrote:
       | https://www.canglibcbebuiltwithclangyet.com/ anyone?
        
       ___________________________________________________________________
       (page generated 2021-10-13 23:01 UTC)