Eliminate rebuilding the following packages on darwin just for this
attrset:
< DarwinTools-1.drv
< DarwinTools-1.tar.gz.drv
< IOKit-11.0.drv
< builder.pl.drv
< clang-16.0.6.drv
< clang-at-least-16-LLVMgold-path.patch.drv
< clang-darwin-An-OS-version-preprocessor-define.patch.drv
< clang-src-16.0.6.drv
< llvm-16.0.6.drv
< llvm-src-16.0.6.drv
< psutil-6.0.0.tar.gz.drv
< python3-3.12.7-env.drv
< python3.12-psutil-6.0.0.drv
< sysctl-system_cmds-1012.drv
found by diffing the output of the command below before and after this
change:
```
nix-store --query -R $(nix-instantiate -A llvmPackages.lldbPlugins) | \
cut -d- -f 2- | sort
```
The original tblgen split landed before I was quite ready for it, so
older versions of clang had not been tested.
Reinstate them here.
* Apply patches from LLVM (aside for those from polly, because the
source tree is not present)
* Apply the clang/gnu-install-dirs.patch patch to the clang tree.
* Bracket the build targets with appropriate version checks so we don't
try to build non-existent things.
* Bracket mlir-tblgen with >=16 to mirror the rest of mlir support.
Signed-off-by: Peter Waller <p@pwaller.net>
There is at least one of these which isn't always present across all
LLVM version, so relax it to --replace-quiet.
Signed-off-by: Peter Waller <p@pwaller.net>
Rationale: --replace is deprecated and emits warnings. If these
replacements fail it is probably better to know about it early and come
up with better fixes than the alternative of letting them silently fail
and discover some distal brokenness.
Signed-off-by: Peter Waller <p@pwaller.net>
Background:
LLVM has some tools that run at build time. In native builds, these are
built as a part of the usual build, but in cross builds they need to
come from buildPackages.
In many scenarios this is a small problem because LLVM from
buildPackages is already available as a build; but if cross building a
version of LLVM which is not available (e.g. a new git commit of LLVM)
this results in two builds of LLVM and clang, one native and one for the
cross.
Full builds of LLVM are expensive; and unnecessary in this scenario. We
don't need a native LLVM, only a native copy of the tools which run at
build time. This is only tablegen and related tooling, which are cheap
to build.
Implementation-wise, we introduce a derivation llvmPackages.tblgen,
which specifies the tablegen targets which need to be built and has a
custom installPhase to copy them to the output.
A previous attempt in https://github.com/NixOS/nixpkgs/pull/359967
dropped the use of LLVM_TABLEGEN_EXE and friends on the grounds that
llvm can already cross build these things, but that is false since it's
necessary in that case to wire in a cross compiler. This PR avoids that
problem by allowing access to buildPackages.tblgen.
Signed-off-by: Peter Waller <p@pwaller.net>
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev 78e9caf153
result/bin/apply-formatting $NIXPKGS_PATH
Using ninja makes it consistent with the other llvm package builds, and
libclang is not necessary as a dependency.
Signed-off-by: Peter Waller <p@pwaller.net>
This deals with some special cases, i.e. where "null" is used to avoid
replacing some values or where the syntax is not too easy to grep for
for automated replacement.
Seems like the patch we've written for LLVM 13 and above also works for
LLVM 12 which seems a little more robust.
(cherry picked from commit 37437849de)
(cherry picked from commit f30f8ee969)
All LLVM versions < 12 have been removed, so this patch can live in the
versioned directory, simplifying the patch list in the process.
(cherry picked from commit 8408b91e8d)
(cherry picked from commit e33308016c)
As mentioned in #305146, keeping LLVM 12 is a source of pain because it
is the only version to be built from individual release tarball instead
of the LLVM monorepo. This commit makes LLVM 12 start from the monorepo
as well, simplifying all common LLVM expressions in the process.
With #347887, some quirks in the expressions for LLVM <14 were ironed
out, so building LLVM through from the monorepo is quite simple now.
- Most expressions only required minor changes, mostly removing the
special casing for `sourceRoot`.
- The patch lists from llvm/12/default.nix were ported to
common/default.nix. This only required a few extra conditionals which
could be reduced via a rebuild also involving other LLVM versions.
Outstanding tasks of little urgency have been noted in TODO comments.
I have verified that the patch lists stay the same for all packages
except LLVM where merely the order changes. An extra set of eyes
is appreciated, of course.
- clang: The expression was reworked to use the same symlink location
for clang-tools-extra for all versions including LLVM 12. This
required adjusting the ad hoc patching of the clangd cmake files
slightly.
- libunwind: We no longer need to make the libcxx sources available
manually. We can rely on the monorepo source instead.
- lld: We no longer need to make the libunwind sources available manually.
- llvm: We no longer need to make the polly sources available manually
- On Darwin, we need to bypass CMake's C++ compiler for libcxx and
libunwind now. It isn't a 100% clear why, probably because we've
started to use Darwin's bootstrapStdenv for libcxx in the common
expression compared to LLVM 12 on master [1].
The reordering of flags for wasm causes a rebuild for some packages
like firefox, but this should be tolerable on staging.
[1]: 665ebfb253/pkgs/development/compilers/llvm/12/default.nix (L392-L430)
(cherry picked from commit ee9eacf23e)
(cherry picked from commit c4e9f17ef9)
We just need to make sure the attribute evaluates so we can cleanly
access `meta.broken` for those versions.
(cherry picked from commit ce6c31c312)
(cherry picked from commit 9bf90993f4)