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

Linking is really slow with Ninja CMake generator, but not Unix Makefiles #5223

Open
3 tasks done
chillenb opened this issue Jul 3, 2024 · 0 comments
Open
3 tasks done
Labels
triage New bug, unverified

Comments

@chillenb
Copy link

chillenb commented Jul 3, 2024

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.13.1

Problem description

When building a large pybind11 module with GCC+CMake+Ninja, I find that the linking step is serial and takes forever. When the Makefiles generator is specified, linking (LTO) uses all available cpus, and linking is much faster.

environment: Conda-forge, linux x64

GCC 12.3.0
CMake 3.30.0
GNU Make 4.4.1
Ninja 1.12.1

The problem seems related to the fact that Ninja does not support the GNU Make jobserver protocol. Therefore, the -flto flag does serial LTO with Ninja and parallel LTO with Make. You need to explicitly set -flto=auto or -flto=n when you use Ninja for reasonable link times.

It might be a good idea to change set(thin "") to set(thin "=auto") here:

set(thin "")

Clang supports -flto=auto too (with Clang, it means the same as -flto).

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

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

No branches or pull requests

1 participant