This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40379] New: Extremely long compiling time of gcc optimization mode


I've got some cpp files that take extremely long time to compile with gcc-4.2.3
in the optimization mode. For example, one of them takes 102 minutes elapsed
time. This is the command line I used (I've removed -I -D -MMD -MT -MF and -MP
options).

$ /usr/bin/time g++ -m32 -xc++ -c -fPIC -pipe -fpermissive -w -fuse-cxa-atexit
-march=athlon64 -mfpmath=sse -O2 <source_file> -o <object_file>
5936.75user 2.94system 1:42:47elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (2major+440942minor)pagefaults 0swaps

If I remove the "-O2" option, the compilation takes less than 11 seconds. It
looks like that the optimization stage is spending very long time. I've tried
to modify my source code, and one change has made the difference. There are
many functions in several anonymous namespace in the cpp file. If I name those
namespace to make them non-anonymouse. The compilation time is reduced to about
4 minutes. It seems to me that gcc is spending a lot of time inlining those
functions, presumably because those function are called only once. 

I would like to know whether there are some gcc options to avoid this lengthy
optimization time without changing the source code or disabling the -O2 option
altogether. I tried to compile with -fno-unit-at-a-time and
-fno-inline-functions-called-once, but they do not seem to affect the compiling
time.

The system I am using is Red Hat Enterprise Linux AS release 4 (Nahant Update
4) on x86_64 processor. I compiled gcc 4.2.3 myself with the following config:

$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.2.3/configure --prefix=/home/share/gcc-4.2.3
--enable-__cxa_atexit --enable-languages=c,c++ --enable-multilib
Thread model: posix
gcc version 4.2.3


-- 
           Summary: Extremely long compiling time of gcc optimization mode
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qingning dot huo at barcap dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40379


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]