LLVM 12 added the memory profiling runtime and LLVM 13 the ORC
runtime. Both need a libc in order to build (or at least headers not
present in clang's resource root), so we'll disable them for any sort of
baremetal-ish build. memprof likely doesn't work in a baremetal
situation at all, orc is unknown. Whether both would compile with musl
is to be checked.
The main thing we need to pass LLVM_ENABLE_PIC=OFF to prevent LLVM from
building shared objects because our cc-wrapper is incapable of producing
shared objects. Building LLVM statically also influences other LLVM
projects like clang and lld -- which can be built linked fully
statically with this change.
To make the value of doCheck in the argument attribute set accurate we
also need to include the condition for cross compilation which normally
is added by stdenv.mkDerivation.
LLVM's build system creates NATIVE/bin/llvm-config by reexecuting cmake
with entirely new flags. Problematically, the `CMAKE_INSTALL_*` flags
are not inherited, causing llvm-config-native to return wrong
installation paths, e. g. CMAKE_INSTALL_LIBDIR would default to `lib64`
on x86_64-linux. Previously this was masked by outputs.patch which
replaced ActiveLibDir with a string passed in from Nix, however
`--cmakedir` for example would turn out to be wrong always, breaking
cross-compilation of e. g. lld.
Additionally LLVM_ENABLE_RTTI needs to be repassed, as it is used to
determine if RTTI is available. Passing LLVM_LINK_LLVM_DYLIB is crucial
if we are building LLVM non-statically: It influences the --shared-mode
flag (which should indicate that -lLLVM is enough to link all
components) and makes --link-shared work in the first place,
i. e. llvm-config-native believes the built shared libs don't exist
unless we repass this flag.
Passing LLVM_LINK_LLVM_DYLIB=ON, however, makes the native build produce
a full libLLVM.so which is something we don't want, so we introduce a
patch which forces llvm-config to link statically against the LLVM
components it needs.
Starting with LLVM 8, clang does no longer use llvm-config to detect the
LLVM installation: https://github.com/llvm/llvm-project/commit/e4faa5c7986b7
Consequently, there is no point passing LLVM_CONFIG_PATH (in fact the
variable is unused currently).
[ 11%] Building CXX object lib/xray/CMakeFiles/clang_rt.xray-x86_64.dir/xray_buffer_queue.cc.o
In file included from lib/xray/xray_buffer_queue.cc:15:
lib/xray/xray_buffer_queue.h:35:5: error: 'size_t' does not name a type
35 | size_t Size = 0;
| ^~~~~~
lib/xray/xray_buffer_queue.h:23:1: note: 'size_t' is defined in header '<cstddef>';
did you forget to '#include <cstddef>'?
22 | #include <utility>
+++ |+#include <cstddef>
23 |
In https://gcc.gnu.org/PR103598 we found out that gcc-12
changed __PRETTY_FUNCTION__ slightly and broke llvm-12 (and older)
tests that rely on exact type match. llvm-13 already removed the
qualified names from the expected output.
This change changes expected output to avoid llvm:: namespace prefix.
This is enough to get tests pass on x86_64 again.
Tested against this week's gcc-12 and against gcc-10.
Since both static and shared libs are installed to the same `lib`
output, we override the ActiveLibDir unconditionally.
Fixes `llvm-config-native --link-static --libs`
LLVM 11 libcxxabi has some flags to support usage in the Darwin stdenv,
in particular, `standalone` and `withLibunwind`.
Darwin stdenv needs the `standalone` flag because its `hostPlatform` set
doesn't have `useLLVM` set to true. And it needs `withLibunwind` to
explicitly disable including `libunwind` as a build input.
We also prefix `install_name_tool` in case we're cross-compiling.
LLVM 11 libcxxabi has some flags to support usage in the Darwin stdenv,
in particular, `standalone` and `withLibunwind`.
Darwin stdenv needs the `standalone` flag because its `hostPlatform` set
doesn't have `useLLVM` set to true. And it needs `withLibunwind` to
explicitly disable including `libunwind` as a build input.
We also prefix `install_name_tool` in case we're cross-compiling.
The libcxxabi expression had a `standalone` argument in LLVM 7 which
triggered passing of the `-DLLVM_ENABLE_LIBCXX=ON` flag. In LLVM 11 this
flag and others are toggled by the `useLLVM` attribute of
`stdenv.hostPlatform` but this toggles a flag we don't need on Darwin.
Similar to the refactoring of LLVM 7 libc++abi by Ericson2314 in
3af7e98470, I have reintroduced the standalone argument for use in
bootstrapping the Darwin stdenv.
Without the fix build fails on gcc-12 as:
/build/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp:
In member function 'std::string llvm::NVPTXAsmPrinter::getPTXFundamentalTypeStr(...':
/build/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp:1319:10:
error: use of deleted function 'std::__cxx11::basic_string<...>; std::nullptr_t = std::nullptr_t]'
1319 | return nullptr;
| ^~~~~~~
The patch is present in upstream releases since llvm-12.
This is already done for previous versions of clang which use
a release tarball, but must be done differently for the more
recent versions which use fetchFromGitHub.
Fixes clang-tools clangd wrapper
Naive concatenation of $LD_LIBRARY_PATH can result in an empty
colon-delimited segment; this tells glibc to load libraries from the
current directory, which is definitely wrong, and may be a security
vulnerability if the current directory is untrusted. (See #67234, for
example.) Fix this throughout the tree.
Followup to #76804. Fixes#144646.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Commit 199b7c50 "compiler-rt: remove <cyclades.h> from libsanitizer"
broke conditional conditional musl patches.
The change has a few effects:
- pkgsStatic.llvmPackages_{5,6,7}.compiler-rt: fix build on musl after cyclades backport
- pkgsStatic.llvmPackages_{{5..13},git}.compiler-rt: drop incomplete musl patches as
sanitizers are disabled anyway and require more upstream porting.
the fix to extendDerivation in #140051 unwittingly worsened eval performance by
quite a bit. set elements alone needed over 1GB extra after the change, which
seems disproportionate to how small it was. if we flip the logic used to
determine which outputs to install around and keep a "this one exactly" flag in
the specific outputs instead of a "all of them" in the root we can avoid most
of that cost.
linux-headers-5.13 removed <cyclades.h> along with device support.
Backport a single https://reviews.llvm.org/D102059 upstream change to
fix compiler-rt build.
Use local patches as there is a whitespace change compared to upstream.
I currently do not have much time to work on nixpkgs. Remove
myself as a maintainer from a bunch of packages to avoid that
people are waiting on me for a review.
Conflicts:
pkgs/development/compilers/ghc/8.10.7.nix
pkgs/development/compilers/ghc/8.8.4.nix
I've removed the isWindows check from useLdGold in ghc, since that should
be covered by the new hasGold check.
Cross-compilation is broken because the method of finding ncurses has
changed, causing the build for the 'build system' to fail with a linking
error due to ncurses being for the 'host system' (where you're compiling
for).
This patch disables ncurses, which is not a very neat solution, but will
do until someone takes this upstream and gets it fixed properly.
Closes https://github.com/NixOS/nixpkgs/issues/127946.
Error that's seen before applying this:
/nix/store/hash-binutils-2.35.1/bin/ld: /nix/store/hash-ncurses-6.2-aarch64-unknown-linux-gnu/lib/libtinfo.so: error adding symbols: file in wrong format
To avoid unnecessary builds but this needs to be fixed ASAP. Chromium
already depends on it and a lot of additional packages, including Mesa,
will depend on it after the stable release.