Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Precompiled headers in GCC 3.4.0
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Thu Apr 22, 2004 1:16 am    Post subject: Precompiled headers in GCC 3.4.0 Reply with quote

Right, here goes.

GCC 3.4.0 is out the door. It's been released. There's even an ebuild for it in the GCC 3.4 thread. One of the major new features is precompiled headers.

In short, this means that headers don't have to be compiled every single time you use them - just the once. They're still an "experimental feature" of sorts, although they are supposed to work on the whole.

Before you start saying, "Eh? What?" this basically means that compiling headers in C++ programmes like KDE, which usually takes over 90% of compile time, only has to be done once per header (rather than once per source file). So KDE (not that I use it) would compile ten times faster, or so.

Therefore, I feel that it's probably a good idea to try and get something like this working. GCC 3.4.0 appears to be fairly stable - I've not had it die with an internal compiler error yet, and whilst there are a few packages which don't compile with GCC 3.4.0, this isn't GCC's fault - so we may as well make some sort of effort to make use of this genuinely useful feature.

So, I'm going to have a go. This is a call to arms of sorts - is there anyone who would be prepared to help? In particular, working out quite how precompiled header usage is invoked would be a good place to start.
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
LaNcom
Apprentice
Apprentice


Joined: 03 May 2003
Posts: 254
Location: Erfurt, Germany

PostPosted: Thu Apr 22, 2004 1:35 am    Post subject: Reply with quote

You mean this one?
http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Sounds great, but I think I don't know how it's supposed to work. Is it necessary to enable it? Because, right now, I don't see a speed-up compiling KDE...

Anyway, using GCC 3.4.0preBLABLA (the last pre that is in portage), recompiling KDE right now. FAM won't compile, and kdenetwork failed, too. OTOH, I use AMD64, maybe that causes the problems...
Back to top
View user's profile Send private message
Superduck
Retired Dev
Retired Dev


Joined: 17 Apr 2003
Posts: 104
Location: Denmark

PostPosted: Thu Apr 22, 2004 9:34 am    Post subject: Reply with quote

I'm going to try gcc 3.4 out very soon for testing on one of my own projects, but just a quick question first.

How much to I have to recompile when I upgrade to gcc 3.4? Can I leave the system intact and just upgrade as new packages arrive?

Another question: Has anyone tested this with nptl?

Thanx 8)
Back to top
View user's profile Send private message
()
l33t
l33t


Joined: 25 Nov 2002
Posts: 610

PostPosted: Thu Apr 22, 2004 10:05 am    Post subject: Reply with quote

You have to invoke gcc directly on the headers (as with .c/.cpp) in order to produce .gch files, which will be preferred to source headers.
_________________
to be concerned is good
Back to top
View user's profile Send private message
irf2003
Veteran
Veteran


Joined: 10 Sep 2003
Posts: 1078

PostPosted: Thu Apr 22, 2004 10:15 am    Post subject: Reply with quote

LaNcom wrote:
You mean this one?
http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Sounds great, but I think I don't know how it's supposed to work. Is it necessary to enable it? Because, right now, I don't see a speed-up compiling KDE...

Anyway, using GCC 3.4.0preBLABLA (the last pre that is in portage), recompiling KDE right now. FAM won't compile, and kdenetwork failed, too. OTOH, I use AMD64, maybe that causes the problems...

if i am not mistaken the project has to be contructed in
such a way to take advantage of precompiled headers.
i very much doubt whether the kde makefiles are
precompiled header aware, as until gcc3.4 there was no such
thing in gnuworld. i am sure that eventually when gcc3.4
becomes mainstream developers will tweak their project
files accordingly.
hence, your kde compile did not speed up.
hth
PS can you post the output of emerge -ep world, and advise
what ebuilds failed with gcc3.4, as i am currently doing
emerge -e world with gcc3.4
TIA
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Thu Apr 22, 2004 11:49 am    Post subject: Reply with quote

() wrote:
You have to invoke gcc directly on the headers (as with .c/.cpp) in order to produce .gch files, which will be preferred to source headers.


Yeah, but you have to do some trickery in passing the same options as you do when you compile the source files, or something like that. That's where I'm having difficulty. Someone made an openoffice compile script, which I can't find now, that had me compiling it in about 3 hours on a P200MMX, rather than 30 hours or so like it usually takes. So the speed-up is worth the effort...
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
()
l33t
l33t


Joined: 25 Nov 2002
Posts: 610

PostPosted: Thu Apr 22, 2004 12:46 pm    Post subject: Reply with quote

Yes, of course, its the same way as with any source code. Also, the headers have to contain all the necessary includes to be compiled by themselves, which need not always be the case :] That is, if a header is normally included with a bunch of other headers, the programmer might omit some includes in the header itself.
_________________
to be concerned is good
Back to top
View user's profile Send private message
irf2003
Veteran
Veteran


Joined: 10 Sep 2003
Posts: 1078

PostPosted: Thu Apr 22, 2004 2:18 pm    Post subject: Reply with quote

LaNcom wrote:
You mean this one?
http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Sounds great, but I think I don't know how it's supposed to work. Is it necessary to enable it? Because, right now, I don't see a speed-up compiling KDE...

Anyway, using GCC 3.4.0preBLABLA (the last pre that is in portage), recompiling KDE right now. FAM won't compile, and kdenetwork failed, too. OTOH, I use AMD64, maybe that causes the problems...

FYI just clean compiled FAM with gcc 3.4.0, my arch is
x86, must be an amd64 issue
hth
Back to top
View user's profile Send private message
LaNcom
Apprentice
Apprentice


Joined: 03 May 2003
Posts: 254
Location: Erfurt, Germany

PostPosted: Thu Apr 22, 2004 2:43 pm    Post subject: Reply with quote

Yes, it was a problem with FAM 2.6.10.
2.7.0 works, but it wasn't marked stable on AMD64.

Now I'm compiling kdenetwork 3.2.1 again, had to patch the Makefiles to disable IRC support in Kopete to make it work...
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Thu Apr 22, 2004 3:29 pm    Post subject: Reply with quote

"that had me compiling it in about 3 hours on a P200MMX, rather than 30 hours or so like it usually takes. So the speed-up is worth the effort..."

holy crap, are those numbers anywhere near correct, or is it the feel you got after compile was done? Because that's insane :)
Back to top
View user's profile Send private message
irf2003
Veteran
Veteran


Joined: 10 Sep 2003
Posts: 1078

PostPosted: Thu Apr 22, 2004 3:50 pm    Post subject: Reply with quote

robmoss2k wrote:
() wrote:
You have to invoke gcc directly on the headers (as with .c/.cpp) in order to produce .gch files, which will be preferred to source headers.


Yeah, but you have to do some trickery in passing the same options as you do when you compile the source files, or something like that. That's where I'm having difficulty. Someone made an openoffice compile script, which I can't find now, that had me compiling it in about 3 hours on a P200MMX, rather than 30 hours or so like it usually takes. So the speed-up is worth the effort...

robmoss2k, where did you get that OOo compile script, the forums?
TIA
Back to top
View user's profile Send private message
irf2003
Veteran
Veteran


Joined: 10 Sep 2003
Posts: 1078

PostPosted: Thu Apr 22, 2004 3:54 pm    Post subject: Reply with quote

neuron wrote:
"that had me compiling it in about 3 hours on a P200MMX, rather than 30 hours or so like it usually takes. So the speed-up is worth the effort..."

holy crap, are those numbers anywhere near correct, or is it the feel you got after compile was done? Because that's insane :)

yes it makes sense, think about all the header files
in a build ebuild such as say OOo, these are been included
in the various .c or .cxx or whatever files, and everytime
they are included they have to be re-parsed etc..
so pre-compiled headers do speed up the compiling
hth
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Thu Apr 22, 2004 4:41 pm    Post subject: Reply with quote

irf2003 wrote:
robmoss2k, where did you get that OOo compile script, the forums?


No - and now I can't find the damned thing either. I found it looking for something "precompiled headers" related on Google, but I can't remember what, and the computer I used it on is now switched off (it's at home, and I'm back at uni...)
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Thu Apr 22, 2004 4:42 pm    Post subject: Reply with quote

that really is awsome... and gigantic help for source based distro's everywhere ;)
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Thu Apr 22, 2004 4:49 pm    Post subject: Reply with quote

Absolutely. All we have to do now is find out how the bloody thing works! :P
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
Remenic
Tux's lil' helper
Tux's lil' helper


Joined: 10 May 2003
Posts: 76

PostPosted: Thu Apr 22, 2004 5:03 pm    Post subject: Reply with quote

Qt appears to have PCH support, but it's not working here... I have "precompile_header" in the Configuration part of ./configure, but it doesn't seem to have speed up at all :(

Quote:
Configuration ....... nocrosscompiler precompile_header minimal-config small-config medium-config large-config full-config styles tools kernel widgets dialogs iconview workspace network canvas table xml opengl sql release dll thread largefile stl ipv6 system-jpeg system-png png no-gif system-zlib nis cups bigcodecs x11sm xshape xinerama xrandr xrender xftfreetype xkb
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Thu Apr 22, 2004 6:47 pm    Post subject: Reply with quote

Oooh, sounds fun... I'll check it out later. I don't actually use QT, but I can still try compiling it ;)
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Fri Apr 23, 2004 5:31 pm    Post subject: Reply with quote

bump

anyone tried this? Would be sweet to see patches for packages like qt/kde/openoffice/mozilla*
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Fri Apr 23, 2004 6:27 pm    Post subject: Reply with quote

Not yet. But don't worry, I will!

Right now I'm in the middle of an "emerge -e world" using GCC 3.4.0. The only packages which I haven't managed to fix are app-office/openoffice-ximian-1.1.53 and media-libs/libsdl-1.2.7-r1. The former because I haven't tried yet - I assume that the patch will be nothing short of monstrous - and the latter because I don't know any assembly, or what "clobbering" is, or what the "%ebx" register is. So I'll have to leave that fix for someone else.

In the meantime, I have 119 packages left to re-merge, which is a pretty good effort considering that I have a total of 466 installed packages. I'm going to make a patch for mplayer (if it compiles - I suspect this may be the second one with which I have assembly troubles) so that it uses -mtune instead of -mcpu if gcc-3.4 is detected too before I get onto precompiled headers.

As far as I'm aware, certain packages do have precompiled headers support ready done, it just needs to be enabled. I'll run some speed tests to see what sort of speed-up I'm getting. I'm tending to see a 10% - 30% speed-up anyway with GCC 3.4.0 over 3.3.3, so I'm pretty happy already :)
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
MG-Cloud
Apprentice
Apprentice


Joined: 28 Oct 2003
Posts: 200

PostPosted: Sat Apr 24, 2004 12:45 am    Post subject: Reply with quote

GCC 3.4 sounds awesome .... I can't wait to have the time to try it out ! :D
Back to top
View user's profile Send private message
motaboy
Developer
Developer


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Sun Apr 25, 2004 11:38 am    Post subject: Reply with quote

HI to all. I've analized the configure script of the kde projects.

There's an option called --enable-pch but this check only if the compiler is the KCC then make a check to watch if it supports the --pch option.

But with gcc there isn't a --pch options or any other option to enable the precompiled header support.

I think that gcc works in another way: it ALWAYS use pch if it find them, but you have to create them compiling the .h files like a .cpp file.

So I think that the configure and the Makefiles have to be changed in a lot of parts to activate pch.

I'm a kde developer (kde-bluetooth) and I know that ALL the kde projects use the same automake-conf etc.. structure. This is the admin directory present in every kde project and that you can find on kde CVS under kde-common.

I'll take a look if there's already and implementation for this on CVS.

Bye!
_________________
...
Back to top
View user's profile Send private message
robmoss
Retired Dev
Retired Dev


Joined: 27 May 2003
Posts: 2634
Location: Jesus College, Oxford

PostPosted: Sun Apr 25, 2004 4:25 pm    Post subject: Reply with quote

Thanks very much motaboy - it would be most helpful if you could find out what support, if any, there is for GCC 3.4.0 precompiled headers with KDE.
_________________
Reality is for those who can't face Science Fiction.

emerge -U will kill your Gentoo
ecatmur, Lord of Portage Bash Scripts
Back to top
View user's profile Send private message
motaboy
Developer
Developer


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Sun Apr 25, 2004 6:37 pm    Post subject: Reply with quote

Well, FIRST LET's START from QT.

I've noticed that the QT detect the precompiled headers because with gcc 3.3.3 the detected configuration is:

Code:

Configuration .......  nocrosscompiler minimal-config small-config medium-config large-config full-config styles tools kernel widgets dialogs iconview workspace network canvas table xml opengl sql release dll largefile stl ipv6 png no-gif zlib nis cups bigcodecs x11sm xshape xinerama xcursor xrandr xrender xftfreetype xkb


while with gcc 3.4 it's:
Code:

Configuration .......  nocrosscompiler precompile_header minimal-config small-config medium-config large-config full-config styles tools kernel widgets dialogs iconview workspace network canvas table xml opengl sql release dll largefile stl ipv6 png no-gif zlib nis cups bigcodecs x11sm xshape xinerama xcursor xrandr xrender xftfreetype xkb


So now I'm compiling QT and looking if the *.h.gch file are installed in the include dir (/usr/qt/3/include ).
QT uses qmake not the standard make so I don't know well how it works.

Is there someone already emerged it with gcc 3.4 that can look in /usr/qt/3/include if there are the .gch files? Thanks!

Bye!
_________________
...
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Sun Apr 25, 2004 6:48 pm    Post subject: Reply with quote

building a livecd with gcc 3.4 atm.
usr/qt/3/include does not have any gch files.
Back to top
View user's profile Send private message
stonent
Veteran
Veteran


Joined: 07 Aug 2003
Posts: 1139
Location: Texas

PostPosted: Sun Apr 25, 2004 7:31 pm    Post subject: Reply with quote

So do you have to manually compile all the headers or can you just make it run through your include path and do it automatically?
_________________
Inspiron 4100 & Sun UltraAXe
Portage on Solaris|Dell Laptop Hacks
The way you feel about organized religion is the same way I feel about organized socialism.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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