I'm suffer from too slow link in MinGW-w64 environment.
I used very simple main.cpp:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
And, here's the result:

Well, it takes about 8 seconds to compile the file here, which is totally acceptable considering big header file.
The problem is that it takes another approximately 9 seconds again to create executable with already compiled object file.
As you can see, the link time is even longer than compile time.
This is very annoying because I have to wait 9 seconds at least whenever building executable even though the object file is not changed.
In fact, my actual test project requires me to wait about 1 minute to be linked.
How can I improve link performance, here?
Any suggestion would be nice.
Thank you.
Hi,
I have a similar problem. I am using Catch under CLion.
Linking time w/ Catch is extremely long (>2 mins for a trivial test).
Compiling a trivial main.cpp. Build finished in 772ms
Compiling main.cpp with catch.hpp:
#define CATCH_CONFIG_MAIN
#include "../Catch2/single_include/catch.hpp"
Build finished in 2m 32s 812ms (!!!)
test.cpp:#include "../Catch2/single_include/catch.hpp"
TEST_CASE( "Simple math", "" ) {
REQUIRE( 2 + 2 == 4);
}
Build finished in 2m 4s 211ms (!!!)
test.cpp:Most of the time is spent on linking.
We have had some issue with link times before, but that was caused by LTO builds.
For non-lto builds, there is not much we can do except concluding that MinGW link times are awful.
OK. Thanks a lot.
mingw-w64 in version 7.2 and 7.3 LTO is completely broken. Also, the link times are horrible without LTO, to the point of it not being usable. I have to wait 4 minutes for it to link, compared to under MSVC++ the same projects links in less than 20 seconds.
The only reasonable for me to use mingw and catch2 is to create a shared library and compile the whole subtree from here https://github.com/catchorg/Catch2/tree/master/include (not a single header file because it's awfully slow). Tests compile and run within milisecond
Any resolution on this issue?
Not that I am aware of. Hopefully soon, as we're about to move back to Visual Studio.
I have same problem on MSYS2.
The only reasonable for me to use mingw and catch2 is to create a shared library and compile the whole subtree from here https://github.com/catchorg/Catch2/tree/master/include (not a single header file because it's awfully slow). Tests compile and run within milisecond
@nano-bot Hi, How to compile catch2 shared library?
@nano-bot How'd you go about compiling your shared library?
On a side-note, can we push that shared library to Conan? It'll make consumption a whole lot easier rather than having to build it ourselves.
I am a random guy who was searching for a solution to improve the horrible link time in Mingw. I successfully improve it vastly by using the lld linker -fuse-ld=lld in my own project. I know nothing about this project so it may or may not work.
Most helpful comment
The only reasonable for me to use mingw and catch2 is to create a shared library and compile the whole subtree from here https://github.com/catchorg/Catch2/tree/master/include (not a single header file because it's awfully slow). Tests compile and run within milisecond