Building a profiled, optimized ioQ3 with gcc should be easier (see details below). As it is, there is no profile target, and overriding LDFLAGS on the make command-line is problematic (-ldl and -lm have to be explicitly provided).
Also, after Step 2, not all source files have corresponding '.gcda' files like they do for '.gcno'. In fact, most of them don't, even if I load maps, play online, etc (I'm setting fs_basepath from the build/release-linux-x86_64 folder). As a result, they're compiled with no branch info taken into account. Am I missing something?
Step 1: Build non-optimized for '.gcno'
OPTIMIZE="-O0 -fno-guess-branch-probability -fprofile-generate"
LDFLAGS+="-fprofile-generate"
Step 2: Build optimized for '.gcda'
make clean
OPTIMIZE="[k8, O3, fast math] -fno-guess-branch-probability -fprofile-arcs"
Remove "-fprofile-generate" from LDFLAGS, add "-fprofile-arcs"
Run the resulting binary to generate .gcda files
Step 3: Build final optimized binary
make clean
OPTIMIZE="[above opts] -fno-guess-branch-probability -fprofile-use"
Remove "-fprofile-arcs" from LDFLAGS, add "-fprofile-use"
Haha, no; I've never used Gentoo. I simply happened to notice that idQ3 1.32c is rather well-optimized, and that it feels more responsive (has lower latency) than the typical ioQ3 build does with some Q3 mods. I'm simply trying to reproduce that feel, because it DOES make a big difference while playing.
Besides, according to the gcc manpage, -funroll-loops is one of the "optimizations generally profitable only with profile feedback available." Which makes me wonder why it's a default optimization, since it certainly does seem detrimental in some cases without that.
> [-funroll-loops] does seem detrimental in some cases without [profile feedback].
Or maybe using an overly-optimized OpenAL isn't such a great idea. Oops.
Anyways, regarding profiling:
In order to generate all of the arcs feedback files, I have to attach to ioQ3 with gdb and call __gcov_flush() (an idea found here: http://www.nabble.com/-fprofile-arcs-and-gcov:-data-without-exit()-t396370.html). Shouldn't the game exit cleanly so that this won't be necessary?
Also, I'm trying to compile & link with the -pg flag so that I can profile with gprof (this may help to track down the Intel -march=i686+ problem). That works fine, but once again, the file that is supposed to be generated, gmon.out, is missing. I'm not sure what function to call here, either.
Okay, using exit() instead of _exit() in Sys_Exit solves the problem; gmon.out is now generated. I experience no problems with the usage of exit() on my system, FWIW. o_O
> Am I missing something? Nevermind; I figured it out. Still, it'd be nice if profiling were easier. :)