Skip to content
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_git.libcxx: use clang from git instead of the stdenv's compiler #220527

Merged
merged 1 commit into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,27 +246,39 @@ let

libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;

libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
};

libcxxabi = let
stdenv_ = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
# CMake will "require" a compiler capable of compiling C++ programs
# cxx-header's build does not actually use one so it doesn't really matter
# what stdenv we use here, as long as CMake is happy.
cxx-headers = callPackage ./libcxx {
inherit llvm_meta;
stdenv = stdenv_;
headersOnly = true;
};

# `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it
# *does* need a relatively modern C++ compiler (see:
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support).
#
# So, we use the clang from this LLVM package set, like libc++
# "boostrapping builds" do:
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build
#
# We cannot use `clangNoLibcxx` because that contains `compiler-rt` which,
# on macOS, depends on `libcxxabi`, thus forming a cycle.
stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc;
in callPackage ./libcxxabi {
stdenv = stdenv_;
inherit llvm_meta cxx-headers;
};

# Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler,
# so: we use the clang from this LLVM package set instead of the regular
# stdenv's compiler.
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

libunwind = callPackage ./libunwind {
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
Expand Down
7 changes: 7 additions & 0 deletions pkgs/development/compilers/llvm/git/libcxxabi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ stdenv.mkDerivation rec {
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libcxxabi"
"-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"

# `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached
# (we specify the headers it should use explicitly above).
#
# CMake however checks for this anyways; this flag tells it not to. See:
# https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243
"-DCMAKE_CXX_COMPILER_WORKS=ON"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
Expand Down