Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compiling world with llvm-gcc.
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Need4Speed
Guru
Guru


Joined: 06 Jun 2004
Posts: 497

PostPosted: Wed Oct 28, 2009 8:17 pm    Post subject: Compiling world with llvm-gcc. Reply with quote

So I've been reading about llvm and it sounds pretty interesting. Seeing that 2.6 has been unmasked in portage, I thought I'd give it a try. I just added three lines to paludis' bashrc (portage's make.conf)
Code:

CC="/usr/bin/llvm-gcc"
CXX="/usr/bin/llvm-g++"
CPP="/usr/bin/llvm-cpp"

and things seem to be compiling ok. I'm about to recompile world with it. Has anyone done this yet? I'm a little scared. :oops:

My cflags are just "-march=native -O2 -pipe" for now. If that works I may try adding "-flto" for link time optimization, but that requires the gold plugin which didn't work so well last time I tried it. Has anyone tried the clang front-end? It sounds like that might not work without modifying most ebuilds..
_________________
2.6.34-rc3 on x86_64 w/ paludis
WM: ratpoison
Term: urxvt, zsh
Browser: uzbl
Email: mutt, offlineimap
IRC: weechat
News: newsbeuter
PDF: apvlv
Back to top
View user's profile Send private message
MalleRIM
Guru
Guru


Joined: 23 Jul 2007
Posts: 563
Location: China

PostPosted: Thu Oct 29, 2009 9:26 am    Post subject: Reply with quote

same for me - will you tell me, whether you had success or not? :lol:
Back to top
View user's profile Send private message
Need4Speed
Guru
Guru


Joined: 06 Jun 2004
Posts: 497

PostPosted: Thu Oct 29, 2009 4:18 pm    Post subject: Reply with quote

MalleRIM wrote:
same for me - will you tell me, whether you had success or not? :lol:

I have run into a couple packages that won't compile. Two of them being glibc and mplayer, which fail because of an unsupported inline assembly bit. I'll file some bug reports regarding these issues after I do some more searching to make sure they aren't already known.
The good news is that so far everything that has compiled, which is most packages, has worked perfectly. I haven't come across any runtime errors.
_________________
2.6.34-rc3 on x86_64 w/ paludis
WM: ratpoison
Term: urxvt, zsh
Browser: uzbl
Email: mutt, offlineimap
IRC: weechat
News: newsbeuter
PDF: apvlv
Back to top
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 6108
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Thu Oct 29, 2009 4:27 pm    Post subject: Reply with quote

good news !

seems it's progressing with big steps now :D

Quote:
but that requires the gold plugin which didn't work so well last time I tried it.


so you have gold-support compiled in / activated and it worked except those 2 packages ?



source: http://llvm.org/docs/GoldPlugin.html
_________________
https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Back to top
View user's profile Send private message
Need4Speed
Guru
Guru


Joined: 06 Jun 2004
Posts: 497

PostPosted: Thu Oct 29, 2009 4:41 pm    Post subject: Reply with quote

kernelOfTruth wrote:

so you have gold-support compiled in / activated and it worked except those 2 packages ?


No, I haven't tried gold with llvm since I'm not using link time optimization yet. I also haven't compiled everything in world yet. I've so far come across two more packages that won't compile: rtorrent and strace. But strace has an easy fix, just change the unrecognized "bool" type to an "int" and it compiles. I'm not sure "bool" is even supposed to be used in standard C; I thought it was just C++.
_________________
2.6.34-rc3 on x86_64 w/ paludis
WM: ratpoison
Term: urxvt, zsh
Browser: uzbl
Email: mutt, offlineimap
IRC: weechat
News: newsbeuter
PDF: apvlv
Back to top
View user's profile Send private message
sera
Retired Dev
Retired Dev


Joined: 29 Feb 2008
Posts: 1017
Location: CET

PostPosted: Thu Oct 29, 2009 5:08 pm    Post subject: Reply with quote

Yes, there is no built in boolean type in ANSI C but C99 has one.
Back to top
View user's profile Send private message
tranquilcool
Veteran
Veteran


Joined: 25 Mar 2005
Posts: 1159

PostPosted: Sat Oct 31, 2009 6:53 am    Post subject: Reply with quote

lots of compilation failures and some stuff compile but seg. fault.
_________________
this is a strange strange world.
Back to top
View user's profile Send private message
cruzki123
Apprentice
Apprentice


Joined: 16 May 2008
Posts: 248

PostPosted: Sat Oct 31, 2009 11:15 am    Post subject: Reply with quote

Can you post how you compile llvm. I tried two days ago and cant compile llvm-gcc (said that the two version didn't mach at the end of stage 2 I suppose)

I used gcc-4.4.2
Back to top
View user's profile Send private message
tranquilcool
Veteran
Veteran


Joined: 25 Mar 2005
Posts: 1159

PostPosted: Sat Oct 31, 2009 11:58 am    Post subject: Reply with quote

cruzki123 wrote:
Can you post how you compile llvm. I tried two days ago and cant compile llvm-gcc (said that the two version didn't mach at the end of stage 2 I suppose)

I used gcc-4.4.2


2.6 in portage.
emerge llvm llvm-gcc
_________________
this is a strange strange world.
Back to top
View user's profile Send private message
Need4Speed
Guru
Guru


Joined: 06 Jun 2004
Posts: 497

PostPosted: Sat Oct 31, 2009 1:33 pm    Post subject: Reply with quote

Yeah, I've ran into quite a few problems too. After filing a few bug reports and reading through them, it seems that the developers are focusing a lot more on clang than llvm-gcc. A number of a bugs, such as the glibc compile problem, have already been fixed in clang, but not in llvm-gcc.

I tried setting CC="/usr/bin/clang", which worked better than llvm-gcc for some things, but there are still too many problems for it to be really usable. Also with clang I ran into some problems with configure scripts not liking my compiler's version number.
_________________
2.6.34-rc3 on x86_64 w/ paludis
WM: ratpoison
Term: urxvt, zsh
Browser: uzbl
Email: mutt, offlineimap
IRC: weechat
News: newsbeuter
PDF: apvlv
Back to top
View user's profile Send private message
cruzki123
Apprentice
Apprentice


Joined: 16 May 2008
Posts: 248

PostPosted: Sat Oct 31, 2009 8:54 pm    Post subject: Reply with quote

Thansk for the responce.

I will try to compile clang. I am not interested in recompiled worl but some programas I wrote.

In other topic, there is any guide to use the new toolchain. I mean: gold, llvm and the new optimización of gcc
Back to top
View user's profile Send private message
dreadlorde
Apprentice
Apprentice


Joined: 16 Dec 2008
Posts: 243
Location: /adm/timezone/US_Michigan

PostPosted: Sun Nov 01, 2009 11:27 pm    Post subject: Reply with quote

I did this a couple of months ago in a funtoo chroot. It was a bare bones system, but most of the packages I installed (all text based) worked. Subversion kept seg faulting though. I'll have to try this out again once I fix my clang ebuild.
_________________
Ludwig von Mises Institute
Quote:
I am not to be a shepherd, I am not to be a grave-digger. No longer will I speak to the people; for the last time I have spoken to the dead.
Back to top
View user's profile Send private message
MalleRIM
Guru
Guru


Joined: 23 Jul 2007
Posts: 563
Location: China

PostPosted: Sat Nov 28, 2009 11:39 am    Post subject: Reply with quote

You might also want to set
F77="/usr/bin/llvm-gfortran"
in /etc/make.conf to use llvm to compile fortran, too.
Back to top
View user's profile Send private message
MalleRIM
Guru
Guru


Joined: 23 Jul 2007
Posts: 563
Location: China

PostPosted: Wed Dec 02, 2009 10:15 am    Post subject: Reply with quote

Need4Speed wrote:
...such as the glibc compile problem, have already been fixed in clang, but not in llvm-gcc.

Would you tell me how to compile glibc with clang? For me, the configure script already fails.
Back to top
View user's profile Send private message
Need4Speed
Guru
Guru


Joined: 06 Jun 2004
Posts: 497

PostPosted: Wed Dec 02, 2009 10:29 am    Post subject: Reply with quote

MalleRIM wrote:
Need4Speed wrote:
...such as the glibc compile problem, have already been fixed in clang, but not in llvm-gcc.

Would you tell me how to compile glibc with clang? For me, the configure script already fails.

I've haven't built it myself, but according to the developers the actual compile should work with clang. The configure script just fails when it checks for gcc's version. I am not very familiar with build systems, but I think that a simple patch to accept the use of clang as the compiler should work.
_________________
2.6.34-rc3 on x86_64 w/ paludis
WM: ratpoison
Term: urxvt, zsh
Browser: uzbl
Email: mutt, offlineimap
IRC: weechat
News: newsbeuter
PDF: apvlv
Back to top
View user's profile Send private message
ScytheMan
l33t
l33t


Joined: 30 Nov 2005
Posts: 605

PostPosted: Mon Oct 18, 2010 10:30 pm    Post subject: Reply with quote

10 months later, can somebody tell me how is it working?

does it improve speed? memory usage when compiling? :)
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 517

PostPosted: Thu Dec 09, 2010 10:41 am    Post subject: Reply with quote

I'm interested in knowing this aswell. Any news?
Back to top
View user's profile Send private message
ComaWhite
Tux's lil' helper
Tux's lil' helper


Joined: 07 Oct 2008
Posts: 125

PostPosted: Fri Dec 10, 2010 1:40 am    Post subject: Reply with quote

try using clang :D
Back to top
View user's profile Send private message
Lucipher
Tux's lil' helper
Tux's lil' helper


Joined: 11 Feb 2007
Posts: 78

PostPosted: Thu Jan 27, 2011 5:44 am    Post subject: Reply with quote

I'm having troubles with glibc too. How did you guys worked around or fixed the following error with glibc:

Code:
checking whether autoconf works... yes
configure: error:
*** These critical programs are missing or too old: gcc
*** Check the INSTALL file for required versions.


I'm using clang as C compiler. I tried to compile with llvm=gcc but got another error. I wonder if you guys can help me here?

Thanks
Back to top
View user's profile Send private message
Shining Arcanine
Veteran
Veteran


Joined: 24 Sep 2009
Posts: 1110

PostPosted: Thu Jan 27, 2011 8:34 am    Post subject: Reply with quote

Lucipher wrote:
I'm having troubles with glibc too. How did you guys worked around or fixed the following error with glibc:

Code:
checking whether autoconf works... yes
configure: error:
*** These critical programs are missing or too old: gcc
*** Check the INSTALL file for required versions.


I'm using clang as C compiler. I tried to compile with llvm=gcc but got another error. I wonder if you guys can help me here?

Thanks


They used GCC to compile glibc.
Back to top
View user's profile Send private message
asturm
Developer
Developer


Joined: 05 Apr 2007
Posts: 6944
Location: Austria

PostPosted: Thu Jan 27, 2011 9:06 am    Post subject: Reply with quote

Somewhere here in US there must be a bigger thread about llvm lurking around, if I remember correctly.
_________________
backend.cpp:92:2: warning: #warning TODO - this error message is about as useful as a cooling unit in the arctic
Back to top
View user's profile Send private message
the8lack8ox
n00b
n00b


Joined: 03 Feb 2009
Posts: 29
Location: Cleveland, OH, USA

PostPosted: Mon May 21, 2012 1:54 am    Post subject: Reply with quote

Today, I started working on rebuilding my system--as much as possible--with clang using LTO. For all you Paludis users out there, I've written a bashrc for Paludis which makes selection of toolchain more convenient:
Code:
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j9"

CFLAGS="-march=bdver1 -pipe -O2"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,--as-needed"

if grep -Fxq "${CATEGORY}/${PN}-${PV}" /etc/paludis/gcc-build ; then
        echo "==> Compiling with GCC <=="
elif grep -Fxq "${CATEGORY}/${PN}-${PV}" /etc/paludis/dragonegg-build ; then
        echo "==> Compiling with DragonEgg <=="
        CFLAGS="${CFLAGS} -fplugin=/usr/lib64/llvm/dragonegg.so"
        CXXFLAGS="${CXXFLAGS} -fplugin=/usr/lib64/llvm/dragonegg.so"
elif grep -Fxq "${CATEGORY}/${PN}-${PV}" /etc/paludis/sane-build ; then
        echo "==> Compiling with sane optimizations <=="
        CC="clang"
        CXX="clang++"
elif grep -Fxq "${CATEGORY}/${PN}-${PV}" /etc/paludis/insane-build ; then
        echo "==> Compiling with insane optimizations <=="
        CC="clang -O4"
        CXX="clang++ -O4"
        RANLIB=":"

        CFLAGS="${CFLAGS} -O4"
        CXXFLAGS="${CXXFLAGS} -O4"
        LDFLAGS="${LDFLAGS} -O4"
else
        echo "==> Compiling with normal optimizations <=="
        CC="clang -flto"
        CXX="clang++ -flto"
        RANLIB=":"

        CFLAGS="${CFLAGS} -flto"
        CXXFLAGS="${CXXFLAGS} -flto"
        LDFLAGS="${LDFLAGS} -O2 -flto"
fi

Now I can put packages in /etc/paludis/gcc-build or /etc/paludis/dragonegg-build or /etc/paludis/sane-build or /etc/paludis/insane-build to select which toolchain/optimizations I want.

I ran into trouble getting some packages to load the LLVMgold.so plugin into ar/nm. You'll get more packages to compile if you use the "autoloading" feature of binutils instead of the clang-ar script layed out in the wiki. You can do it like this:
Code:
# mkdir /usr/lib64/bfd-plugins
# cd /usr/lib64/bfd-plugins
# ln -s ../llvm/LLVMgold.so /usr/lib64/bfd-plugins
# ln -s ../llvm/libLTO.so /usr/lib64/bfd-plugins
# ln -s ../llvm/libLLVM-3.1.so /usr/lib64/bfd-plugins
# ln -s /usr/lib64/bfd-plugins /usr/x86_64-pc-linux-gnu/lib
# ln -s /usr/x86_64-pc-linux-gnu/lib /usr/x86_64-pc-linux-gnu/binutils-bin/lib

Unfortunately, binutils only searchs $install_dir/../lib/bfd-plugins for its plugins necessitating an awkward symlink in /usr/x86_64-pc-linux-gnu/binutils-bin.

I'll probably pitch in at the wiki once I get my machine nice and working again. :wink:

EDIT: Improved organization of bashrc and made it less insane, plus other minor touchups.


Last edited by the8lack8ox on Fri May 25, 2012 9:43 am; edited 1 time in total
Back to top
View user's profile Send private message
SeeksTheMoon
Apprentice
Apprentice


Joined: 24 Sep 2003
Posts: 163

PostPosted: Thu May 24, 2012 10:04 am    Post subject: Reply with quote

Thanks for the information, the8lack8ox. I updated http://en.gentoo-wiki.com/wiki/Llvm, now that llvm 3.1 and clang 3.1 are out and in portage.
I was able to compile texinfo with your symlinks, which was not possible with the ar wrapper script for clang+lto before.
screen and gpsd still don't link with lto though, I suggest we provide a list of packages that are not compatible with lto or need gcc (like virtualbox, glibc, firefox) in a wiki.
Back to top
View user's profile Send private message
the8lack8ox
n00b
n00b


Joined: 03 Feb 2009
Posts: 29
Location: Cleveland, OH, USA

PostPosted: Fri May 25, 2012 6:14 am    Post subject: Reply with quote

I'm working right now toward building an entire system as much as possible with clang. However, it seems that in my never ending pursuit for speed, I have messed it up pretty good by using -O4 for nearly everything. I'll post more on what packages can be compiled with what later when I can use something other than a cell phone. :wink: For now, just let me say that libtool is really annoying. When you use it to link a shared library, it strips certain flags.This includes your -O4 and -fto flags. To work around this, set
Code:
CC="clang -O4"
CXX="clang++ -O4"

That way libtool won't strip it, and you'll be able to link LTO objects. But! Keep it in CFLAGS too so your flag doesn't get overridden in the compile stage.

HTH

- The 8lack 8ox
Back to top
View user's profile Send private message
SeeksTheMoon
Apprentice
Apprentice


Joined: 24 Sep 2003
Posts: 163

PostPosted: Fri May 25, 2012 9:38 am    Post subject: Reply with quote

I tried to compile screen with CC=clang -O4 and cflags -O4, but this time instead of stopping with a linker error it seems to be stuck in an endless loop in the linking process, eating 100% CPU for several minutes now. I guess it is better not to try to compile everything with -O4 but to stick with -O2 and use -O4 only for special programs where every slight performance gain counts.

Here is my list of exceptions so far:
# fallback from clang -O4 to clang -O2:
app-misc/screen
sci-geosciences/gpsd
media-gfx/gimp
net-misc/openssh
sys-power/apcupsd
sys-libs/libutempter
# for libre-office-bin:
sci-libs/ufconfig
dev-db/unixODBC
dev-libs/hyphen
app-text/libwpd
app-text/libwpg

# fallback from clang -O2 to gcc:
www-client/firefox
app-emulation/virtualbox
sys-libs/glibc (sure, glibc is very GNUish, I bet that gcc also won't compile with clang)
net-print/cups (llvm and cups are apple sponsored... a shame ^^)
sys-devel/llvm (like clang below)
sys-devel/clang (seriously?? It was self hosting once, but it complains about a missing cxxabi.h)
x11-libs/qt-core (trouble with pch, should compile though)
net-p2p/ktorrent (not libktorrent though)

Several basic daemons work with -O4, like postfix, vixie-cron, rdate, mdadm, acpid, also coreutils. This makes sense, because the smaller and "easier" a program is and the less GNU-like it is, the more compatible it is for several unices (e.g. BSD), the better the clang support.
Maybe it is a good idea to fetch the FreeBSD packet list, intersect with the packages in portage -> these programs should work with clang -O2 and maybe with -O4.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum