Skip to content

Commit

Permalink
llvmPackages_15: apply #211230 to llvmPackages_15
Browse files Browse the repository at this point in the history
See the comments here for context: #194634 (comment)

Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
  • Loading branch information
rrbutani and wegank committed Jan 27, 2023
1 parent 3b6d98d commit 4fabcf4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
targetLlvmLibraries.libcxxabi
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
Expand Down Expand Up @@ -154,7 +154,7 @@ let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
targetLlvmLibraries.libcxxabi
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
Expand All @@ -167,7 +167,7 @@ let
]
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
++ lib.optional
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
"-lunwind"
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
};
Expand Down
20 changes: 15 additions & 5 deletions pkgs/development/compilers/llvm/15/libcxx/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand
, cmake, python3, fixDarwinDylibNames, version
, libcxxabi
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt
, enableShared ? !stdenv.hostPlatform.isStatic

# If headersOnly is true, the resulting package would only include the headers.
Expand All @@ -16,6 +17,8 @@ let
basename = "libcxx";
in

assert stdenv.isDarwin -> cxxabi.libName == "c++abi";

stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
Expand Down Expand Up @@ -59,12 +62,18 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;

buildInputs = lib.optionals (!headersOnly) [ libcxxabi ];
buildInputs = lib.optionals (!headersOnly) [ cxxabi ];

cmakeFlags = [
cmakeFlags = let
# See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
libcxx_cxx_abi_opt = {
"c++abi" = "system-libcxxabi";
"cxxrt" = "libcxxrt";
}.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
in [
"-DLLVM_ENABLE_RUNTIMES=libcxx"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else "system-libcxxabi"}"
] ++ lib.optional (!headersOnly) "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${libcxxabi.dev}/include/c++/v1"
"-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ lib.optionals stdenv.hostPlatform.isWasm [
Expand All @@ -78,6 +87,7 @@ stdenv.mkDerivation rec {

passthru = {
isLLVM = true;
inherit cxxabi;
};

meta = llvm_meta // {
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/compilers/llvm/15/libcxxabi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ stdenv.mkDerivation rec {
install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
'';

passthru = {
libName = "c++abi";
};

meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "Provides C++ standard library support";
Expand Down

0 comments on commit 4fabcf4

Please sign in to comment.