Skip to content

pkgs/development/compilers/llvm: add replacement entrypoint using mak…#436350

Closed
RossComputerGuy wants to merge 2 commits intoNixOS:masterfrom
RossComputerGuy:feat/better-llvm
Closed

pkgs/development/compilers/llvm: add replacement entrypoint using mak…#436350
RossComputerGuy wants to merge 2 commits intoNixOS:masterfrom
RossComputerGuy:feat/better-llvm

Conversation

@RossComputerGuy
Copy link
Member

…eScopeWithSplicing'

Things done

To test:

Edit pkgs/top-level/all-packages.nix, find the callPackage for pkgs/development/compilers/llvm. Add in useNG = true and test eval on llvmPackages_*.

Plan:

  1. Merge this
  2. Wait for staging
  3. Swap out default-ng.nix into default.nix
  4. Create a PR to staging if evals explode

I believe it's likely this could cause a world rebuild since I did remove a bunch of extraBuildCommands stuff to make it easier to maintain.

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Aug 24, 2025
@alyssais
Copy link
Member

Why do we need two implementations of this at the same time?

@RossComputerGuy
Copy link
Member Author

I believe it's likely this could cause a world rebuild since I did remove a bunch of extraBuildCommands stuff to make it easier to maintain.

@alyssais
Copy link
Member

Then let's have a world rebuild?

@RossComputerGuy
Copy link
Member Author

Then let's have a world rebuild?

Done

@RossComputerGuy RossComputerGuy force-pushed the feat/better-llvm branch 2 times, most recently from 46b5746 to 3a5d89d Compare September 1, 2025 03:01
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 6.topic: stdenv Standard environment and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 1, 2025
@nix-owners nix-owners bot requested review from emilazy, reckenrode and toonn September 1, 2025 03:07
@LunNova

This comment was marked as resolved.

@nixpkgs-ci nixpkgs-ci bot removed the 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. label Sep 1, 2025
@RossComputerGuy
Copy link
Member Author

Ok, I've done some cleaning up on the ordering and it should be closer to a readable diff. It falls apart when it gets to where libraries was removed but not much I can do there.

@emilazy
Copy link
Member

emilazy commented Sep 1, 2025

I would really like to see this down to 0 rebuilds. For a PR like this, every rebuild is a regression that we need to figure out. Even if the refactor uncovers previously‐incorrect behaviour or things that can be improved, it’s better to do those separately so that we can demonstrate that we can achieve the same behaviour through nicer mechanism without affecting the jobset (and avoid expensive rebuilds, in the case of ROCm). Can it not be minimized just by adjusting the overrides in the ROCm tree?

Definite +1 for using a proper scope here in general though.

@RossComputerGuy
Copy link
Member Author

Can it not be minimized just by adjusting the overrides in the ROCm tree?

It cannot as there's something with splicing going on because of how overrides change. The version attribute was different between the host or target, not entirely sure but that's what nix-diff was hinting at. I tried overriding it but ended up getting it to work in 1 way or another but not both to prevent rebuilds.

@emilazy
Copy link
Member

emilazy commented Sep 1, 2025

Is splicing involved here? My understanding was that ROCm doesn’t use the Nixpkgs cross functionality at all, so splicing should have no effect.

Comment on lines +65 to +68
# Needs "libcxx/utils/merge_archives.py"
+ lib.optionalString (lib.versions.major release_version == "13") ''
cp -r ${monorepoSrc}/libcxx "$out"
''
Copy link
Member

Choose a reason for hiding this comment

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

Was this previously being injected by override or something? I’m not seeing it in this PR.

I’m dropping LLVM 12–17 this week, so I don’t think we need to spend time fixing existing issues with LLVM 13 (and it goes against making this zero rebuilds).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, that's what confused me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, now I know what it is. llvmPackages.compiler-rt.src was literally the entire Git repo shoved in and not this special one we generate here.

@RossComputerGuy
Copy link
Member Author

Is splicing involved here?

I think it's something that makeeScopeWithSplicing' changes when you override something which ROCm uses. But I'm not sure, it doesn't explain why before some derivations had the ROCm LLVM version and some had the standard LLVM 18 version. Now, all derivations have the ROCm LLVM version.

@emilazy
Copy link
Member

emilazy commented Sep 5, 2025

#440273 will solve the LLVM 12 and 13 rebuilds, at least. The eval comparison currently shows this PR as removing llvmPackages_19, which seems… weird?

As far as ROCm goes, it seems like the two options would be to change its overrides in this PR to produce the same result (e.g. maybe overriding buildPackages/targetPackages with the vanilla package set would do it?), or to change it before this PR to do the override in a way that produces the result it gets here. Maybe @LunNova has opinions here on what the better option would be. We can of course follow up by adjusting ROCm to do whatever makes the most sense afterwards, but it shouldn’t be too hard to get the rebuilds down to 0 here, and it’s important for validating that changes like this aren’t causing regressions.

@LunNova
Copy link
Member

LunNova commented Sep 6, 2025

Applying the extra commit in #440697 gets rid of the rocmPackages rebuild. If that seems like an acceptable way to unblock this it works for me. I can follow up with a rocmPackages rebuilding PR that drops the bug-for-bug rebuild avoidance.

@emilazy
Copy link
Member

emilazy commented Sep 7, 2025

The big whitespace diff makes it hard to tell; is it just overriding the inputs so that the overrides only happen at the top level? If so it seems reasonable to me.

@LunNova
Copy link
Member

LunNova commented Sep 8, 2025

The big whitespace diff makes it hard to tell; is it just overriding the inputs so that the overrides only happen at the top level? If so it seems reasonable to me.

I've split it into two parts to make it easier to view and attempted to minimize the number of touched lines.

  • use overrideScope 5f06b99683a29192d0213b051b4181be443bb5b1
    • clang-unwrapped: continue to filter out and reapply patch instead of dropping now that the scope issues are fixed, note this should be removed shortly
    • compiler-rt-libc: pass incorrect libllvm to compiler-rt-libc to avoid rebuilding
  • nix fmt 1071572b1387d175753d516d1f3bbf2945ad3838

If it's possible to structure this so nixfmt doesn't want to indent everything further and avoid the reformat commit that would be nice, I couldn't figure it out.

@emilazy
Copy link
Member

emilazy commented Sep 8, 2025

Yeah, that looks good to me, and adding it to this PR seems like a good fix.

I’m curious why you need the builtins.toString – does this somehow make postPatch become null sometimes or something?

I have no idea why nixfmt wants to split the function on another line. It seems to only happen because there’s two parameters? A very silly thing you could do would be overrideLlvmPackagesRocm = f: llvmPackagesRocm.overrideScope (final: prev: f { inherit final prev; }); and then overrideLlvmPackagesRocm (scope: … scope.final … scope.prev …). But actually, I think squashing these two commits shouldn’t be too bad, because you can choose “ignore whitespace” and it should give more or less the same result. Still, it’s unfortunate for git blame and so on. cc @NixOS/nix-formatting

@LunNova
Copy link
Member

LunNova commented Sep 9, 2025

I’m curious why you need the builtins.toString – does this somehow make postPatch become null sometimes or something?

On further investigation I shouldn't need to change that. I accidentally exposed new attributes from the original scope such as llvm-manpages, causing a failure to eval because of how those set postPatch to null. If I don't expose those attributes then there's no need to change this yet.

A very silly thing you could do would be overrideLlvmPackagesRocm = f: llvmPackagesRocm.overrideScope (final: prev: f { inherit final prev; });

That will make the ROCm 6.4.x bump PR less annoying for future me to rebase so I kinda prefer going with that.

Third attempt: 76144e608f19b1a83af3b2b531c418c486a4b2ad

@emilazy
Copy link
Member

emilazy commented Sep 9, 2025

Don't do that inherit. It does not share the override call and will macro-expsnd to doing it for every single attribute. You need a let. Yes this is horrible.

@LunNova
Copy link
Member

LunNova commented Sep 9, 2025

Don't do that inherit. It does not share the override call and will macro-expsnd to doing it for every single attribute. You need a let. Yes this is horrible.

augh. Can I do something like below or do I need a large pile of a = overridenScope.a; b = ...?

let overridenScope = (llvmPackagesRocm.overrideScope (final: prev: f { inherit final prev; })); in {
  inherit (overridenScope)
    a
    b
    ...
    ;
}

@emilazy
Copy link
Member

emilazy commented Sep 9, 2025

Yeah that's fine, since it just desugars to the same pile.

@LunNova
Copy link
Member

LunNova commented Sep 9, 2025

Fixed in 47393c7

Is it a problem that there are a lot of inherit (callPackage… in all-packages.nix? 😨

@emilazy
Copy link
Member

emilazy commented Sep 9, 2025

Yes, I think so :( But really it’s just a Nix implementation problem and should ideally be fixed there.

@bb010g
Copy link
Contributor

bb010g commented Sep 10, 2025

Don't do that inherit. It does not share the override call and will macro-expsnd to doing it for every single attribute. You need a let. Yes this is horrible.

@emilazy I thought this had been fixed since Lix 2.90 and CppNix 2.21. Is this concern just for those still running CppNix <2.21?

@emilazy
Copy link
Member

emilazy commented Sep 10, 2025

Hmm, I was even just glancing at that code a few days ago but didn’t realize it seems to do the right thing now. That’s nice. Maybe it’s fine, then.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 17, 2025
@nixos-discourse
Copy link

@nixos-discourse
Copy link

@LunNova
Copy link
Member

LunNova commented Nov 4, 2025

This was included in #445668 which was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: stdenv Standard environment 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants