Skip to content

Conversation

biodranik
Copy link

@biodranik biodranik commented Mar 29, 2025

Updated to the latest official cmake release: https://cmake.org/cmake/help/latest/release/4.1.html

A side note: release notes do not mention UNITY_BUILD_RELOCATABLE target property introduced in 4.0.
It fixes the remote ccache hit rate when unity builds are enabled. Both unity builds and ccache are greatly speeding up C/C++/ObjC/Cuda builds when enabled.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label Mar 29, 2025
@biodranik biodranik force-pushed the cmake-4.0.0 branch 2 times, most recently from 7b85cb0 to 944e793 Compare March 29, 2025 22:19
@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Mar 29, 2025
@nix-owners nix-owners bot requested review from LnL7 and ttuegel March 29, 2025 22:19
@MisileLab
Copy link
Contributor

MisileLab commented Mar 30, 2025

Base branch should be staging because it involves many rebuilds.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: vim Advanced text editor 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: stdenv Standard environment 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: R R is a programming language for statistical computing and data visualization. 6.topic: lib The Nixpkgs function library 6.topic: games Gaming on NixOS 6.topic: rocm ROCm is an Advanced Micro Devices software stack for graphics processing unit programming. 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 8.has: documentation This PR adds or changes documentation labels Mar 30, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 17, 2025
@biodranik biodranik changed the title cmake: 3.31.6 -> 4.0.1 cmake: 3.31.6 -> 4.0.2 May 18, 2025
@biodranik
Copy link
Author

Thanks, updated to 4.0.2

@biodranik biodranik changed the title cmake: 3.31.6 -> 4.0.2 cmake: 3.31.7 -> 4.0.2 May 18, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label May 18, 2025
@LordGrimmauld LordGrimmauld removed the 2.status: wait for branch‐off Waiting for the next Nixpkgs branch‐off label May 18, 2025
@jys1670 jys1670 mentioned this pull request Jun 1, 2025
13 tasks
@MisileLab
Copy link
Contributor

again, 4.0.3 released: https://cmake.org/cmake/help/latest/release/4.0.html#id3 (I guess no api change)

@biodranik biodranik changed the title cmake: 3.31.7 -> 4.0.2 cmake: 3.31.7 -> 4.0.3 Jun 13, 2025
@jys1670
Copy link

jys1670 commented Jul 1, 2025

Since CMake 4 is not really backward compatible with older versions and there are far too many breakages because of that, can we go with introducing a separate cmake_4?
Aside from speeding up builds, it finally has support for import std; with GCC.

@biodranik
Copy link
Author

there are far too many breakages because of that

How to discover these breakages and count them? Pushing upstream or nix maintainers to fix it looks like a better long-term strategy.

it finally has support for import std; with GCC.

Does it work reliably? The MR references some issues, like this one.

@jys1670
Copy link

jys1670 commented Jul 1, 2025

How to discover these breakages and count them? Pushing upstream or nix maintainers to fix it looks like a better long-term strategy.

I guess it's about evaluating one of these jobsets locally (with cmake changes applied) and comparing the number of failures to see how many more appeared. It's very resource-intensive... It might be possible to get some help with evaluation. I remember vcunat creating separate smaller jobsets for some PRs. It's worth asking around in nixos matrix.

Does it work reliably? The MR references some issues, like this one.

I have tried compiling a test project (something like this) on Arch, and it worked. Perhaps it was some packaging issue.

@LordGrimmauld
Copy link
Contributor

I wouldn't be against introducing a cmake_3 to pin stuff that can't be upgraded, but the default should be 4.x. Both to stay up to date and to actually find (and count) the unfixed stuff.
Finding breaks would basically be either running this PR in a hydra jobset, or yoloing it and fixing during staging cycle. Either way it'd involve hydra.

@biodranik
Copy link
Author

For most packages, fixing will be super-easy, like in this commit: 89514c4

The build errors I discovered and fixed in this MR on CI are only the tip of the iceberg, right? So… How to discover more/all build errors with it? :)

@emilazy
Copy link
Member

emilazy commented Jul 2, 2025

FWIW this is still on the radar and has been discussed recently in the Staging room on Matrix. Sorry for the radio silence here, it’s just a matter of people having limited time to devote to this stuff right now and Hydra being busy. This kind of update is one of the trickier ones to land without gumming up our processes entirely.

I think we’re agreed that the correct way forward is to set up a Hydra jobset with the bump and the long‐problematic fixCmakeFiles hook removed and work on triaging the regressions before sending this to staging. IIRC, the immediate blocker there is that CMake itself fails to build without fixCmakeFiles and nobody yet put the effort into figuring out why. If you felt like putting energy into dropping the hook and figuring out how to get CMake itself to build in this PR, it’d probably reduce the inertia of getting the jobset set up, but otherwise hopefully someone will have the time for it soon. If you felt like joining us on Matrix to help with a triage effort then it would be a great help too, but you’ve already done a lot of work here so don’t feel obligated.

BTW, I think -DCMAKE_POLICY_VERSION_MINIMUM=3.5 is still deprecated/produces warnings. Gentoo (among probably others) has been working on this transition and is setting 3.10, which I believe is the lowest that CMake haven’t indicated intent to deprecate. We should probably follow suit to avoid doing all of this again any time soon (though hopefully we won’t need xcbuild for too much longer now that Swift Build exists).

The toml11 bump probably still breaks the build of Nix itself and pinging on that issue hasn’t produced results so far. But we can deal with that problem later; it shouldn’t be a blocker for the jobset.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 26, 2025
- Cygwin patch does not apply anymore, it was done for a very old cmake 3.2.2
- FindCurl patch has already been merged:
  https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9900
The fix is required for cmake 4+ to fix this build error:
> Compatibility with CMake < 3.5 has been removed from CMake.

As xcbuild repo is archived, there is no any other way to fix it upstream.
Upgrade to the latest toml11 version to fix cmake 4.0 build error:
> Compatibility with CMake < 3.5 has been removed from CMake.

toml11 v3.8.1 declares minimum required cmake 3.5 but fails to build due to
a required CMAKE_CXX_STANDARD check:
ToruNiina/toml11@d4eb5f3#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR18
- Update cmake to the latest 4.1.0 release:
  https://cmake.org/cmake/help/latest/release/4.1.html
- Fix previous patches for a newer source code
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Aug 13, 2025
@biodranik biodranik changed the title cmake: 3.31.7 -> 4.0.3 cmake: 3.31.7 -> 4.1.0 Aug 13, 2025
@emilazy
Copy link
Member

emilazy commented Aug 13, 2025

Some progress on the Nix blocker: NixOS/nix#13741

@MisileLab
Copy link
Contributor

https://cmake.org/cmake/help/latest/release/4.1.html#id1 released

@emilazy
Copy link
Member

emilazy commented Sep 9, 2025

Finally working on testing this in earnest. I have a bump to 4.1.1 locally and fixes for Darwin, which currently fails to build completely. I’m also dropping the hook. @biodranik Do you mind me force‐pushing to your branch, or should I open a new PR?

@biodranik
Copy link
Author

@emilazy please force-push. I'm curious about the new changes though ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: documentation This PR adds or changes documentation 8.has: package (update) This PR updates a package to a newer version 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants