This is an archive of the discontinued LLVM Phabricator instance.

limit to 2 parallel links when using thinlto
ClosedPublic

Authored by inglorion on Apr 12 2017, 12:53 PM.

Details

Summary

When using ThinLTO, the linker performs its own parallelism. This
change limits the number of parallel link jobs that Ninja will issue
to keep the total number of threads reasonable when linking with
ThinLTO.

Event Timeline

inglorion created this revision.Apr 12 2017, 12:53 PM

Alternatively, we could limit the parallelism of the link jobs, but limiting the number of link jobs is better, because it avoids having to wait a very long time for the last link job. For the same reason, the number of concurrent link jobs is 2 rather than 1.

cmake/modules/HandleLLVMOptions.cmake
20

This code is unchanged, but has been moved up to make uppercase_LLVM_ENABLE_LTO available when setting the number of link jobs.

inglorion planned changes to this revision.Apr 12 2017, 3:59 PM

This will emit a warning when ThinLTO is enabled and the build system is not Ninja. I'll cook up a version that inhibits that warning.

LGTM if you can avoid the warning when using something else than Ninja.

inglorion updated this revision to Diff 95179.Apr 13 2017, 11:47 AM
  • No warning when not using Ninja.
  • Simplified the change.
  • Fixed buggy behavior on Linux.

Sure, still LGTM!

cmake/modules/HandleLLVMOptions.cmake
38

I don't know if there is a more canonical way of checking for ninja?

40

I'd add a note to be displayed in the console log.

inglorion added inline comments.Apr 20 2017, 5:42 PM
cmake/modules/HandleLLVMOptions.cmake
38

This is the same check that was there before (was on line 36).

40

Something like

message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.")

?

mehdi_amini added inline comments.Apr 20 2017, 7:26 PM
cmake/modules/HandleLLVMOptions.cmake
38

Oh right.

40

Yes something like this looks good to me. Thanks!

inglorion updated this revision to Diff 96217.Apr 21 2017, 1:24 PM

added message and fixed case

This revision was automatically updated to reflect the committed changes.