clang multi-threaded compiling

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

clang multi-threaded compiling

Dimitry Andric via cfe-dev
Hi,

I am working on a C++ project using Eclipse IDE.
When I edit some code, and then go to debug it, it takes time to compile the one .cpp file I was editing, and then link it, and then the debugger starts.
I have a 16 CPU Cores PC, but I have noticed for the use case:
"one compile then one link"
It is only using 1 CPU Core.
It is therefore slow to cycle between edit code, and debug it.
How do I get clang to use more than one core when compiling a single .cpp file?
How do I get clang to use more than one core when linking?

Essentially, any way to speed up the "one compile then one link" use case would help me.

The build tool is "ninja", so a way for ninja to use clang in this way would help.

Kind Regards

James




_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang multi-threaded compiling

Dimitry Andric via cfe-dev
What build system are ou using? Ninja is built for parallel builds, and even with makefiles you can use -j X where X is the number of cores to parallize it.

in my expierence, the most expensive parts of compiling Clang is linking and running dysmutil for the debug symbols.

> On Apr 2, 2021, at 3:48 AM, James Courtier-Dutton via cfe-dev <[hidden email]> wrote:
>
> Hi,
>
> I am working on a C++ project using Eclipse IDE.
> When I edit some code, and then go to debug it, it takes time to compile the one .cpp file I was editing, and then link it, and then the debugger starts.
> I have a 16 CPU Cores PC, but I have noticed for the use case:
> "one compile then one link"
> It is only using 1 CPU Core.
> It is therefore slow to cycle between edit code, and debug it.
> How do I get clang to use more than one core when compiling a single .cpp file?
> How do I get clang to use more than one core when linking?
>
> Essentially, any way to speed up the "one compile then one link" use case would help me.
>
> The build tool is "ninja", so a way for ninja to use clang in this way would help.
>
> Kind Regards
>
> James
>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang multi-threaded compiling

Dimitry Andric via cfe-dev
In reply to this post by Dimitry Andric via cfe-dev

Hello James,

 

The compiler is not multi-threaded when you build a single file. There was a long thread on the subject last year: https://lists.llvm.org/pipermail/llvm-dev/2020-March/139606.html

But it’s not something trivial to achieve.

 

The LLD linker however is multithreaded in part. Are you running on Windows or Linux?

If Windows, you can do:

 

$ clang-cl /c -gcodeview-ghash file.cpp

$ lld-link /DEBUG:GHASH file.obj …

 

..to reduce build times a bit. With LLD 12.0 the linker will be faster when using these flags.

 

You can also try disabling optimizations with /Od to save some time in the compiler.

Precompiled headers or modules will certainly help as well when iterating: https://clang.llvm.org/docs/PCHInternals.html

 

Best,

Alex.

 

De : cfe-dev <[hidden email]> De la part de James Courtier-Dutton via cfe-dev
Envoyé : April 2, 2021 6:48 AM
À : [hidden email] Developers <[hidden email]>
Objet : [cfe-dev] clang multi-threaded compiling

 

Hi,

 

I am working on a C++ project using Eclipse IDE.

When I edit some code, and then go to debug it, it takes time to compile the one .cpp file I was editing, and then link it, and then the debugger starts.

I have a 16 CPU Cores PC, but I have noticed for the use case:

"one compile then one link"

It is only using 1 CPU Core.

It is therefore slow to cycle between edit code, and debug it.

How do I get clang to use more than one core when compiling a single .cpp file?

How do I get clang to use more than one core when linking?

 

Essentially, any way to speed up the "one compile then one link" use case would help me.

 

The build tool is "ninja", so a way for ninja to use clang in this way would help.

 

Kind Regards

 

James

 

 

 


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev