precompiled header?

SGDK only sub forum

Moderator: Stef

Post Reply
djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

precompiled header?

Post by djcouchycouch » Tue May 24, 2016 12:34 pm

Hello!

I've been wracking my brain trying to get precompiled headers to work when building an SGDK project but it doesn't seem to be making any difference in compilation time. My makefile-fu is pretty weak so I don't really know what I'm doing :)

Code: Select all


pre.h.gch : pre.h
	$(CC) -c pre.h -o pre.h.gch $(FLAGS)	
	
$(SRC_C) : pre.h.gch
$(SRC_C) : FLAGS += -include pre.h	

Any ideas?

Thanks!
djcc

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: precompiled header?

Post by cero » Tue May 24, 2016 3:05 pm

What version of gcc? I doubt the old gcc 3 in the Windows binaries can make much use of precompiled headers.

Also, what are you doing if C compile time is slow? The SGDK headers are so limited precompiling them won't make much of a difference. All of my sgdk projects compile in less than a second from start to finish, including the resources, and they use -O3 with gcc 4.8.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: precompiled header?

Post by djcouchycouch » Tue May 24, 2016 3:46 pm

cero wrote:What version of gcc? I doubt the old gcc 3 in the Windows binaries can make much use of precompiled headers.

Also, what are you doing if C compile time is slow? The SGDK headers are so limited precompiling them won't make much of a difference. All of my sgdk projects compile in less than a second from start to finish, including the resources, and they use -O3 with gcc 4.8.

3.4.something. It does generate a precompiled header and it seems it's being used but doesn't seem to make much of a difference.

I've got about 200 files to compile. Less than half are auto-generated from resources. From clean, it takes me about two and a half minutes, the majority of the time spent during compilation. I should take a look at trimming #include use.

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: precompiled header?

Post by cero » Tue May 24, 2016 5:48 pm

2.5min for a C project? That's pretty scary, I can build ffmpeg in less than a minute, and that's over a million lines of C. Assuming you're not doing a single-threaded build on a 20 year old Celeron, something's not right.

I assume you can't post the code? I'd first see if particular files are slower than others, and where the compiler spends its time in general, but if you're on Windows I can't give advice on how to do it.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: precompiled header?

Post by djcouchycouch » Fri May 27, 2016 2:21 am

Turns out I was creating the same set of a dozen folders every time a file was getting compiled. Yikes! Moved that to a separate pre-build step. Got the clean compilation down to about a minute. Still a bit too long, but I am #including files willy nilly.

Couldn't get precompiled headers to work. Maybe I'l fight with that again another year.

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: precompiled header?

Post by cero » Fri May 27, 2016 9:17 am

C includes barely take any time, unless you have huge arrays in your headers. It's C++ with templates where PCH is useful, mostly.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: precompiled header?

Post by Sik » Sat May 28, 2016 10:54 pm

Yeah, headers are a drag only in C++, in C they don't really affect the speed (invoking GCC many times has a much bigger impact, saying this as somebody who trimmed from a minute down to less than five seconds by reducing the amount of files to compile... albeit this was done for different reasons).
Sik is pronounced as "seek", not as "sick".

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: precompiled header?

Post by tryphon » Sun May 29, 2016 10:44 am

I have the same problem : compilation time is an issue because I have many files to compile, but I want to keep my files separated. Is there a way to speed things up ?

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: precompiled header?

Post by cero » Sun May 29, 2016 7:33 pm

Perhaps you can post your project? Slow compilation could have a hundred reasons, it's unlikely yours will be similar to another's.

Of course my #1 suggestion is to use gcc from post-flood times ;)

Post Reply