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

Set CMAKE_BUILD_PARALLEL_LEVEL environment variable. #18558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhull
Copy link

@dhull dhull commented Oct 13, 2024

cmake builds previously did not respect HOMEBREW_MAKE_JOBS. This change fixes that.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

…ariable.

`cmake` builds previously did not respect `HOMEBREW_MAKE_JOBS`.  This
change fixes that.
Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks OK.

Though not entirely sure what scenario this would have applied given cmake already respects MAKEFLAGS which we set? Do you have a reproducer?

@cho-m
Copy link
Member

cho-m commented Oct 16, 2024

Need to update deparallelize too.

As far as I can tell:

  • Unix Makefiles should use MAKEFLAGS already so shouldn't be impacted
  • Ninja defaults to all CPUs. We have a ninja shim but cmake --build does not use it. So setting CMAKE_BUILD_PARALLEL_LEVEL will help, but mainly for reducing the parallelization (i.e. setting a lower HOMEBREW_MAKE_JOBS or getting it working with ENV.deparallelize)
  • Should allow controlling parallelization for other generators like Xcode. We don't use them in Homebrew/core but maybe 3rd party taps do.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update ENV.deparallelize too (as mentioned by @cho-m).

Marking as request changes just to ensure it's not merged by mistake before that.

@cho-m cho-m removed their request for review October 16, 2024 15:03
@dhull
Copy link
Author

dhull commented Oct 18, 2024

Though not entirely sure what scenario this would have applied given cmake already respects MAKEFLAGS which we set? Do you have a reproducer?

Yes.

I have a old Mac running MacOS Big Sur 11.7.10 (the latest version of the OS supported on this Mac) so homebrew needs to compile packages when I install them. My Mac has 8 cores and 16 GB RAM and some of the builds occasionally fails because they run out of memory, with 8 cmake jobs running. I tried setting CMAKE_BUILD_PARALLEL_LEVEL in my environment but discovered that brew cleared it and so it had no effect. I then tried setting HOMEBREW_MAKE_JOBS and found 8 cmake jobs still ran. Finally I made this change and then the number of cmake jobs was limited by HOMEBREW_MAKE_JOBS.

@carlocab
Copy link
Member

We have a ninja shim but cmake --build does not use it.

Kinda weird that it doesn't, since cmake --build will happily take any ninja in PATH outside of brew.

@cho-m
Copy link
Member

cho-m commented Oct 18, 2024

Kinda weird that it doesn't, since cmake --build will happily take any ninja in PATH outside of brew.

CMake uses find_program so some locations take precedence over PATH like:

def determine_cmake_prefix_path
PATH.new(
keg_only_deps.map(&:opt_prefix),
HOMEBREW_PREFIX.to_s,

Copy link

github-actions bot commented Nov 9, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale No recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants