Announcement

Collapse
No announcement yet.

LLVM/Clang Can Work Fine As A GCC Replacement For Linux Distributions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    Less buggy then GCC? not in my experience. I personally default to gcc when I can because historically LLVM has exhibited really weird issues for me

    Comment


    • #12
      Originally posted by Volta View Post

      Good to know it's not a toy anymore (I couldn't care less about ability to compile macos or freebsd). Furthermore, this is no surprise, as they have been working on being able to compile the Linux kernel for years. Top notch? GCC is the facto standard. Would be great to see Linux kernel performance with llvm compared to GCC.
      You can check it yourself without any compilation. Just use OpenMandirva. By default, the system starts with the kernel-desktop - this is the version built with Clang, and kernel-desktop-gcc is also waiting in the repository. You can install it by "sudo dnf install kernel-desktop-rc" Also RC versions are available in both versions. You can easily check the performance of both.

      Comment


      • #13
        Originally posted by Volta View Post

        Yes, it's very irritating. Especially in job offers. I wouldn't touch C++ with a stick, so I hate when someone mentions it next to C.
        Yes, for me it is the other way around. Or even worse C with classes where people pretend to program C++ but actually use C pattern. Contemporary C++ has changed much in the last 30 years and it really should not mixed with C anymore.

        Comment


        • #14
          clang is still missing nested functions support in C. This is a very useful feature of gcc which I use frequently. I hope they will implement it some day.

          This is an example how it works in gcc: (count the size of a group at position x,y in the game of Go)
          Code:
          int group_size(int go_board[19][32], unsigned x, unsigned y)
          {
              int cnt = 0;
              int color = go_board[x][y];
          
              static long timestamp;
              static long ts_board[19][32];
          
              void gs_nested(unsigned x, unsigned y) {
                  if (x < 19 && y < 19)
                      if (go_board[x][y] == color)
                          if (ts_board[x][y] != timestamp) {
                              ts_board[x][y] = timestamp;
                              cnt++;
                              gs_nested(x, y - 1);
                              gs_nested(x + 1, y);
                              gs_nested(x, y + 1);
                              gs_nested(x - 1, y);
                          }
              }
          
              timestamp++;
              gs_nested(x, y);
          
              return cnt;
          }

          Comment


          • #15
            Originally posted by xpris View Post
            Well, OpenMandriva use LLVM/Clang for years with lto/pgo with good success
            I used to build my system with clang+LTO before gentoo switched to binary packages.
            That used to work for most packages, but not all. Some had issues with clang, some had issues with LTO.
            If OpenMandriva uses those features for all their packages, there must be patches in OpenMandriva which are not upstream, yet.

            Comment


            • #16
              Originally posted by George99 View Post
              clang is still missing nested functions support in C. This is a very useful feature of gcc which I use frequently. I hope they will implement it some day.

              This is an example how it works in gcc: (count the size of a group at position x,y in the game of Go)
              C should really get lambdas

              Comment


              • #17
                Originally posted by George99 View Post
                clang is still missing nested functions support in C. This is a very useful feature of gcc which I use frequently. I hope they will implement it some day.

                This is an example how it works in gcc: (count the size of a group at position x,y in the game of Go)
                Code:
                int group_size(int go_board[19][32], unsigned x, unsigned y)
                {
                int cnt = 0;
                int color = go_board[x][y];
                
                static long timestamp;
                static long ts_board[19][32];
                
                void gs_nested(unsigned x, unsigned y) {
                if (x < 19 && y < 19)
                if (go_board[x][y] == color)
                if (ts_board[x][y] != timestamp) {
                ts_board[x][y] = timestamp;
                cnt++;
                gs_nested(x, y - 1);
                gs_nested(x + 1, y);
                gs_nested(x, y + 1);
                gs_nested(x - 1, y);
                }
                }
                
                timestamp++;
                gs_nested(x, y);
                
                return cnt;
                }
                Aren't nested functions a GCC extension outside the C standard?

                Comment


                • #18
                  Originally posted by patrick1946 View Post
                  What is the C/C++ language? I thought the kernel is using C with GCC extensions.

                  People love to mix C and C++ but the languages are widely different.
                  While idiomatic code is written "widely different" the languages themselves are not and this meme is stupid.

                  Unless you're using one of a very small handful of unsupported features C code is C++ code. Whether you like it or not C is a (albeit not strict) subset of C++ and there's plenty of large codebases out there using C++ as a sort of Super C (Writing C++ as if it was idiomatic C but using C++ features such as Templates rather than macros). Sitting here pretending otherwise is just asinine regardless of your personal language preferences, GCC and Clang don't test code for idiomacy.

                  Comment


                  • #19
                    I’m glad to see this. I always prefer clang, both for my own projects, and compiling arbitrary projects. Since I’ve switched to FreeBSD I’ve never bothered installing gcc.

                    It's just my personal opinion, but I feel that gcc design choices have been politicized to the point where they shoot themselves in the foot. Example: gcc doesn’t support gnustep 2.0. Clang does. What's up with that?

                    Comment


                    • #20
                      Originally posted by xpris View Post

                      You can check it yourself without any compilation. Just use OpenMandirva. By default, the system starts with the kernel-desktop - this is the version built with Clang, and kernel-desktop-gcc is also waiting in the repository. You can install it by "sudo dnf install kernel-desktop-rc" Also RC versions are available in both versions. You can easily check the performance of both.
                      Thanks a lot! I wasn't sure if OpenMandriva provides GCC kernel. Btw. it's funny to see they're calling it GNU/Linux distribution.
                      Last edited by Volta; 05 February 2024, 12:03 PM.

                      Comment

                      Working...
                      X