apply
5b77e752dc
to clang 14-16 and backport the patch to apply to clang 12-13
backported patch just drops the final change in Hunk 2 of Options.td as
it doesn't exist until clang-14
Remove a patch to decrease the divergence from upstream.
Motivation is a continuation of trying to reduce the number of clang
builds floating around. Wrapper builds are cheap, compiler builds are
not.
It's expected that this patch can be removed at some point and replaced
with some other cc-wrapper logic. This will be a little bit easier with
the logic already in the cc-wrapper.
Ongoing discussion in #191152. It would be nice to drop this but we
think it's probably needed at least on systems where /usr/include may be
available to prevent the possibility of picking up unwanted includes.
One potential method for eliminating nostdlibinc in the future is by
providing a non-existent -sysroot but that was reverted in #213185, and
remains a can of worms.
Signed-off-by: Peter Waller <p@pwaller.net>
Currently the target triple leaks into the clang build via llvm using
libbfd, whose build varies according to the target triple.
LLVM only uses libbfd to enable LTO via the linker plugin (called
LLVMgold.so, though multiple linkers can use the same plugin).
Drop the dependency on the libbfd build, and consume the only needed
source instead. (This would be a good use of CA-derivations FWIW).
The result of this commit is that these match:
* nix eval --raw nixpkgs#clang.cc
* nix eval --raw nixpkgs#pkgsStatic.pkgsLLVM.stdenv.cc.cc
* nix eval --raw nixpkgs#pkgsCross.aarch64-multiplatform.pkgsLLVM.stdenv.cc.cc
This means fewer clang builds will be needed to support cross
configurations, and users wanting to target an exotic cross
configuration should be able to do so without a rebuild of clang.
Also drops libbfd.hasPluginAPI which no longer has any users.
Signed-off-by: Peter Waller <p@pwaller.net>
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 <p@pwaller.net>
Also exposes owner, repo, and other attributes available on the original
monorepoSrc. These attributes were previously hidden behind a
runCommand that consumes monorepoSrc and hides this information away.
```
$ nix eval --raw .#llvmPackages_18.llvm.src.rev
llvmorg-18.1.8
$ nix eval --raw .#llvmPackages_git.llvm.src.rev
0e8555d4dbfdfeddc01dc2ecf9a9b6e804f7b645
```
Signed-off-by: Peter Waller <p@pwaller.net>
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)
Without these fixes, the git build currently fails because the tests are
out of date.
One is updated since it was fixed upstream, the other is still needed
for the git build, but testing `version` resulted in a test against the
`unstable-*` string and not the one with the version number in it.
Signed-off-by: Peter Waller <p@pwaller.net>
The build requires an unwrapped clang due to passing in --arch flags.
However, for c++ it doesn't pass in --arch and requires standard headers
so which requires the wrapped compiler.
The codesign binary is part of the bootstrapTools and is incompatible
with the version required by the compiler_rt build. Remove
find_program(.., codesign) from the cmake files to prevent the build
from using and then breaking due to an incompatible codesign
This is better handled in the cc-wrapper, and makes it possible to avoid
rebuilding clang in some scenarios.
It also appears to be unnecessary since the cc-wrapper already passes
-stdlib=libc++ where needed.
See: 8885a1e21a/pkgs/build-support/cc-wrapper/default.nix (L603)
Signed-off-by: Peter Waller <p@pwaller.net>
x64 darwin doesn't build with 10.12 sdk after the sdk refactor due to
compile errors. bumping the sdk to 11 fixes the build.
set min deployment target as needed for lldb_14
lldb_14 still broken but due to an unrelated issue.
This change implements a leftover task from #307211, namely passing
monorepoSrc to the different llvmPackages_13 package expressions. Before
this change, all packages llvmPackages_13 would be built from a
subdirectory of the full LLVM monorepo tree. After this change only the
relevant directories are made available at build time. This
- reduces the size of the source that needs to be made available to the
builder.
- prevents LLVM from sidestepping our instructions and including extra
sources from other directories it shouldn't.
Since LLVM 12 and 13 don't have the `cmake` directory at the top level,
the runCommand expressions filtering the source need to be adjusted, but
this causes no rebuild for any other LLVM version (ofborg should confirm
this).
The only problem encountered was in lld:
- We need to make the patch to the inclusion of libunwind headers
unconditional now. lld needs this on non-darwin as well. In the
full monorepo, LLVM_MAIN_SRC_DIR would be set correctly, so the
patch wasn't necessary.
- The substitute mechanism for LLVM 12 and 13 can't be unified yet since
LLVM 12 still uses a non monorepo build, so we come up with a
different LLVM_MAIN_SRC_DIR.
Change was tested by building the following expression on x86_64-linux.
with import ./. {};
builtins.removeAttrs llvmPackages_13 [ "lldb" "lldbPlugins" ]'
lld was also tested on aarch64-darwin.