-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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.*: Add devExtraCmakeFlags parameter #342040
Conversation
a01dbdb
to
2ca9a0e
Compare
cmake flags have a 'last flag wins' logic, so by appending to the end of the flags it is possible to override any cmake flag. It also ignores (and warns) if a flag is unused, so passing flags across all packages should be safe if you want to target one package. In combination with NixOS#320261, this PR allows consistently overriding all packages within LLVM with additional cmake arguments. Consistency here means for example 'if you override LLVM, then all dependencies on it are also see the overridden LLVM in their input'. Consistency is hard to achieve with the other obvious way of implementing this as a user: if you use overrideAttrs then you have to write a big mess of override code in order to override all dependents, and this can be very difficult in a cross-compilation scenario using crossSystem and useLLVM, for example. With this PR it is possible to write an overlay which overlays `llvmPackages` with `llvmPackage.override { devExtraCmakeFlags = [ ... ]; }`, and then the toolchain used with useLLVM in effect should respect these flags. This is useful in development for experimenting with the effect of various flags, hence the chosen name `devCmakeFlags`. This won't work out of the box without NixOS#341855 applied, which fixes override passthrough. See-Also: NixOS#320261, NixOS#341855 Signed-off-by: Peter Waller <[email protected]>
2ca9a0e
to
290ec4e
Compare
/cc potentially interested @RossComputerGuy @Ericson2314 @reckenrode @paparodeo @alyssais |
Could you share an example use case? What flags did you want to set? |
Setting LLVM_BUILD_INSTRUMENTED=IR, LLVM_PROFDATA, LLVM_USE_LTO in various cases in order to get a PGO/LTO build is one. More generally, as a dev, I want to test LLVM in a variety of different configurations using options documented at https://llvm.org/docs/CMake.html. Some options may (or may not, I don't know if nixpkgs has a policy on this) deserve being parameters in their own right (like for example the PGO/LTO build maybe), but in general it is useful to be able to access arbitrary cmake parameters consistently across the whole of LLVM for the sake of development and testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to be as long as other LLVM maintainers are happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any improvements we can make to the dev shell experience, the better.
|
Thanks for the reviews!
The word 'global' is probably too strong since it might imply 'beyond the llvm packageset' or 'influencing the cmake flags of other projects', which this is not. My thinking of including 'dev' in the name was to discourage general use. (Although if one were found, it could be renamed).
There are lots of things which are effectively no-op, but their existence enables additional use cases through overriding. This is such a case where lacking the passthrough it is quite difficult to achieve without patching nixpkgs, which is inconvenient and hinders experimentation and development. |
I assume we're good to merge? |
Description of changes
cmake flags have a 'last flag wins' logic, so by appending to the end of
the flags it is possible to override any cmake flag.
It also ignores (and warns) if a flag is unused, so passing flags across
all packages should be safe if you want to
target one packagepass flags which aren't supported by all packages.In combination with #320261, this PR allows consistently overriding all
packages within LLVM with additional cmake arguments. Consistency here
means for example 'if you override LLVM, then all dependencies on it
also see the overridden LLVM in their input'. Consistency is hard to
achieve with the other obvious way of implementing this as a user: if
you use overrideAttrs then you have to write a big mess of override code
in order to override all dependents, and this can be very difficult in a
cross-compilation scenario using crossSystem and useLLVM, for example.
With this PR it is possible to write an overlay which overlays
llvmPackages
withsuper.llvmPackages.override { devExtraCmakeFlags = [ ... ]; }
,and then the toolchain used with useLLVM in effect should respect
these flags.
This is useful in development for experimenting with the effect of
various flags, hence the chosen name
devCmakeFlags
.This won't work out of the box without #341855 applied, which fixes
override passthrough.
See-Also: #320261, #341855
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.