LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   GCC vs LLVM (https://www.linuxquestions.org/questions/slackware-14/gcc-vs-llvm-931034/)

mlpa 02-24-2012 07:11 AM

GCC vs LLVM
 
I saw this news in Phoronix.

I have tried to understand which is better.
I have always used GCC, is there a significant reason to change?

bosth 02-24-2012 10:25 AM

Not a Slackware question. There are programming forums.

knudfl 02-24-2012 02:44 PM

http://llvm.org/

1) There's a llvm/clang Slackbuild ( Version 2.9 )
http://slackbuilds.org/result/?search=llvm&sv=13.37
LLVM 3.0 : http://llvm.org/releases/download.html#svn
Clang http://clang.llvm.org/

2) Gcc will compile "everything".
LLVM can compile some (the most?) applications / libraries.
Why not try out llvm / clang, to know ?
( export CC=clang CXX=clang++ && <other-command> ).

Alien Bob 02-24-2012 02:45 PM

This is not a programming question per sé.

You could also see it as a philosophical question - everybody grew up with GCC - what will a move to LLVM bring to Linux distributions? I have no doubt that Redhat considers a move away from GCC.

This is just one step in a trend to abandon the platform-agnostic tools of old and push Linux into a direction which will separate it from it's UNIX cousins. Some would call it "refreshment of Linux" but mainly this is a push to get the Linux desktop into a state where it will be commercially exploitable. The big distro vendors are not concerning themselves with compatibility issues - look at how we, Slackware, must struggle to keep our own distro sane.

Their ulterior motive is simply: to earn more money. And **** the hippies.

Eric

mlpa 02-24-2012 03:02 PM

Quote:

Originally Posted by bosth (Post 4611086)
Not a Slackware question. There are programming forums.

I am not trying to do a programming questions, or looking to change my compiler.

I am only trying to understand, from the point of view from Linux Distro Maintainers is there any major step in using LLVM?
Based on Phonorix Apple use it and Fedora is considering.

After so many time with GCC, and from several post that I read, many program use specific GCC Macros and options, what is the force to change?
And as a Linux user, is this change for the better or worse?

mlpa 02-24-2012 03:04 PM

Quote:

Originally Posted by knudfl (Post 4611253)
http://llvm.org/

1) There's a llvm/clang Slackbuild ( Version 2.9 )
http://slackbuilds.org/result/?search=llvm&sv=13.37
LLVM 3.0 : http://llvm.org/releases/download.html#svn
Clang http://clang.llvm.org/

2) Gcc will compile "everything".
LLVM can compile some (the most?) applications / libraries.
Why not try out llvm / clang, to know ?
( export CC=clang CXX=clang++ && <other-command> ).

Thanks for the info.
Maybe if i have time I can write a simple code in C and compile with GCC and CLANG and see the differences.
Namely compilation time, execution time and try different optimizations :D

a4z 02-25-2012 04:16 AM

that llvm hypes currently several comanies have several motivations to use it as 'their' compiler is on thing

the advantage of llvm/clang is its modular design, so it can be interfaced and used for example to create static code analysis tools, what becomes more and more important

and competition is good, even for gcc

beside that, it is great to use more than one compiler, especially in so exiting times where the new c++11 stuff comes into the compilers
for C++ this is a big win, compaired to the situation of the last years


for me it is realy exiting to see how various tools and compilers work with each other and how they continue brining new features, and I currently use gcc/clang++ and msvc10 to compile my code.

also, there is no real a vs b situation for me , cause my code has to work with all 3 compilers, or 2 for the linux only parts

fgcl2k 02-27-2012 02:27 AM

Quote:

Originally Posted by Alien Bob (Post 4611254)
This is just one step in a trend to abandon the platform-agnostic tools of old and push Linux into a direction which will separate it from it's UNIX cousins.

Why do you think that the move to LLVM is a step to separate Linux from its UNIX cousins? The BSDs, for example, are already contemplating to replace gcc, although for licence reasons.
Quote:

Originally Posted by Alien Bob (Post 4611254)
Some would call it "refreshment of Linux" but mainly this is a push to get the Linux desktop into a state where it will be commercially exploitable. The big distro vendors are not concerning themselves with compatibility issues - look at how we, Slackware, must struggle to keep our own distro sane.

I completely agree with your analysis about the direction that Linux development is taking.

the3dfxdude 02-29-2012 11:09 AM

Some people may not know this, but gcc has been replaced before. At least by a fork of itself.

http://en.wikipedia.org/wiki/GNU_Com...tion#EGCS_fork

Maybe this is not as drastic as moving to a new compiler code base, but this could shed light why LLVM is getting new attention. Many times, forks or replacements are written, not so much for technical reasons, but control of the code base. (Don't get me wrong, the project leads may make technical decisions different than their competing project, to "improve" things)

So EGCS is an example of developers not happy of the management of GCC, going out on their own, and eventually being the leader. This led back to remerging the code bases under the new leadership (or at least being called the defacto GCC). So GCC is one big happy family again right?

LLVM could prove to be successful that it becomes a standard, but I will wait and see. I do have it installed for my Mesa driver.

Not every competing faction succeeds. Take again Red Hat and GCC, which produced the ill-fated GCC 2.96 (an unofficial fork of GCC 2.95). Unfortunately it was popular among some commercial vendors using Red Hat, and I've finally just got off a vendor produced program myself which required those C++ libs by just finally rewriting a new program for my company in the last 6 months.

Martinus2u 02-29-2012 12:23 PM

Quote:

Originally Posted by Alien Bob (Post 4611254)
You could also see it as a philosophical question - everybody grew up with GCC - what will a move to LLVM bring to Linux distributions?

I grew up with Pure C (formerly Turbo C) on m68k hardware which compiled 20 times faster than GCC and produced similarly well optimised code (since then optimisation has improved no doubt). I believe the speed difference between CLANG and GCC is similar. That alone makes it worth it.

Alien Bob 02-29-2012 12:26 PM

Martinus2u ... you also wrote software on Atari? How funny, I did this too.
I must have my Pure C floppies still, somewhere, but I only run Atari emulators these days, having done away with the 1040ST and the TT long ago.

Eric

Martinus2u 02-29-2012 02:34 PM

Quote:

Originally Posted by Alien Bob (Post 4615252)
Martinus2u ... you also wrote software on Atari? How funny, I did this too.
I must have my Pure C floppies still, somewhere, but I only run Atari emulators these days, having done away with the 1040ST and the TT long ago.

Eric

hehe, yes, i wrote mostly small utilities, that sometimes got me a few bucks from computer magazines. :) I had one of the first mega ST with a whooping 4 MB. Later I upgraded to 68020 and 68030 cpus which means I had to go heavily into hardware design. :D I also contributed to linux 68k. There is still one occurrence of my old e-mail adress left in the vanilla kernel to this day. :D

but all that is history now. I sometimes play with vice, the c 64 emulator. :D

mlpa 03-06-2012 08:26 AM

As it seems Debian are also thinking in trying out LLVM compiler, here.

haziz 03-18-2012 03:34 PM

LLVM/Clang: It's Great for Students!
 
I don't know how it would fit for distribution maintainers; it is attractive to companies trying to make money since it's "BSD" stye license (U. of Chicago license I think) is probably easier to use for financial gain than the GPL though many companies have proved you could profit with GPLed software. Probably why Apple is pushing it in favor of GCC.

I am a student currently studying C and Unix systems programming and I must say that for me Clang has been a godsend and that is mainly because it's warning and error messages are infinitely easier to understand than those of GCC. It also will usually accurately highlight and literally "point to" your errors. I just find it much more user friendly. I am using it from the CLI in a GNU/linux box, so this is not due to a particular implementation in an IDE.

ReaperX7 03-20-2012 12:05 AM

The only thing I've ever used LLVM for was to compile Mesa to support 3D acceleration for various video cards using Gallium3D.

It's just another compiler for another purpose. GCC is and will always be the defacto open source compiler not just for Linux but for many open source projects.

ozanbaba 03-20-2012 12:56 AM

Quote:

Originally Posted by Martinus2u (Post 4615249)
I grew up with Pure C (formerly Turbo C) on m68k hardware which compiled 20 times faster than GCC and produced similarly well optimized code (since then optimization has improved no doubt). I believe the speed difference between CLANG and GCC is similar. That alone makes it worth it.

I did not noticed much speed difference when compiling things like Wine etc. It sure compiles Carbon fast but then there's real world.
Check out a nice detailed benchmark here.

a4z 03-20-2012 01:14 PM

that's why llvm is also good for gcc

http://gcc.gnu.org/ml/gcc/2012-03/msg00256.html

http://gcc.gnu.org/ml/gcc/2012-03/msg00263.html

mlpa 05-14-2012 05:16 AM

Free BSD 10 To Use Clang Compiler, Deprecate GCC, link.
Maybe there is some important advantage of LLVM on top of GCC.

TobiSGD 05-14-2012 05:49 AM

Quote:

Originally Posted by mlpa (Post 4677871)
Free BSD 10 To Use Clang Compiler, Deprecate GCC, link.
Maybe there is some important advantage of LLVM on top of GCC.

Yes, there is. LLVM/Clang is licensed with a BSD license and the BSD people want to become GNU-free.

mlpa 05-14-2012 09:04 AM

From what I read in the Phoronix forum the bitcode compiled by clang is 5-15% slower than the same code compiled with GCC without optimizations.

Clang is not a mature yet.

leeeoooooo 05-18-2012 09:50 PM

I'm delighted that LLVM was included with the new X updates in current. I've been watching this project for several years wondering if it would ever come into more general acceptance.

"GCC vs LLVM"??? I don't get it. To me they are very different tools. Yes, LLVM has a compiler--so does Perl.

To me, the compiler in LLVM has more in common with the Perl compiler than with GCC.

The LLVM compiler targets the Low Level Virtual Machine, just as the Perl compiler targets the Perl runtime. The only differences I see are that the LLVM compiler compiles C and the Perl compiler compiles Perl, and the LLVM operates more closely to the hardware than the Perl runtime does.

GCC directly targets a variety of hardware. LLVM targets a VM layer that can make compiled code more portable.

Apples and Oranges in my book.

rg3 05-19-2012 02:48 AM

Sorry, but that's far from being accurate at all. GCC has front-ends to different languages, and backends to multiple architectures. When the frontends run, they translate the code to an intermediate language or virtual machine, if you prefer, like RTL. GCC and LLVM, in that sense, work very similarly. Of course, internally they're very different, but just not in that concept.

http://en.wikipedia.org/wiki/Interme...uage#Languages
http://en.wikipedia.org/wiki/Register_Transfer_Language

Martinus2u 05-19-2012 02:56 AM

also, for historic reasons and for different optimization steps gcc employes a variety of internal representations of the code. of course, this doesn't help performance very much.

leeeoooooo 05-19-2012 05:35 AM

Quote:

Originally Posted by rg3 (Post 4682435)
Sorry, but that's far from being accurate at all. GCC has front-ends to different languages, and backends to multiple architectures. When the frontends run, they translate the code to an intermediate language or virtual machine, if you prefer, like RTL. GCC and LLVM, in that sense, work very similarly. Of course, internally they're very different, but just not in that concept.

http://en.wikipedia.org/wiki/Interme...uage#Languages
http://en.wikipedia.org/wiki/Register_Transfer_Language

Yes but...

How GCC works internally isn't the point. The output is raw machine code. LLVM's compiler outputs bytecode to run on top of the LLVM, rather like the .Net languages which can't run without .Net

LLVM just has a much lower level of abstraction and so, can run much faster.

GazL 05-19-2012 06:01 AM

Quote:

Originally Posted by leeeoooooo (Post 4682521)
Yes but...

How GCC works internally isn't the point. The output is raw machine code. LLVM's compiler outputs bytecode to run on top of the LLVM, rather like the .Net languages which can't run without .Net

Code:

gazl@darkstar:/tmp$ cat >clang-test.c     
#include <stdio.h>
int main( int argc, char ** argv )
{
  printf("I'll be damned!\n");
  return 0;
}

gazl@darkstar:/tmp$ clang -o doesitwork clang-test.c
gazl@darkstar:/tmp$ ./doesitwork
I'll be damned!
gazl@darkstar:/tmp$ su -l root -c "removepkg llvm >/dev/null 2>&1 && echo llvm removed."
Password:
llvm removed.
gazl@darkstar:/tmp$ ./doesitwork
I'll be damned!
gazl@darkstar:/tmp$



All times are GMT -5. The time now is 12:47 PM.