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

llvmPackages should be more easily overridable #375431

Open
LunNova opened this issue Jan 21, 2025 · 7 comments
Open

llvmPackages should be more easily overridable #375431

LunNova opened this issue Jan 21, 2025 · 7 comments
Labels
0.kind: enhancement Add something new 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related

Comments

@LunNova
Copy link
Member

LunNova commented Jan 21, 2025

llvmPackages doesn't support overrideScope so it's a pain to override its parts. If you override libllvm you need to manually override everything else that references it including patches. It's easy to accidentally allow a non-overridden copy of libllvm to sneak in.

Example of not-fun overriding lots of separate packages in https://github.com/NixOS/nixpkgs/blob/0f5740f6d9c3d0feb3da06e1da2383204fd6f92e/pkgs/development/rocm-modules/6/llvm/default.nix

There seems to be some support for overriding with .override but it's not clear how to use it. You can't use

llvmPackages.overrideScope (final: prev: {
libllvm = prev.libllvm.overrideAttrs { ... };
})

# Allows passthrough to packages via newScope. This makes it possible to
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
# an llvmPackages whose packages are overridden in an internally consistent way.
...
}@args:

cc @dtzWill @Ericson2314 @lovek323 @alyssais @RossComputerGuy @rrbutani @sternenseemann

@LunNova LunNova added 0.kind: enhancement Add something new 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Jan 21, 2025
@RossComputerGuy
Copy link
Member

This is a future project of mine that I plan on doing, I haven't had the time to focus on it yet and there's more important things I've been doing.

@LunNova LunNova changed the title llvmPackage set should be more easily overrideable llvmPackages should be more easily overridable Jan 21, 2025
@LunNova
Copy link
Member Author

LunNova commented Jan 22, 2025

@RossComputerGuy do you have a vague idea when you expect to get to this? I could give it a try if you don't anticipate getting to it for a long time.

@RossComputerGuy
Copy link
Member

do you have a vague idea when you expect to get to this?

Probably after the lib.systems PR, bolt setup hook, and CPU model improvements PR are merged so probably during the summer.

@reckenrode
Copy link
Contributor

reckenrode commented Jan 23, 2025

This would be of interest to the Darwin bootstrap. It would allow the bootstrap-specific hacks in the LLVM derivations to be removed. It might even make it possible to rely on the wrapper definitions in LLVM instead of inlining them into the bootstrap.

@RossComputerGuy
Copy link
Member

Yeah, also to add what I mentioned on Matrix. I'm thinking of staging LLVM similarly to how we do it for the stdenv bootstrap. This will likely be the bulk of the work but I would like to work on after some of the other PR's I have are done. The reason being is merge conflicts. However, I am able to start some of the pre-work. The first thing being, moving patches from pkgs/development/compilers/llvm/common/default.nix to each package's default.nix. This is to make the packages more "standalone" from the LLVM common default.nix.

@RossComputerGuy
Copy link
Member

Decided to nixfmt everything for LLVM in #376179 since I'm getting tired of looking at the old formatting. This will make the next set of work easier to perform.

@pwaller
Copy link
Contributor

pwaller commented Jan 23, 2025

There seems to be some support for overriding with .override but it's not clear how to use it. You can't use:

That's correct. It does allow you to get an overridden llvmPackages, but only for things that are fed through the inputs. So you can't straightforwardly override libllvm's attrs in the way you want. It is possible, but it not straightforward, especially in various cross scenarios. It would be good to make it so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

No branches or pull requests

4 participants