Page 1 of 1
precompiled header?
Posted: Tue May 24, 2016 12:34 pm
by djcouchycouch
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
Re: precompiled header?
Posted: Tue May 24, 2016 3:05 pm
by cero
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.
Re: precompiled header?
Posted: Tue May 24, 2016 3:46 pm
by djcouchycouch
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.
Re: precompiled header?
Posted: Tue May 24, 2016 5:48 pm
by cero
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.
Re: precompiled header?
Posted: Fri May 27, 2016 2:21 am
by djcouchycouch
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.
Re: precompiled header?
Posted: Fri May 27, 2016 9:17 am
by cero
C includes barely take any time, unless you have huge arrays in your headers. It's C++ with templates where PCH is useful, mostly.
Re: precompiled header?
Posted: Sat May 28, 2016 10:54 pm
by Sik
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).
Re: precompiled header?
Posted: Sun May 29, 2016 10:44 am
by tryphon
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 ?
Re: precompiled header?
Posted: Sun May 29, 2016 7:33 pm
by cero
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
