Catch2: Too slow link in MinGW-w64

Created on 1 Mar 2018  路  11Comments  路  Source: catchorg/Catch2

Description

I'm suffer from too slow link in MinGW-w64 environment.

Steps to reproduce

I used very simple main.cpp:

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

And, here's the result:

image

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.

Extra information

  • Catch version: v2.1.2
  • Operating System: Widows 10, MinGW-w64, 64bit
  • Compiler+version: GCC 7.3.0

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

All 11 comments

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).

Example

  1. Compiling a trivial main.cpp. Build finished in 772ms

  2. Compiling main.cpp with catch.hpp:

    #define CATCH_CONFIG_MAIN
    #include "../Catch2/single_include/catch.hpp"

Build finished in 2m 32s 812ms (!!!)

  1. Adding a simple test.cpp:
#include "../Catch2/single_include/catch.hpp"
TEST_CASE( "Simple math", "" ) {
    REQUIRE( 2 + 2 == 4);
}

Build finished in 2m 4s 211ms (!!!)

  1. Modifying test.cpp:
    Build finished in 2m 0s 729ms

Most of the time is spent on linking.

Configuration

  • Catch: v2.2.1
  • OS: Widows 10, MinGW-w64, 64bit
  • MinGW: mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1
  • Clion: CLion 2017.3.4 Build #CL-173.4674.29
  • Compiler+version: GCC 7.2.0

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

offa picture offa  路  7Comments

pwinston picture pwinston  路  5Comments

emil-e picture emil-e  路  8Comments

horenmar picture horenmar  路  7Comments

eloff picture eloff  路  7Comments