Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too slow link in MinGW-w64 #1205

Closed
bylee20 opened this issue Mar 1, 2018 · 14 comments
Closed

Too slow link in MinGW-w64 #1205

bylee20 opened this issue Mar 1, 2018 · 14 comments

Comments

@bylee20
Copy link

bylee20 commented Mar 1, 2018

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
@alexander-titov
Copy link

alexander-titov commented Mar 19, 2018

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

@horenmar
Copy link
Member

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.

@bylee20
Copy link
Author

bylee20 commented Apr 5, 2018

OK. Thanks a lot.

@ghost
Copy link

ghost commented May 21, 2018

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.

Luthaf pushed a commit to Luthaf/chemfiles that referenced this issue Jul 26, 2018
Luthaf pushed a commit to Luthaf/chemfiles that referenced this issue Jul 26, 2018
@nano-bot
Copy link

nano-bot commented Feb 2, 2019

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

@snahmad
Copy link

snahmad commented May 18, 2019

Any resolution on this issue?

@ghost
Copy link

ghost commented May 18, 2019

Not that I am aware of. Hopefully soon, as we're about to move back to Visual Studio.

@maobaoqi
Copy link

I have same problem on MSYS2.

@maobaoqi
Copy link

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?

@shreyasbharath
Copy link

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

@Adriankhl
Copy link

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.

horenmar added a commit that referenced this issue Oct 20, 2019
Unless someone steps up to fix the long link times with a set of
unobtrusive changes, the recommended solution will remain "use a better
linker".

Related to #1205, #1247, and #1637

Closes #1247
Closes #1637
@ylliu
Copy link

ylliu commented Jun 21, 2021

where to set

-fuse-ld=lld

?

@dortamiguel
Copy link

@Adriankhl where do you set the -fuse-ld=lld ?

@Adriankhl
Copy link

@ellipticaldoor It is a compiler flag for gcc: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Therefore, it depends on how your project is built. For plane gcc, here is an example (https://stackoverflow.com/questions/29361801/is-the-lld-linker-a-drop-in-replacement-for-ld-and-gold). Mostly likely, you are working with a build system like cmake, then you have to figure it out how to specify the flag for the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants