LinuxQuestions.org
Register a domain and help support LQ
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, 09: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, 12:04 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
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, 12:32 AM   #3
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 867

Rep: Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750
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, 03: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, 03:29 AM   #5
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 867

Rep: Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750
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, 04:40 PM   #6
comfree
LQ Newbie
 
Registered: Aug 2012
Location: Germany
Distribution: Slackware64-current, Slackware64 14.0
Posts: 27

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, 05:07 PM   #7
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 867

Rep: Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750
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, 05:24 PM   #8
comfree
LQ Newbie
 
Registered: Aug 2012
Location: Germany
Distribution: Slackware64-current, Slackware64 14.0
Posts: 27

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, 05:32 PM   #9
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 867

Rep: Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750Reputation: 1750
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, 06:00 PM   #10
mlslk31
Member
 
Registered: Mar 2013
Location: Florida, USA
Distribution: Slackware, FreeBSD
Posts: 109

Rep: Reputation: 30
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, 08: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-24-2013, 11:38 PM   #12
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,676

Rep: Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440
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-24-2013 at 11:48 PM.
 
Old 12-25-2013, 04:43 PM   #13
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,676

Rep: Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440
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 05:00 PM.
 
Old 12-26-2013, 03:01 AM   #14
ReaperX7
Senior Member
 
Registered: Jul 2011
Distribution: LFS-SVN, FreeBSD 10.0
Posts: 3,197
Blog Entries: 15

Rep: Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828
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 03:59 PM
Building with clang for new C++ standard tron_thomas Programming 2 03-11-2012 03:40 PM
Installation of Just Clang/LLVM Documentation? haziz Debian 1 01-08-2012 04:18 AM
Clang/LLVM Install Within Slackware? haziz Slackware 8 01-03-2012 03:46 AM
Anyone doing much with clang? MBybee Programming 2 12-18-2009 12:43 PM


All times are GMT -5. The time now is 07:02 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration