LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Clang on Slackware, anyone? (http://www.linuxquestions.org/questions/slackware-14/clang-on-slackware-anyone-4175456618/)

blackv1rus 04-02-2013 09:20 PM

Clang on Slackware, anyone?
 
I heard about Clang could replace GCC, I was thinking about installing it on my Slackware to have a try, but before, I would like to know if someone here already used it , if yes what are the ups and downs.



for those curious read here about it:

http://en.wikipedia.org/wiki/Clang

TobiSGD 04-03-2013 12:04 AM

Clang is part of a standard install of my 14.0 and -current system, it comes with the llvm package. So you can just try it.

volkerdi 04-03-2013 12:32 AM

Pretty easy to give it a try. For most SlackBuilds that use a configure script, you can just add a couple lines to the start:

Code:

CC=clang \
CXX=clang++ \
CFLAGS="$SLKCFLAGS" \
./configure \

The majority of the things I've tried compile fine. I even added those CC and CXX definitions in the export statement at the end of KDE.options, and all but of few of the KDE packages compiled. Those that did, worked.

blackv1rus 04-03-2013 03:09 AM

Quote:

Originally Posted by volkerdi (Post 4924035)

The majority of the things I've tried compile fine. I even added those CC and CXX definitions in the export statement at the end of KDE.options, and all but of few of the KDE packages compiled. Those that did, worked.

Many thanks. This will help me a lot, didn't know it was so simple. Will it replace GCC on Slackware too?

volkerdi 04-03-2013 03:29 AM

Quote:

Originally Posted by blackv1rus (Post 4924110)
Many thanks. This will help me a lot, didn't know it was so simple. Will it replace GCC on Slackware too?

Upstream packages are free to prefer whichever compiler they want. Right now llvm/clang and icu4c will prefer clang if it's available.

There's no plan to try to force it into place.

comfree 04-04-2013 04:40 PM

Clang will replace the GCC in FreeBSD in the future, but I never heard that it will replace the GCC in GNU/Linux or Slackware.
I think Clang is not able to build the Linux kernel right now, but it's able to build the FreeBSD kernel and most of the ports.

volkerdi 04-04-2013 05:07 PM

Quote:

Originally Posted by comfree (Post 4925278)
Clang will replace the GCC in FreeBSD in the future, but I never heard that it will replace the GCC in GNU/Linux or Slackware.
I think Clang is not able to build the Linux kernel right now, but it's able to build the FreeBSD kernel and most of the ports.

To build the Linux kernel, Clang needs a few patches. I hear these will be in the next release. Also, the kernel needs a few patches. Once a vanilla Clang is otherwise able to compile the kernel, I expect these changes will end up in the kernel sources. There's a lot of interest in making this possible... certainly it will be interesting to keep an eye on this.

comfree 04-04-2013 05:24 PM

Yes, it's really interesting and it's good to have an alternative. Isn't clang mainly developed by the BSD community? No offense here. ;)
I used it a couple times on FreeBSD 9.1 and I was really impressed how good it was already working. Is there any advantage over the GCC right now?
I red about some speed and size improvements on the compiled binaries and that clang should become the standart compiler in FreeBSD 10.0, but that was some time ago.

volkerdi 04-04-2013 05:32 PM

I haven't done any benchmarks with the compiled code. I did notice that llvm/clang compiled with clang was significantly smaller, but that most of the KDE packages grew in size. I've also been made aware that the clang compiler no longer works on the Pentium-III since it was recompiled with clang, and it looks to be an issue with the assembler. I need to set up an emulated Pentium-III environment to do some testing, but I believe recompiling with clang using the GNU assembler will fix the issue.

mlslk31 04-05-2013 06:00 PM

The upside to using LLVM/Clang have to do with a) giving GCC some competition and b) giving different/better error reporting than GCC. Clang seems to be a nice C compiler that can compile a lot of open-source C programs. For now, the memory usage of Clang is not the miserable mess that gcc can be a times. LLVM/Clang is distributed under a BSD-style license, and that's part of the reason that FreeBSD uses it. Apple seems to like it because it can work on Objective-C without relying on GCC, but how that propagates to C/C++ is something I don't know.

The downside is in the programs that Clang can't compile, and that happens quite a bit on the C++ side. The results of doing, say, a Clang build of Xfce on top of a gcc-built GTK+ might not go very well. LLVM/Clang and GCC are simply targeting different parts of the C++ standards for improvement. Additionally, almost all of the open-source programs meant to be compiled on Linux were meant to be compiled using GCC. Whether such a program compiles using Clang depends on a) the upstream maintainer caring whether his/her program builds with Clang, b) that the program was written with portability in mind, and/or c) sheer luck that Clang chose to support the same quirks that GCC did.

LLVM/Clang is compelling on FreeBSD and can do a full `make world`, which would be the loose equivalent of taking the source code to the Slackware a, ap, d, and k disk sets, with parts of l and n thrown in there; then building all of it at once. I think that GCC is deprecated at this point for doing such a build. But keep in mind that the FreeBSD folks want to keep GPLv3 out of this world, and most of the GNU programs in the FreeBSD base are the last versions for which they were GPLv2 or lower. In particular, this means that GCC is 4.2.0 in FreeBSD, and that was a long time ago. They have plenty of incentive to make sure that Clang works on FreeBSD before GCC 4.2.0 becomes too obsolete to compile cutting-edge programs.

As for Linux in general, though, getting everything to work with Clang should be done on a case-by-case basis. Try it, though! For the C programs at least, a program should either build or not build. I haven't seen a case where a C program will build without errors under Clang and then do the wrong thing, but you still might watch for such cases.

blackv1rus 04-05-2013 08:00 PM

Thanks for good info, I will start using Clang more to get knowledge of it.

dugan 12-24-2013 11:38 PM

I just set up a Slackware 14.1 VM with CC set to clang and CXX set to clang++. So far, I've rebuilt vim (for X and Ruby support) and Freetype (for subpixel and cleartype rendering), as well as installed Wine and some other programs from SlackBuilds.org. No probems so far.

dugan 12-25-2013 04:43 PM

x264 from SBo didn't build with CLang. Building x264 with gcc and then building FFMPEG against it, with clang, didn't seem to be a problem.

Then I tried to build mpd against FFMPEG, with clang, and it failed. So I built it with gcc.

As most things build with clang and those that don't can be built with gcc on a case-by-case basis, I'm going to leave clang as my default compilers.

ReaperX7 12-26-2013 03:01 AM

LLVM/Clang will probably end up replacing a majority of GCC's usage, but it won't replace it for everything outright. It still needs a deal of work, and GCC is still being developed as well, so realistically both will probably be in heavy and equal usage for a while to come.


All times are GMT -5. The time now is 09:08 PM.