Skip to content

Commit

Permalink
llvmPackages: Make targetLlvmLibraries overridable
Browse files Browse the repository at this point in the history
Pull #320261 introduced the possibility to consistently override
dependencies within an llvm package set. This is useful for development
and testing exotic configurations.

Go one step further and enable overriding targetLlvmLibraries.

This makes it possible to write an overlay such as:

```nix
overlays = [
  (self: super: {
    llvmPackages = super.llvmPackages.override (prev: {
      targetLlvmLibraries = super.targetPackages.llvmPackages.libraries // {
        compiler-rt = super.targetPackages.llvmPackages.libraries.compiler-rt.override {
          ...
        }
      };
    });
  })
];
```

... where the overridden compiler-rt will be used in a pkgsLLVM build.

As a straw man, I've done the minimally invasive thing to the code
structure: `targetLlvmLibraries` is not an explicitly named parameter
for llvmPackages; but it is available in `packageSetArgs` if passed.
This makes it slightly less discoverable, but this seems like a
reasonable tradeoff considered that modifying this would be a fairly
advanced/esoteric thing to need to do.

In some ways it would be better to have as an explicit parameter with a
default, but the obvious thing won't work because the default needs to
be a non-trivial expression. Potentially we could instead have it as a
defaulted parameter with the value of 'null', and if it's null, then
compute the current thing.

Signed-off-by: Peter Waller <[email protected]>
  • Loading branch information
pwaller committed Nov 10, 2024
1 parent 6011527 commit 51ba14b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkgs/development/compilers/llvm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ let
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages."llvmPackages_${attrName}".tools;
targetLlvmLibraries =
targetPackages."llvmPackages_${attrName}".libraries or llvmPackages."${attrName}".libraries;
# Allow overriding targetLlvmLibraries; this enables custom runtime builds.
packageSetArgs.targetLlvmLibraries or targetPackages."llvmPackages_${attrName}".libraries
or llvmPackages."${attrName}".libraries;
targetLlvm = targetPackages."llvmPackages_${attrName}".llvm or llvmPackages."${attrName}".llvm;
inherit
officialRelease
Expand Down

0 comments on commit 51ba14b

Please sign in to comment.