LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-02-2013, 10:20 PM   #1
blackv1rus
Member
 
Registered: Apr 2005
Location: switzerland
Distribution: slackware
Posts: 54

Rep: Reputation: 4
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
 
Old 04-03-2013, 01:04 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
2 members found this post helpful.
Old 04-03-2013, 01:32 AM   #3
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,970

Rep: Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685
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.
 
8 members found this post helpful.
Old 04-03-2013, 04:09 AM   #4
blackv1rus
Member
 
Registered: Apr 2005
Location: switzerland
Distribution: slackware
Posts: 54

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by volkerdi View Post

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?
 
Old 04-03-2013, 04:29 AM   #5
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,970

Rep: Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685
Quote:
Originally Posted by blackv1rus View Post
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.
 
Old 04-04-2013, 05:40 PM   #6
comfree
LQ Newbie
 
Registered: Aug 2012
Location: Germany
Distribution: Slackware64-current, Slackware64 14.0
Posts: 28

Rep: Reputation: Disabled
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.
 
Old 04-04-2013, 06:07 PM   #7
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,970

Rep: Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685
Quote:
Originally Posted by comfree View Post
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.
 
Old 04-04-2013, 06:24 PM   #8
comfree
LQ Newbie
 
Registered: Aug 2012
Location: Germany
Distribution: Slackware64-current, Slackware64 14.0
Posts: 28

Rep: Reputation: Disabled
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.
 
Old 04-04-2013, 06:32 PM   #9
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,970

Rep: Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685Reputation: 9685
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.
 
Old 04-05-2013, 07:00 PM   #10
mlslk31
Member
 
Registered: Mar 2013
Location: Florida, USA
Distribution: Slackware, FreeBSD
Posts: 210

Rep: Reputation: 77
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.
 
4 members found this post helpful.
Old 04-05-2013, 09:00 PM   #11
blackv1rus
Member
 
Registered: Apr 2005
Location: switzerland
Distribution: slackware
Posts: 54

Original Poster
Rep: Reputation: 4
Thanks for good info, I will start using Clang more to get knowledge of it.
 
Old 12-25-2013, 12:38 AM   #12
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,352

Rep: Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383
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.

Last edited by dugan; 12-25-2013 at 12:48 AM.
 
Old 12-25-2013, 05:43 PM   #13
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,352

Rep: Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383Reputation: 5383
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.

Last edited by dugan; 12-25-2013 at 06:00 PM.
 
Old 12-26-2013, 04:01 AM   #14
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,564
Blog Entries: 15

Rep: Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118Reputation: 2118
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
g++ vs clang++: odd behavious miguelg Programming 4 03-30-2013 04:59 PM
Building with clang for new C++ standard tron_thomas Programming 2 03-11-2012 04:40 PM
Installation of Just Clang/LLVM Documentation? haziz Debian 1 01-08-2012 05:18 AM
Clang/LLVM Install Within Slackware? haziz Slackware 8 01-03-2012 04:46 AM
Anyone doing much with clang? MBybee Programming 2 12-18-2009 01:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration