Bug 87107 - Template instantiation is 50x slower than with clang++
Summary: Template instantiation is 50x slower than with clang++
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: compile-time-hog
Depends on:
Reported: 2018-08-26 12:45 UTC by Frédéric Bron
Modified: 2018-08-27 08:12 UTC (History)
3 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

File to reproduce the issue (2.55 KB, application/gzip)
2018-08-26 12:45 UTC, Frédéric Bron

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Bron 2018-08-26 12:45:26 UTC
Created attachment 44598 [details]
File to reproduce the issue

The new IO extension from GIL (boost 1.68.0) takes a very long time to compile with g++ 8.2.0 compared to clang++ 5 or 6. Note that this is also true with g++ 6 and 7 but not with g++ 5. I also opened an issue at boost::gil:

I was able to identify which code exactly takes so much time to compile and I was able to make it independent from any external libraries, in particular from boost (MPL and GIL). See the attached file "gcc-is-long-minimum-and-standalone.cpp".

With this particular program, g++ 8.2.0 is 53x longer than clang 6.0 on my x86_64 linux computer (8.175 s vs 0.152 s).

The command line is:
g++-8.2.0 -o out.o -c -O2 -DNDEBUG -std=c++14 Progs/gcc-is-long-minimum-and-standalone.cpp

clang++ -o out.o -c -O2 -DNDEBUG -std=c++14 Progs/gcc-is-long-minimum-and-standalone.cpp
Comment 1 Mateusz Loskot 2018-08-27 07:52:13 UTC
There was similar bug reported to GCC 8.1, fixed in 8.2

However, I'm not seeing any improvement compiling the Frédéric's sample gcc-is-long-minimum-and-standalone.cpp with GCC 8.2 on Linux.
Comment 2 Frédéric Bron 2018-08-27 07:55:09 UTC
Yes, I've seen that one and saw it was fixed before 8.2.0. I wasn't sure actually if it was included in 8.2.0 as it was solved few weeks before 8.2.0 was out.