llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)

- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again

This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)

### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix  does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.

### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx

### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override

https://github.com/NixOS/nixpkgs/pull/292043
This commit is contained in:
a-n-n-a-l-e-e 2024-03-11 03:53:37 -07:00 committed by GitHub
parent b221192048
commit ce789e7e35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 722 additions and 2203 deletions

View file

@ -4,7 +4,6 @@
, scons
, boost
, ladspaH
, libcxxabi
}:
stdenv.mkDerivation (finalAttrs: {
@ -23,7 +22,7 @@ stdenv.mkDerivation (finalAttrs: {
--replace "-fomit-frame-pointer -ffast-math -mfpmath=sse" "-I${boost.dev}/include -I${ladspaH}/include" \
--replace "env.has_key('cxx')" "True" \
--replace "env['cxx']" "'${stdenv.cc.targetPrefix}c++'" \
--replace "-Wl,--strip-all" "${lib.optionalString stdenv.isDarwin "-L${libcxxabi}/lib"}"
--replace "-Wl,--strip-all" ""
substituteInPlace filters.cpp \
--replace "LADSPA_HINT_SAMPLE_RATE, 0, 0.5" "LADSPA_HINT_SAMPLE_RATE, 0.0001, 0.5"

View file

@ -75,10 +75,6 @@ rustPlatform.buildRustPackage rec {
# This variable is read by build script, so that Lapce editor knows its version
RELEASE_TAG_NAME = "v${version}";
} // lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
postPatch = ''

View file

@ -78,11 +78,6 @@ rustPlatform.buildRustPackage.override { stdenv = clangStdenv; } rec {
darwin.apple_sdk.frameworks.AppKit
];
env = lib.optionalAttrs stdenv.isDarwin {
# Work around https://github.com/NixOS/nixpkgs/issues/166205
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
postFixup = let
libPath = lib.makeLibraryPath ([
libglvnd

View file

@ -62,8 +62,6 @@ stdenv.mkDerivation rec {
env = lib.optionalAttrs stdenv.isDarwin {
GETTEXT_DIR = gettext;
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
meta = with lib; {

View file

@ -183,7 +183,7 @@ let
# We only link c++ libs here, our compiler wrapper can find wasi libc and crt itself.
wasiSysRoot = runCommand "wasi-sysroot" {} ''
mkdir -p $out/lib/wasm32-wasi
for lib in ${pkgsCross.wasi32.llvmPackages.libcxx}/lib/* ${pkgsCross.wasi32.llvmPackages.libcxxabi}/lib/*; do
for lib in ${pkgsCross.wasi32.llvmPackages.libcxx}/lib/*; do
ln -s $lib $out/lib/wasm32-wasi
done
'';

View file

@ -13,7 +13,7 @@ let
[ zlib glib libpng freetype xorg.libSM xorg.libICE xorg.libXrender openssl
xorg.libXrandr xorg.libXfixes xorg.libXcursor xorg.libXinerama
xorg.libxcb fontconfig xorg.libXext xorg.libX11 alsa-lib qtbase qtwebengine qtwebchannel qtsvg
qtwebsockets libpulseaudio quazip llvmPackages.libcxx llvmPackages.libcxxabi
qtwebsockets libpulseaudio quazip llvmPackages.libcxx
];
desktopItem = makeDesktopItem {

View file

@ -35,10 +35,7 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optional stdenv.isLinux alsa-lib
++ lib.optionals stdenv.isDarwin [ AppKit CoreFoundation Security ];
env = lib.optionalAttrs (stdenv.cc.libcxx != null) {
# work around https://github.com/NixOS/nixpkgs/issues/166205
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
} // lib.optionalAttrs stdenv.cc.isClang {
env = lib.optionalAttrs stdenv.cc.isClang {
CXXFLAGS = "-std=c++11";
} // lib.optionalAttrs stdenv.isDarwin {
NIX_CFLAGS_LINK = "-headerpad_max_install_names";

View file

@ -2,7 +2,7 @@
, file, atk, alsa-lib, cairo, fontconfig, gdk-pixbuf, glib, webkitgtk, gtk2-x11, gtk3
, heimdal, krb5, libsoup, libvorbis, speex, openssl, zlib, xorg, pango, gtk2
, gnome2, mesa, nss, nspr, gtk_engines, freetype, dconf, libpng12, libxml2
, libjpeg, libredirect, tzdata, cacert, systemd, libcxxabi, libcxx, e2fsprogs, symlinkJoin
, libjpeg, libredirect, tzdata, cacert, systemd, libcxx, e2fsprogs, symlinkJoin
, libpulseaudio, pcsclite, glib-networking, llvmPackages_12, opencv4
, libfaketime
, libinput, libcap, libjson, libsecret, libcanberra-gtk3
@ -84,7 +84,6 @@ stdenv.mkDerivation rec {
libcap
libcanberra-gtk3
libcxx
libcxxabi
libinput
libjpeg
libjson

View file

@ -120,11 +120,6 @@ rustPlatform.buildRustPackage rec {
--replace '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
'';
env = lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# Some tests require networking
doCheck = false;

View file

@ -50,11 +50,6 @@ stdenv.mkDerivation (finalAttrs: {
"-DINSTALL_LICENSE=OFF"
];
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
passthru.tests = {
version = testers.testVersion {
package = finalAttrs.finalPackage;

View file

@ -4,10 +4,7 @@
, lib
, emptyDirectory
, linkFarm
, symlinkJoin
, jam
, libcxx
, libcxxabi
, openssl
, xcbuild
, CoreServices
@ -33,10 +30,6 @@ let
# cone-based Git sparse checkout, either.)
{ name = "contrib"; path = "${src}/contrib"; }
];
libcxxUnified = symlinkJoin {
inherit (libcxx) name;
paths = [ libcxx libcxxabi ];
};
in
stdenv.mkDerivation rec {
pname = "p4";
@ -70,7 +63,7 @@ stdenv.mkDerivation rec {
++ lib.optionals stdenv.isDarwin [
"-sOSVER=1013"
"-sMACOSX_SDK=${emptyDirectory}"
"-sLIBC++DIR=${libcxxUnified}/lib"
"-sLIBC++DIR=${lib.getLib stdenv.cc.libcxx}/lib"
];
CCFLAGS =

View file

@ -543,8 +543,11 @@ stdenv.mkDerivation {
''
+ optionalString (libcxx.isLLVM or false) ''
echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-isystem ${lib.getDev libcxx.cxxabi}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
''
# can remove once LLVM9 and LLVM11 are dropped from nixpkgs
+ optionalString (libcxx.isLLVM or false && lib.versionOlder (lib.getVersion libcxx) "12" && libcxx ? cxxabi.libName) ''
echo "-isystem ${lib.getDev libcxx.cxxabi}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-l${libcxx.cxxabi.libName}" >> $out/nix-support/libcxx-ldflags
''

View file

@ -18,11 +18,6 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-48ZVbRJkpMO+kJE5Kz96McjXhMtu4TzzjfyYdggNWkQ=";
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
nativeBuildInputs = [ installShellFiles ];
# error: linker `aarch64-linux-gnu-gcc` not found

View file

@ -59,11 +59,6 @@ buildGoModule rec {
flags = [ "-a -trimpath" ];
ldflags = [ "-s" "-w" "-X github.com/richardwilkes/toolbox/cmdline.AppVersion=${version}" ];
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs (stdenv.cc.libcxx != null) {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
installPhase = ''
runHook preInstall
install -Dm755 $GOPATH/bin/gcs -t $out/bin

View file

@ -36,11 +36,6 @@ rustPlatform.buildRustPackage rec {
cargoBuildFlags = [ "-p nickel-lang-cli" "-p nickel-lang-lsp" ];
env = lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
nativeBuildInputs = [
python3
];

View file

@ -47,9 +47,6 @@ rustPlatform.buildRustPackage rec {
SYMBOLICATOR_GIT_VERSION = src.rev;
SYMBOLICATOR_RELEASE = version;
ZSTD_SYS_USE_PKG_CONFIG = true;
} // lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# tests require network access

View file

@ -97,8 +97,6 @@ let
cudaBuildInputs = [ llamaccpPackage ];
rocmBuildInputs = [ llamaccpPackage ];
LLAMA_CPP_LIB = "${llamaccpPackage.outPath}/lib";
in
rustPlatform.buildRustPackage {
inherit pname version;
@ -148,11 +146,7 @@ rustPlatform.buildRustPackage {
++ optionals enableRocm rocmBuildInputs
;
env = lib.mergeAttrsList [
{ inherit LLAMA_CPP_LIB; }
# Work around https://github.com/NixOS/nixpkgs/issues/166205
(lib.optionalAttrs stdenv.cc.isClang { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; })
];
env.LLAMA_CPP_LIB = "${lib.getLib llamaccpPackage}/lib";
patches = [ ./0001-nix-build-use-nix-native-llama-cpp-package.patch ];
# Fails with:

View file

@ -50,11 +50,6 @@ buildGoModule rec {
"no_adodb"
];
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
ldflags = [
"-s"
"-w"

View file

@ -27,12 +27,7 @@ rustPlatform.buildRustPackage rec {
zlib
];
env = {
LLVM_SYS_130_PREFIX = llvmPackages_13.llvm.dev;
} // lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
env.LLVM_SYS_130_PREFIX = llvmPackages_13.llvm.dev;
# process didn't exit successfully: <...> SIGSEGV
doCheck = false;

View file

@ -152,7 +152,7 @@ let
# Darwin links against libc++ not libstdc++. Newer versions of clang (12+) require
# libc++abi to be linked explicitly (see https://github.com/NixOS/nixpkgs/issues/166205).
substituteInPlace src/llvm/lib_llvm.cr \
--replace '@[Link("stdc++")]' '@[Link("c++", "-l${stdenv.cc.libcxx.cxxabi.libName}")]'
--replace '@[Link("stdc++")]' '@[Link("c++")]'
'';
# Defaults are 4

View file

@ -1,5 +1,5 @@
{ lib, stdenv, llvm_meta, version, fetch
, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -20,8 +20,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString [
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -109,7 +109,6 @@ let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -163,7 +162,6 @@ let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -257,24 +255,13 @@ let
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
inherit llvm_meta;
inherit (buildLlvmTools) llvm;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
openmp = callPackage ./openmp {

View file

@ -1,68 +1,127 @@
{ lib, stdenv, llvm_meta, fetch, cmake, python3, llvm, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt
{ lib, stdenv, llvm_meta
, fetchFromGitHub, runCommand, substitute
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
}:
assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
stdenv.mkDerivation {
pname = "libcxx";
inherit version;
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
src = fetch "libcxx" "05cx39ldlxchck454lgfly1xj0c7x65iyx4hqhiihrlg6p6qj854";
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
postUnpack = ''
unpackFile ${libcxxabi.src}
mv libcxxabi-* libcxxabi
unpackFile ${llvm.src}
mv llvm-* llvm
'';
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
stdenv.mkDerivation rec {
pname = basename;
inherit version cmakeFlags;
src = fetchFromGitHub {
owner = "llvm";
repo = "llvm-project";
rev = "refs/tags/llvmorg-${version}";
sparseCheckout = [
"libcxx"
"libcxxabi"
"llvm/cmake"
"llvm/utils"
"runtimes"
];
hash = "sha256-etxgXIdWxMTmbZ83Hsc0w6Jt5OSQSUEPVEWqLkHsNBY=";
};
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
(substitute {
src = ../../common/libcxxabi/wasm.patch;
replacements = [
"--replace-fail" "/cmake/" "/llvm/cmake/"
];
})
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../common/libcxx/libcxx-0001-musl-hacks.patch
(substitute {
src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
replacements = [
"--replace-fail" "/include/" "/libcxx/include/"
];
})
];
postPatch = ''
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs = [ cxxabi ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
cmakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabi.pname}"
] ++ 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 [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
preInstall = lib.optionalString (stdenv.isDarwin) ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
installName="$out/lib/$baseName"
abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
done
done
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include $out/include/c++/v1
lndir ${lib.getLib cxxabi}/lib $out/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,100 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9bf1a02f0908..612cd4aab76c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
project(libcxx CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION 12.0.0)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@@ -402,7 +404,7 @@ endif ()
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR})
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
@@ -410,11 +412,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR})
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
else()
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
set(LIBCXX_HEADER_DIR ${CMAKE_BINARY_DIR})
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
endif()
file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
index 5d2764e870e9..bb1ec5de6ca2 100644
--- a/cmake/Modules/HandleLibCXXABI.cmake
+++ b/cmake/Modules/HandleLibCXXABI.cmake
@@ -63,7 +63,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
if (LIBCXX_INSTALL_HEADERS)
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir}
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}
COMPONENT cxx-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 29a317b8ae9a..4747263cfd1b 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -252,7 +252,7 @@ if (LIBCXX_INSTALL_HEADERS)
foreach(file ${files})
get_filename_component(dir ${file} DIRECTORY)
install(FILES ${file}
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir}
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dir}
COMPONENT cxx-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
@@ -260,7 +260,7 @@ if (LIBCXX_INSTALL_HEADERS)
# Install the generated header as __config.
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
RENAME __config
COMPONENT cxx-headers)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9965104cb5b2..9b55dbb1d822 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -352,21 +352,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY)
install(TARGETS cxx_shared
ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
+ RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
if (LIBCXX_INSTALL_STATIC_LIBRARY)
install(TARGETS cxx_static
ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
+ RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
if(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
install(TARGETS cxx_experimental
LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
+ RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
# NOTE: This install command must go after the cxx install command otherwise

View file

@ -1,87 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, python3, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
, standalone ? stdenv.hostPlatform.useLLVM or false
, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
}:
stdenv.mkDerivation {
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "1l4idd8npbkm168d26kqn529yv3npsd8f2dm8a7iwyknj7iyivw8";
outputs = [ "out" "dev" ];
postUnpack = ''
unpackFile ${libcxx.src}
mv libcxx-* libcxx
unpackFile ${llvm.src}
mv llvm-* llvm
'' + lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d libcxx -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch}
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
'';
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake python3 ];
buildInputs = lib.optional withLibunwind libunwind;
cmakeFlags = lib.optionals standalone [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
# Fix up the install name. Preserve the basename, just replace the path.
installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
# cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
# libcxxabi to sometimes link against a different version of itself.
# Here we simply make that second reference point to ourselves.
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
done
done
'';
postInstall = ''
mkdir -p "$dev/include"
install -m 644 ../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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,34 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 426c855288fc..a9812a994f53 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
project(libcxxabi CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxxabi)
set(PACKAGE_VERSION 11.0.0)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@@ -180,17 +182,17 @@ set(CMAKE_MODULE_PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
endif()
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX})
else()
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX})
endif()
set(LIBCXXABI_INSTALL_PREFIX "" CACHE STRING "Define libc++abi destination prefix.")

View file

@ -9,10 +9,8 @@ stdenv.mkDerivation rec {
src = fetch pname "192ww6n81lj2mb9pj4043z79jp3cf58a9c2qrxjwm5c3a64n1shb";
postUnpack = ''
unpackFile ${libcxx.src}
mv libcxx-* libcxx
unpackFile ${llvm.src}
mv llvm-* llvm
ln -s ${libcxx.src}/libcxx .
ln -s ${libcxx.src}/llvm .
'';
patches = [

View file

@ -184,6 +184,10 @@ in stdenv.mkDerivation (rec {
--replace 'Starting llvm::' 'Starting {{.*}}' \
--replace 'Finished llvm::' 'Finished {{.*}}'
done
'' + ''
# gcc-13 fix
sed -i '/#include <string>/i#include <cstdint>' \
include/llvm/DebugInfo/Symbolize/DIPrinter.h
'';
preConfigure = ''

View file

@ -1,5 +1,5 @@
{ lib, stdenv, llvm_meta, version, src
, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -22,8 +22,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString [
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -137,7 +137,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -203,7 +202,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -297,28 +295,8 @@ in let
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else (
# libcxx >= 13 does not build on gcc9
if stdenv.cc.isGNU && lib.versionOlder stdenv.cc.version "10"
then pkgs.gcc10Stdenv
else stdenv
);
};
libcxxabi = let
stdenv_ = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
cxx-headers = callPackage ./libcxx {
inherit llvm_meta;
stdenv = stdenv_;
headersOnly = true;
};
in callPackage ./libcxxabi {
stdenv = stdenv_;
inherit llvm_meta cxx-headers;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
monorepoSrc = src;
};
libunwind = callPackage ./libunwind {

View file

@ -1,80 +1,123 @@
{ lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand, substitute
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
stdenv.mkDerivation rec {
pname = if headersOnly then "cxx-headers" else "libcxx";
inherit version;
pname = basename;
inherit version cmakeFlags;
inherit src;
sourceRoot = "${src.name}/libcxx";
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
(substitute {
src = ../../common/libcxxabi/wasm.patch;
replacements = [
"--replace-fail" "/cmake/" "/llvm/cmake/"
];
})
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../common/libcxx/libcxx-0001-musl-hacks.patch
(substitute {
src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
replacements = [
"--replace-fail" "/include/" "/libcxx/include/"
];
})
];
postPatch = ''
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs = lib.optionals (!headersOnly) [ cxxabi ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
cmakeFlags = [ "-DLIBCXX_CXX_ABI=${cxxabi.pname}" ]
++ 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 [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
buildFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
installName="$out/lib/$baseName"
abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
done
done
'';
# At this point, cxxabi headers would be installed in the dev output, which
# prevents moveToOutput from doing its job later in the build process.
postInstall = lib.optionalString (!headersOnly) ''
mv "$dev/include/c++/v1/"* "$out/include/c++/v1/"
pushd "$dev"
rmdir -p include/c++/v1
popd
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {
@ -84,7 +127,6 @@ stdenv.mkDerivation rec {
libc++ is an implementation of the C++ standard library, targeting C++11,
C++14 and above.
'';
# "All of the code in libc++ is dual licensed under the MIT license and the
# UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];

View file

@ -1,82 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b1e25358d41a..7fe1f4d85401 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
project(libcxx CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION 13.0.0git)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@@ -412,7 +414,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
"Path where target-agnostic libc++ headers should be installed.")
@@ -426,7 +428,7 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
"Path where target-agnostic libc++ headers should be installed.")
@@ -436,7 +438,7 @@ else()
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
"Path where target-agnostic libc++ headers should be installed.")
diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
index 5a8a4a270a1a..c06bae0001aa 100644
--- a/cmake/Modules/HandleLibCXXABI.cmake
+++ b/cmake/Modules/HandleLibCXXABI.cmake
@@ -63,7 +63,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
if (LIBCXX_INSTALL_HEADERS)
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
- DESTINATION include/c++/v1/${dstdir}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}
COMPONENT cxx-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 496429f3841e..1a0c9c0a3159 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -376,21 +376,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY)
install(TARGETS cxx_shared
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION bin COMPONENT cxx)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
if (LIBCXX_INSTALL_STATIC_LIBRARY)
install(TARGETS cxx_static
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION bin COMPONENT cxx)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
if(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
install(TARGETS cxx_experimental
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
- RUNTIME DESTINATION bin COMPONENT cxx)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
endif()
# NOTE: This install command must go after the cxx install command otherwise

View file

@ -1,84 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, python3, src, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
, standalone ? stdenv.hostPlatform.useLLVM or false
, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
inherit src;
sourceRoot = "${src.name}/${pname}";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
'';
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake python3 ];
buildInputs = lib.optional withLibunwind libunwind;
cmakeFlags = [
"-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
] ++ lib.optionals standalone [
"-DLLVM_ENABLE_LIBCXX=ON"
] ++ lib.optionals (standalone && withLibunwind) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
# Fix up the install name. Preserve the basename, just replace the path.
installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
# cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
# libcxxabi to sometimes link against a different version of itself.
# Here we simply make that second reference point to ourselves.
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
done
done
'';
postInstall = ''
mkdir -p "$dev/include"
install -m 644 ../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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,37 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9fb35860d483..5739d9e8af62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
project(libcxxabi CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxxabi)
set(PACKAGE_VERSION 11.0.0git)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@@ -195,7 +197,7 @@ set(CMAKE_MODULE_PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -204,12 +206,12 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -1,6 +1,6 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -30,8 +30,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString [
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -134,7 +134,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -200,7 +199,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -296,23 +294,7 @@ in let
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;
cxx-headers = callPackage ./libcxx {
inherit llvm_meta;
stdenv = stdenv_;
headersOnly = true;
};
in callPackage ./libcxxabi {
stdenv = stdenv_;
inherit llvm_meta cxx-headers;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {

View file

@ -1,87 +1,129 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand
, cmake, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt
, monorepoSrc, runCommand, substitute
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
pname = basename;
inherit version cmakeFlags;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${basename} "$out"
mkdir -p "$out/libcxxabi"
cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
'';
cp -r ${monorepoSrc}/third-party "$out"
cp -r ${monorepoSrc}/runtimes "$out"
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
sourceRoot = "${src.name}/${basename}";
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
(substitute {
src = ../../common/libcxxabi/wasm.patch;
replacements = [
"--replace-fail" "/cmake/" "/llvm/cmake/"
];
})
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../common/libcxx/libcxx-0001-musl-hacks.patch
(substitute {
src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
replacements = [
"--replace-fail" "/include/" "/libcxx/include/"
];
})
];
postPatch = ''
# fix CMake error when static and LIBCXXABI_USE_LLVM_UNWINDER=ON. aren't
# building unwind so don't need to depend on it
substituteInPlace libcxx/src/CMakeLists.txt \
--replace-fail "add_dependencies(cxx_static unwind)" "# add_dependencies(cxx_static unwind)"
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs = lib.optionals (!headersOnly) [ cxxabi ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
cmakeFlags = [ "-DLIBCXX_CXX_ABI=${cxxabi.pname}" ]
++ 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 [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
buildFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
installName="$out/lib/$baseName"
abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
done
done
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,21 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -436,7 +436,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
"Path where target-specific libc++ headers should be installed.")
@@ -453,7 +453,7 @@ else()
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
endif()
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
"Path where target-specific libc++ headers should be installed.")

View file

@ -1,103 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, python3
, monorepoSrc, runCommand
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx/src"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
'';
sourceRoot = "${src.name}/${pname}";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
'';
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
cmakeFlags = [
"-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
installPhase = if stdenv.isDarwin
then ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
# Fix up the install name. Preserve the basename, just replace the path.
installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
# cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
# libcxxabi to sometimes link against a different version of itself.
# Here we simply make that second reference point to ourselves.
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
done
done
make install
install -d 755 $out/include
install -m 644 ../include/*.h $out/include
''
else ''
install -d -m 755 $out/include $out/lib
install -m 644 lib/libc++abi.a $out/lib
install -m 644 ../include/cxxabi.h $out/include
'' + lib.optionalString enableShared ''
install -m 644 lib/libc++abi.so.1.0 $out/lib
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
passthru = {
libName = "c++abi";
};
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "Provides C++ standard library support";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecbc7091864e..53ba2dbc3bd1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,7 +216,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -230,7 +230,7 @@ else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -1,6 +1,6 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -30,8 +30,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString [
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -139,7 +139,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -205,7 +204,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -309,45 +307,7 @@ in let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxxabi = let
# 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;
# Note that if we use the regular stdenv here we'll get cycle errors
# when attempting to use this compiler in the stdenv.
#
# The final stdenv pulls `cxx-headers` from the package set where
# hostPlatform *is* the target platform which means that `stdenv` at
# that point attempts to use this toolchain.
#
# So, we use `stdenv_` (the stdenv containing `clang` from this package
# set, defined below) to sidestep this issue.
#
# Because we only use `cxx-headers` in `libcxxabi` (which depends on the
# clang stdenv _anyways_), this is okay.
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,
# `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 {

View file

@ -1,75 +1,110 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
, monorepoSrc, runCommand, fetchpatch, substitute
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
pname = basename;
inherit version cmakeFlags;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${basename} "$out"
mkdir -p "$out/libcxxabi"
cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/third-party "$out"
cp -r ${monorepoSrc}/runtimes "$out"
'';
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
prePatch = ''
cd ../${basename}
chmod -R u+w .
'';
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
# See:
# - https://reviews.llvm.org/D133566
# - https://github.com/NixOS/nixpkgs/issues/214524#issuecomment-1429146432
# !!! Drop in LLVM 16+
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/57c7bb3ec89565c68f858d316504668f9d214d59.patch";
hash = "sha256-AaM9A6tQ4YAw7uDqCIV4VaiUyLZv+unwcOqbakwW9/k=";
relative = "libcxx";
hash = "sha256-B07vHmSjy5BhhkGSj3e1E0XmMv5/9+mvC/k70Z29VwY=";
})
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
(substitute {
src = ../../common/libcxxabi/wasm.patch;
replacements = [
"--replace-fail" "/cmake/" "/llvm/cmake/"
];
})
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../common/libcxx/libcxx-0001-musl-hacks.patch
(substitute {
src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
replacements = [
"--replace-fail" "/include/" "/libcxx/include/"
];
})
];
postPatch = ''
cd ../runtimes
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@ -77,52 +112,22 @@ stdenv.mkDerivation rec {
'';
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs =
lib.optionals (!headersOnly) [ cxxabi ]
++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
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 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.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
# (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15
# does not appear to)
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwind
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
# "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
"-DCMAKE_SHARED_LINKER_FLAGS=-lunwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
# If we're only building the headers we don't actually *need* a functioning
# C/C++ compiler:
++ lib.optionals (headersOnly) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
];
ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74eff2002fc9..c935d10878bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -419,7 +419,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
"Path where target-specific libc++ headers should be installed.")
@@ -436,7 +436,7 @@ else()
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
endif()
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
"Path where target-specific libc++ headers should be installed.")

View file

@ -1,113 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, ninja, python3
, monorepoSrc, runCommand, fetchpatch
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx/src"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
'';
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
# https://reviews.llvm.org/D132298, Allow building libcxxabi alone
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
stripLen = 1;
})
];
postPatch = ''
cd ../runtimes
'';
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
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"
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
'';
postInstall = ''
mkdir -p "$dev/include"
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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8326d08d23a..a1e36f713161 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -201,7 +201,7 @@ else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -1,6 +1,6 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -31,8 +31,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString ([
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -139,7 +139,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -214,7 +213,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -324,45 +322,7 @@ in let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxxabi = let
# 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;
# Note that if we use the regular stdenv here we'll get cycle errors
# when attempting to use this compiler in the stdenv.
#
# The final stdenv pulls `cxx-headers` from the package set where
# hostPlatform *is* the target platform which means that `stdenv` at
# that point attempts to use this toolchain.
#
# So, we use `stdenv_` (the stdenv containing `clang` from this package
# set, defined below) to sidestep this issue.
#
# Because we only use `cxx-headers` in `libcxxabi` (which depends on the
# clang stdenv _anyways_), this is okay.
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,
# `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 {

View file

@ -1,115 +1,113 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
pname = basename;
inherit version cmakeFlags;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${basename} "$out"
mkdir -p "$out/libcxxabi"
cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/third-party "$out"
cp -r ${monorepoSrc}/runtimes "$out"
'';
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
prePatch = ''
cd ../${basename}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
];
postPatch = ''
cd ../runtimes
'';
outputs = [ "out" "dev" ];
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs =
lib.optionals (!headersOnly) [ cxxabi ]
++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
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 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.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
# If we're only building the headers we don't actually *need* a functioning
# C/C++ compiler:
++ lib.optionals (headersOnly) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
];
ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74eff2002fc9..c935d10878bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -419,7 +419,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
"Path where target-specific libc++ headers should be installed.")
@@ -436,7 +436,7 @@ else()
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
endif()
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
"Path where target-specific libc++ headers should be installed.")

View file

@ -1,114 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, ninja, python3
, monorepoSrc, runCommand, fetchpatch
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx/src"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'';
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
# https://reviews.llvm.org/D132298, Allow building libcxxabi alone
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
stripLen = 1;
})
];
postPatch = ''
cd ../runtimes
'';
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
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 && !stdenv.hostPlatform.isWasm) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
'';
postInstall = ''
mkdir -p "$dev/include"
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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8326d08d23a..a1e36f713161 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -201,7 +201,7 @@ else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -1,6 +1,6 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -31,8 +31,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString ([
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -134,7 +134,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -199,7 +198,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -308,45 +306,7 @@ in let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxxabi = let
# 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;
# Note that if we use the regular stdenv here we'll get cycle errors
# when attempting to use this compiler in the stdenv.
#
# The final stdenv pulls `cxx-headers` from the package set where
# hostPlatform *is* the target platform which means that `stdenv` at
# that point attempts to use this toolchain.
#
# So, we use `stdenv_` (the stdenv containing `clang` from this package
# set, defined below) to sidestep this issue.
#
# Because we only use `cxx-headers` in `libcxxabi` (which depends on the
# clang stdenv _anyways_), this is okay.
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,
# `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 {

View file

@ -1,71 +1,101 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
pname = basename;
inherit version cmakeFlags;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${basename} "$out"
mkdir -p "$out/libcxxabi"
cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/third-party "$out"
cp -r ${monorepoSrc}/runtimes "$out"
'';
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" "dev" ];
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
prePatch = ''
cd ../${basename}
chmod -R u+w .
'';
patches = [
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
] ++ lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
# https://github.com/llvm/llvm-project/issues/64226
(fetchpatch {
name = "0042-mbstate_t-not-defined.patch";
url = "https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch";
relative = "libcxx";
hash = "sha256-fVbX99W1gQrSaMFeBkzsJmNWNy0xVSw+oFvDe4AYXL0=";
hash = "sha256-jo+DYA6zuSv9OH3A0bYwY5TlkWprup4OKQ7rfK1WHBI=";
})
];
postPatch = ''
cd ../runtimes
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@ -73,50 +103,22 @@ stdenv.mkDerivation rec {
'';
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs =
lib.optionals (!headersOnly) [ cxxabi ]
++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
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 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.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
# If we're only building the headers we don't actually *need* a functioning
# C/C++ compiler:
++ lib.optionals (headersOnly) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
];
ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,114 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, ninja, python3
, monorepoSrc, runCommand, fetchpatch
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx/src"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'';
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
# https://reviews.llvm.org/D132298, Allow building libcxxabi alone
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
stripLen = 1;
})
];
postPatch = ''
cd ../runtimes
'';
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
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 && !stdenv.hostPlatform.isWasm) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
'';
postInstall = ''
mkdir -p "$dev/include"
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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,22 +0,0 @@
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index f380fe6b6b92..a9656258c38e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,7 +188,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -202,7 +202,7 @@ else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -1,6 +1,6 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
@ -31,8 +31,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
env.NIX_CFLAGS_COMPILE = toString ([
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"

View file

@ -134,7 +134,6 @@ in let
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
@ -199,7 +198,6 @@ in let
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
@ -303,45 +301,7 @@ in let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxxabi = let
# 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;
# Note that if we use the regular stdenv here we'll get cycle errors
# when attempting to use this compiler in the stdenv.
#
# The final stdenv pulls `cxx-headers` from the package set where
# hostPlatform *is* the target platform which means that `stdenv` at
# that point attempts to use this toolchain.
#
# So, we use `stdenv_` (the stdenv containing `clang` from this package
# set, defined below) to sidestep this issue.
#
# Because we only use `cxx-headers` in `libcxxabi` (which depends on the
# clang stdenv _anyways_), this is okay.
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,
# `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 {

View file

@ -9,13 +9,13 @@ removes space from
https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch
so it applies cleanly
---
include/__mbstate_t.h | 3 +++
libcxx/include/__mbstate_t.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/__mbstate_t.h b/include/__mbstate_t.h
diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
index bfa6d61..5f51112 100644
--- a/include/__mbstate_t.h
+++ b/include/__mbstate_t.h
--- a/libcxx/include/__mbstate_t.h
+++ b/libcxx/include/__mbstate_t.h
@@ -42,6 +42,9 @@
#elif __has_include(<bits/types/mbstate_t.h>)
# include <bits/types/mbstate_t.h> // works on most Unixes

View file

@ -1,57 +1,107 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
, enableShared ? !stdenv.hostPlatform.isStatic
# If headersOnly is true, the resulting package would only include the headers.
# Use this to break the circular dependency between libcxx and libcxxabi.
#
# Some context:
# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
, headersOnly ? false
}:
# external cxxabi is not supported on Darwin as the build will not link libcxx
# properly and not re-export the cxxabi symbols into libcxx
# https://github.com/NixOS/nixpkgs/issues/166205
# https://github.com/NixOS/nixpkgs/issues/269548
assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
let
basename = "libcxx";
cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
cxxCMakeFlags = [
"-DLIBCXX_CXX_ABI=${cxxabiName}"
] ++ lib.optionals (cxxabi != null) [
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
"-DLIBCXX_HAS_MUSL_LIBC=1"
] ++ lib.optionals (lib.versionAtLeast version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
"-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
] ++ lib.optionals useLLVM [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ cxxCMakeFlags
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
in
assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
stdenv.mkDerivation rec {
pname = basename + lib.optionalString headersOnly "-headers";
inherit version;
pname = basename;
inherit version cmakeFlags;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${basename} "$out"
mkdir -p "$out/libcxxabi"
cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
src = runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/libcxx "$out"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/third-party "$out"
cp -r ${monorepoSrc}/runtimes "$out"
'';
'' + lib.optionalString (cxxabi == null) ''
cp -r ${monorepoSrc}/libcxxabi "$out"
'');
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
prePatch = ''
cd ../${basename}
chmod -R u+w .
'';
outputs = [ "out" "dev" ];
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
# https://github.com/llvm/llvm-project/issues/64226
./0001-darwin-10.12-mbstate_t-fix.patch
] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [
# Allow building libcxxabi alone when using LLVM unwinder
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
revert = true;
hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA=";
})
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
revert = true;
hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY=";
})
];
postPatch = ''
cd ../runtimes
cd runtimes
'';
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@ -59,52 +109,22 @@ stdenv.mkDerivation rec {
'';
nativeBuildInputs = [ cmake ninja python3 ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional (cxxabi != null) lndir;
buildInputs =
lib.optionals (!headersOnly) [ cxxabi ]
++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
buildInputs = [ cxxabi ]
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
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 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.optionals (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false) && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
"-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBCXX_USE_COMPILER_RT=ON"
# There's precedent for this in llvm-project/libcxx/cmake/caches.
# In a monorepo build you might do the following in the libcxxabi build:
# -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
# libcxx appears to require unwind and doesn't pull it in via other means.
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
# If we're only building the headers we don't actually *need* a functioning
# C/C++ compiler:
++ lib.optionals (headersOnly) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
];
ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {

View file

@ -1,130 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, ninja, python3
, monorepoSrc, runCommand, fetchpatch
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libcxxabi";
inherit version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx/src"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
outputs = [ "out" "dev" ];
postUnpack = lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'';
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
# https://reviews.llvm.org/D132298, Allow building libcxxabi alone
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
stripLen = 1;
})
] ++ lib.optionals (lib.versionAtLeast version "18") [
# Allow building libcxxabi alone when using LLVM unwinder
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
stripLen = 1;
revert = true;
hash = "sha256-Jogx/cvTJ6fdyprTD1QzMIeRWcBlZZMWE/y9joOtVH0=";
})
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
stripLen = 1;
revert = true;
hash = "sha256-7VeBFjG7CnEMWn0hpBvyNOyhRfz50PnD3zyQNDhNChk=";
})
];
postPatch = ''
cd ../runtimes
'';
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
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 (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm)) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
"-DUNIX=ON"
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file
done
'';
postInstall = ''
mkdir -p "$dev/include"
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";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,22 +0,0 @@
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index f380fe6b6b92..a9656258c38e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,7 +188,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -202,7 +202,7 @@ else()
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING
+ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
"Path where built libc++abi libraries should be installed.")
endif()

View file

@ -47,9 +47,6 @@ stdenv.mkDerivation rec {
ghostscript
];
# Work around https://github.com/NixOS/nixpkgs/issues/166205
env.NIX_LDFLAGS = lib.optionalString (stdenv.cc.isClang && stdenv.cc.libcxx != null) "-l${stdenv.cc.libcxx.cxxabi.libName}";
configurePhase = ''
runHook preConfigure

View file

@ -284,7 +284,6 @@ in stdenv.mkDerivation {
patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch}
patch -p1 -d swift -i ${./patches/swift-linux-fix-linking.patch}
patch -p1 -d swift -i ${./patches/swift-darwin-libcxx-flags.patch}
patch -p1 -d swift -i ${./patches/swift-darwin-link-cxxabi.patch}
patch -p1 -d swift -i ${substituteAll {
src = ./patches/swift-darwin-plistbuddy-workaround.patch;
inherit swiftArch;

View file

@ -1,14 +0,0 @@
This patches the stdlib backdeploy static lib to have its users link c++abi.
Without this, later steps that try to link this fail looking for global
new/delete operators (__Znwm/__ZdlPv).
--- a/stdlib/toolchain/Compatibility56/Overrides.cpp
+++ b/stdlib/toolchain/Compatibility56/Overrides.cpp
@@ -23,6 +23,7 @@
using namespace swift;
__asm__ (".linker_option \"-lc++\"");
+__asm__ (".linker_option \"-lc++abi\"");
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
Override_ ## name name;

View file

@ -35,14 +35,6 @@ let
# that can happen when a Swift application dynamically links different versions
# of libc++ and libc++abi than libraries it links are using.
inherit (llvmPackages) libcxx;
extraPackages = [
llvmPackages.libcxxabi
# Use the compiler-rt associated with clang, but use the libc++abi from the stdenv
# to avoid linking against two different versions (for the same reasons as above).
(swiftLlvmPackages.compiler-rt.override {
inherit (llvmPackages) libcxxabi;
})
];
}
else
swiftLlvmPackages.clang;

View file

@ -817,12 +817,5 @@ stdenv.mkDerivation ({
// lib.optionalAttrs (stdenv.hasCC && stdenv.cc.isClang) {
NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion";
}
# Ensure libc++abi is linked even when clang is invoked as just `clang` or `cc`.
# Works around https://github.com/NixOS/nixpkgs/issues/166205.
# This can be dropped once a fix has been committed to cc-wrapper.
// lib.optionalAttrs (stdenv.hasCC && stdenv.cc.isClang && stdenv.cc.libcxx != null) {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
}
)
)

View file

@ -48,7 +48,6 @@ stdenv.mkDerivation rec {
;
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-Wno-error=array-bounds";
env.NIX_LDFLAGS = lib.optionalString (stdenv.cc.libcxx != null) "-l${stdenv.cc.libcxx.cxxabi.libName}";
# Tries to link test binaries binaries dynamically and fails
doCheck = !stdenv.hostPlatform.isStatic;

View file

@ -32,11 +32,6 @@ stdenv.mkDerivation rec {
postPatch = ''
patchShebangs configure lds-gen.pl
'' + lib.optionalString (stdenv.cc.libcxx != null) ''
# fix for https://github.com/NixOS/nixpkgs/issues/166205
# llvm12+ isn't adding libc++abi
substituteInPlace src-cpp/Makefile \
--replace "LIBS += -lstdc++" "LIBS += -lc++ -l${stdenv.cc.libcxx.cxxabi.libName}"
'';
# Has a configure script but its not Autoconf so steal some bits from multiple-outputs.sh:

View file

@ -8,7 +8,6 @@
, CFNetwork
, cmake
, CoreFoundation
, libcxxabi
, openssl
, Security
, pytestCheckHook
@ -84,10 +83,6 @@ buildPythonPackage rec {
certifi
];
LDFLAGS = lib.optionals stdenv.isDarwin [
"-L${lib.getLib libcxxabi}/lib"
];
dontUseCmakeConfigure = true;
preCheck = ''

View file

@ -17,11 +17,6 @@ stdenv.mkDerivation rec {
makeFlags = [ "FLOW_RELEASE=1" ];
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
installPhase = ''
install -Dm755 bin/flow $out/bin/flow
install -Dm644 resources/shell/bash-completion $out/share/bash-completion/completions/flow

View file

@ -31,11 +31,6 @@ rustPlatform.buildRustPackage rec {
# rust-src and `-Z build-std=core` are required to properly run the tests
doCheck = false;
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
meta = with lib; {
description = "Simple BPF static linker";
homepage = "https://github.com/aya-rs/bpf-linker";

View file

@ -73,11 +73,6 @@ let
'' + lib.optionalString (stdenv.isDarwin) ''
--cxxopt=-x --cxxopt=c++ \
--host_cxxopt=-x --host_cxxopt=c++ \
'' + lib.optionalString (stdenv.cc.isClang && stdenv ? cc.libcxx.cxxabi.libName) ''
--linkopt=-Wl,-l${stdenv.cc.libcxx.cxxabi.libName} \
--linkopt=-L${stdenv.cc.libcxx.cxxabi}/lib \
--host_linkopt=-Wl,-l${stdenv.cc.libcxx.cxxabi.libName} \
--host_linkopt=-L${stdenv.cc.libcxx.cxxabi}/lib \
'' + lib.optionalString (stdenv.isDarwin && Foundation != null) ''
--linkopt=-Wl,-F${Foundation}/Library/Frameworks \
--linkopt=-L${darwin.libobjc}/lib \

View file

@ -258,8 +258,6 @@ stdenv.mkDerivation rec {
postPatch =
let
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
nixpkgs166205ldflag = lib.optionalString stdenv.cc.isClang "-l${stdenv.cc.libcxx.cxxabi.libName}";
darwinPatches = ''
bazelLinkFlags () {
eval set -- "$NIX_LDFLAGS"
@ -274,7 +272,7 @@ stdenv.mkDerivation rec {
# Framework search paths aren't added by bintools hook
# https://github.com/NixOS/nixpkgs/pull/41914
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks -F${IOKit}/Library/Frameworks ${nixpkgs166205ldflag}"
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks -F${IOKit}/Library/Frameworks"
# libcxx includes aren't added by libcxx hook
# https://github.com/NixOS/nixpkgs/pull/41589

View file

@ -157,11 +157,6 @@ let
--javabase='@local_jdk//:jdk' \
'' + lib.optionalString (stdenv.isDarwin) ''
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
'' + lib.optionalString (stdenv.cc.isClang && stdenv ? cc.libcxx.cxxabi.libName) ''
--linkopt=-Wl,-l${stdenv.cc.libcxx.cxxabi.libName} \
--linkopt=-L${stdenv.cc.libcxx.cxxabi}/lib \
--host_linkopt=-Wl,-l${stdenv.cc.libcxx.cxxabi.libName} \
--host_linkopt=-L${stdenv.cc.libcxx.cxxabi}/lib \
'' + ''
'';

View file

@ -7,8 +7,8 @@ sbt.overrideAttrs(previousAttrs: {
wrapProgram $out/bin/sbt \
--set CLANG_PATH "${llvmPackages.clang}/bin/clang" \
--set CLANGPP_PATH "${llvmPackages.clang}/bin/clang" \
--set CPATH "${lib.makeSearchPathOutput "dev" "include" [ re2 zlib boehmgc libunwind llvmPackages.libcxxabi llvmPackages.libcxx ]}/c++/v1" \
--set LIBRARY_PATH "${lib.makeLibraryPath [ re2 zlib boehmgc libunwind llvmPackages.libcxxabi llvmPackages.libcxx ]}" \
--set NIX_CFLAGS_LINK "-lc++abi -lc++"
--set CPATH "${lib.makeSearchPathOutput "dev" "include" [ re2 zlib boehmgc libunwind llvmPackages.libcxx ]}/c++/v1" \
--set LIBRARY_PATH "${lib.makeLibraryPath [ re2 zlib boehmgc libunwind llvmPackages.libcxx ]}" \
--set NIX_CFLAGS_LINK "-lc++"
'';
})

View file

@ -13,9 +13,6 @@ rustPlatform.buildRustPackage rec {
cargoSha256 = "sha256-6oZCpjQ8t/QLFhEtF7td8KGI/kFE04pg7OELutsrJKo=";
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; };
passthru.tests.version = testers.testVersion {
package = cbfmt;
};

View file

@ -31,11 +31,6 @@ rustPlatform.buildRustPackage {
cargoSha256 = "sha256-I5CfrLWVTUwOtZrje3eATFen5u9MEH79Rk30ZNhaG98=";
# Workaround for https://github.com/nixos/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
nativeBuildInputs = [
pkg-config
];

View file

@ -17,11 +17,6 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-NMSNCURSO1iIWHH27FI5Y0q7+Ghds8VSxRGBOp+fH6A=";
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs (stdenv.cc.libcxx != null) {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
doInstallCheck = true;
postInstallCheck = ''
$out/bin/beancount-language-server --help > /dev/null

View file

@ -43,11 +43,6 @@ stdenv.mkDerivation (finalAttrs: {
-e '/cxx_/s,$cc,clang++,'
'';
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
ninjaFlags = [
"-fcompile/ninja/${if stdenv.isDarwin then "macos" else "linux"}.ninja"
];

View file

@ -35,12 +35,7 @@ rustPlatform.buildRustPackage rec {
cargoBuildFlags = [ "-p" "topiary-cli" ];
cargoTestFlags = cargoBuildFlags;
env = {
TOPIARY_LANGUAGE_DIR = "${placeholder "out"}/share/queries";
} // lib.optionalAttrs stdenv.cc.isClang {
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
env.TOPIARY_LANGUAGE_DIR = "${placeholder "out"}/share/queries";
postInstall = ''
install -Dm444 queries/* -t $out/share/queries

View file

@ -122,11 +122,6 @@ in stdenv.mkDerivation {
outputs = [ "out" "installer" ];
setOutputFlags = false;
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# change argv0 to "opam" as a workaround for
# https://github.com/ocaml/opam/issues/2142
postInstall = ''

View file

@ -112,11 +112,6 @@ print <<'EOF';
outputs = [ "out" "installer" ];
setOutputFlags = false;
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# change argv0 to "opam" as a workaround for
# https://github.com/ocaml/opam/issues/2142
postInstall = ''

View file

@ -12,11 +12,6 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-axrtFZQOm1/UUBq1CDFkaZCks1mWoLWmfajDfsqSBmY=";
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
meta = with lib; {
description = "Analyze and collect metrics on source code";
homepage = "https://github.com/mozilla/rust-code-analysis";

View file

@ -7,7 +7,6 @@ let
if packages.stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion packages.stdenv.cc.cc) "16"
then overrideCC packages.llvmPackages_15.stdenv (packages.llvmPackages_15.stdenv.cc.override {
inherit (packages.llvmPackages) libcxx;
extraPackages = [ packages.llvmPackages.libcxxabi ];
})
else packages.stdenv;

View file

@ -34,7 +34,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
--replace "-Werror " ""
substituteInPlace SETUP/kextsymboltool/Makefile \
--replace "-lstdc++" "-lc++ -lc++abi"
--replace "-lstdc++" "-lc++"
substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
--replace "/usr/include" "/include" \

View file

@ -40,15 +40,12 @@ stdenv.mkDerivation (finalAttrs: {
let
nativeCC = pkgsBuildBuild.stdenv.cc;
nativeBintools = nativeCC.bintools.bintools;
nativeLibcxxabi = lib.getLib pkgsBuildBuild.libcxxabi;
nativeToolchainFlags = [
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
"-DCMAKE_EXE_LINKER_FLAGS=-L${nativeLibcxxabi}/lib"
"-DCMAKE_SHARED_LINKER_FLAGS=-L${nativeLibcxxabi}/lib"
];
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
)

View file

@ -46,8 +46,6 @@ rustPlatform.buildRustPackage rec {
OPENSSL_NO_VENDOR = 1;
} // lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-faligned-allocation";
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
passthru = {

View file

@ -28,8 +28,6 @@ rustPlatform.buildRustPackage rec {
rustPlatform.bindgenHook
];
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env.NIX_LDFLAGS = lib.optionalString stdenv.cc.isClang "-l${stdenv.cc.libcxx.cxxabi.libName}";
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-faligned-allocation";
postPatch = ''

View file

@ -35,9 +35,7 @@ stdenv.mkDerivation rec {
dontDisableStatic = true;
# postgis config directory assumes /include /lib from the same root for json-c library
NIX_LDFLAGS = "-L${lib.getLib json_c}/lib"
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
+ lib.optionalString (stdenv.cc.isClang && stdenv.cc.libcxx != null) " -l${stdenv.cc.libcxx.cxxabi.libName}";
env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
preConfigure = ''

View file

@ -50,19 +50,18 @@ rec {
# because older compilers may not be able to parse the headers from the default stdenvs libc++.
overrideLibcxx = stdenv:
assert stdenv.cc.libcxx != null;
assert pkgs.stdenv.cc.libcxx != null;
# only unified libcxx / libcxxabi stdenv's are supported
assert lib.versionAtLeast pkgs.stdenv.cc.libcxx.version "12";
assert lib.versionAtLeast stdenv.cc.libcxx.version "12";
let
llvmLibcxxVersion = lib.getVersion llvmLibcxx;
stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;
stdenvLibcxx = pkgs.stdenv.cc.libcxx;
stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;
llvmLibcxx = stdenv.cc.libcxx;
llvmCxxabi = stdenv.cc.libcxx.cxxabi;
libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit cxxabi;
isLLVM = true;
} ''
mkdir -p "$dev/nix-support"
@ -70,21 +69,10 @@ rec {
echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
'';
cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
outputs = [ "out" "dev" ];
inherit (stdenvCxxabi) libName;
} ''
mkdir -p "$dev/nix-support"
ln -s '${stdenvCxxabi}' "$out"
echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
'';
in
overrideCC stdenv (stdenv.cc.override {
inherit libcxx;
extraPackages = [
cxxabi
pkgs.buildPackages.targetPackages."llvmPackages_${lib.versions.major llvmLibcxxVersion}".compiler-rt
];
});

View file

@ -81,7 +81,6 @@ let
};
extraPackages = [
prevStage.llvmPackages.libcxxabi
prevStage.llvmPackages.compiler-rt
];
@ -196,7 +195,6 @@ in
clang-unwrapped = null;
libllvm = null;
libcxx = null;
libcxxabi = null;
compiler-rt = null;
};
})
@ -346,18 +344,6 @@ in
'';
passthru = {
isLLVM = true;
cxxabi = self.llvmPackages.libcxxabi;
isFromBootstrapFiles = true;
};
};
libcxxabi = self.stdenv.mkDerivation {
name = "bootstrap-stage0-libcxxabi";
buildCommand = ''
mkdir -p $out/lib
ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib
'';
passthru = {
libName = "c++abi";
isFromBootstrapFiles = true;
};
};
@ -413,7 +399,7 @@ in
assert (with prevStage.darwin; (! useAppleSDKLibs) -> CF == null);
assert lib.all isFromBootstrapFiles (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm compiler-rt libcxx libcxxabi
clang-unwrapped libclang libllvm llvm compiler-rt libcxx
]);
stageFun prevStage {
@ -480,7 +466,7 @@ in
inherit (prevStage.llvmPackages) clang-unwrapped libclang libllvm llvm;
});
libraries = super.llvmPackages.libraries.extend (_: _: {
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit tools libraries; inherit (prevStage.llvmPackages) release_version; } // tools // libraries
@ -526,7 +512,7 @@ in
assert lib.all isFromNixpkgs (with prevStage.darwin; [ dyld launchd xnu ]);
assert lib.all isFromBootstrapFiles (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm compiler-rt libcxx libcxxabi
clang-unwrapped libclang libllvm llvm compiler-rt libcxx
]);
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == "boot";
@ -580,7 +566,7 @@ in
clang = prevStage.stdenv.cc;
});
libraries = super.llvmPackages.libraries.extend (_: _: {
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit tools libraries; inherit (prevStage.llvmPackages) release_version; } // tools // libraries
@ -626,7 +612,7 @@ in
assert lib.all isFromNixpkgs (with prevStage.darwin; [ dyld launchd xnu ]);
assert lib.all isFromBootstrapFiles (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm compiler-rt libcxx libcxxabi
clang-unwrapped libclang libllvm llvm compiler-rt libcxx
]);
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == lib.getVersion prevStage.darwin.cctools-port;
@ -670,17 +656,8 @@ in
libraries = super.llvmPackages.libraries.extend (selfLib: superLib: {
compiler-rt = null;
libcxx = superLib.libcxx.override ({
inherit (selfLib) libcxxabi;
stdenv = libcxxBootstrapStdenv;
});
libcxxabi = superLib.libcxxabi.override {
stdenv = libcxxBootstrapStdenv;
}
# Setting `standalone = true` is only needed with older verions of LLVM. Newer ones
# automatically do what is necessary to bootstrap lib++abi.
// lib.optionalAttrs (builtins.any (v: llvmMajor == v) [ "7" "11" "12" "13" ]) {
standalone = true;
};
});
in
{ inherit libraries; } // libraries
@ -726,7 +703,7 @@ in
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm
]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx libcxxabi ]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx ]);
assert prevStage.llvmPackages.compiler-rt == null;
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == lib.getVersion prevStage.darwin.cctools-port;
@ -763,7 +740,7 @@ in
});
libraries = super.llvmPackages.libraries.extend (selfLib: superLib: {
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit tools libraries; inherit (prevStage.llvmPackages) release_version; } // tools // libraries
@ -779,7 +756,6 @@ in
in
self.overrideCC stdenvNoCF (self.llvmPackages.clangNoCompilerRtWithLibc.override {
inherit (self.llvmPackages) libcxx;
extraPackages = [ self.llvmPackages.libcxxabi ];
});
};
@ -827,7 +803,7 @@ in
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm
]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx libcxxabi ]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx ]);
assert prevStage.llvmPackages.compiler-rt == null;
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == lib.getVersion prevStage.darwin.cctools-llvm;
@ -874,12 +850,11 @@ in
});
libraries = super.llvmPackages.libraries.extend (selfLib: superLib: {
inherit (prevStage.llvmPackages) libcxx libcxxabi;
inherit (prevStage.llvmPackages) libcxx;
# Make sure compiler-rt is linked against the CF from this stage, which can be
# propagated to the final stdenv. CF is required by ASAN.
compiler-rt = superLib.compiler-rt.override ({
inherit (selfLib) libcxxabi;
inherit (self.llvmPackages) libllvm;
stdenv = self.stdenv.override {
extraBuildInputs = [ self.darwin.CF ];
@ -907,8 +882,6 @@ in
bintools = self.llvmPackages.clangNoCompilerRtWithLibc.bintools.override {
libc = self.darwin.Libsystem;
};
extraPackages = [ self.llvmPackages.libcxxabi ];
});
};
@ -924,7 +897,7 @@ in
# Rebuild LLVM with LLVM. This stage also rebuilds certain dependencies needed by LLVM.
#
# LLVM requires: libcxx libcxxabi libffi libiconv libxml2 ncurses zlib
# LLVM requires: libcxx libffi libiconv libxml2 ncurses zlib
(prevStage:
# previous stage2-CF stdenv:
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage; [
@ -954,7 +927,7 @@ in
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm
]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx libcxxabi ]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [ libcxx ]);
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == lib.getVersion prevStage.darwin.cctools-llvm;
@ -986,7 +959,7 @@ in
llvmPackages = super.llvmPackages // (
let
libraries = super.llvmPackages.libraries.extend (_: _: {
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit libraries; } // libraries
@ -1033,7 +1006,7 @@ in
assert lib.all isFromNixpkgs (with prevStage.darwin; [ dyld launchd libclosure libdispatch xnu ]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm compiler-rt libcxx libcxxabi
clang-unwrapped libclang libllvm llvm compiler-rt libcxx
]);
assert lib.getVersion prevStage.stdenv.cc.bintools.bintools == lib.getVersion prevStage.darwin.cctools-llvm;
@ -1117,7 +1090,6 @@ in
};
extraPackages = [
self.llvmPackages.libcxxabi
self.llvmPackages.compiler-rt
];
@ -1158,7 +1130,7 @@ in
};
});
libraries = super.llvmPackages.libraries.extend (_: _:{
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit tools libraries; } // tools // libraries
@ -1200,7 +1172,7 @@ in
assert lib.all isFromNixpkgs (with prevStage.darwin; [ dyld launchd libclosure libdispatch xnu ]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.llvmPackages; [
clang-unwrapped libclang libllvm llvm compiler-rt libcxx libcxxabi
clang-unwrapped libclang libllvm llvm compiler-rt libcxx
]);
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage; [
@ -1312,8 +1284,6 @@ in
compiler-rt.dev
libcxx
libcxx.dev
libcxxabi
libcxxabi.dev
lld
llvm
llvm.lib
@ -1356,7 +1326,7 @@ in
inherit (prevStage.llvmPackages) clang clang-unwrapped libclang libllvm llvm;
});
libraries = super.llvmPackages.libraries.extend (_: _: {
inherit (prevStage.llvmPackages) compiler-rt libcxx libcxxabi;
inherit (prevStage.llvmPackages) compiler-rt libcxx;
});
in
{ inherit tools libraries; } // tools // libraries
@ -1382,7 +1352,6 @@ in
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.clang-unwrapped;
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.libllvm;
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.libcxx;
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.libcxxabi;
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.compiler-rt;
{ inherit (prevStage) config overlays stdenv; })
]

View file

@ -116,7 +116,11 @@ rec {
cp -rd ${lib.getLib llvmPackages.clang-unwrapped}/lib/* $out/lib
cp -d ${lib.getLib llvmPackages.libcxx}/lib/libc++*.dylib $out/lib
''
# libc++abi is contained in libcxx for LLVM12+. Remove once unpinned from LLVM11
+ lib.optionalString (llvmPackages ? libcxxabi) ''
cp -d ${lib.getLib llvmPackages.libcxxabi}/lib/libc++abi*.dylib $out/lib
'' + ''
cp -d ${lib.getLib llvmPackages.compiler-rt}/lib/darwin/libclang_rt* $out/lib/darwin
cp -d ${lib.getLib llvmPackages.compiler-rt}/lib/libclang_rt* $out/lib
cp -d ${lib.getLib llvmPackages.llvm.lib}/lib/libLLVM.dylib $out/lib

View file

@ -19,6 +19,11 @@ updateInstallName() {
cp "$path" "$path.new"
install_name_tool -id "$path" "$path.new"
# workaround for https://github.com/NixOS/nixpkgs/issues/294518
# libc++.1.0.dylib contains wrong LC_RPATH
if [[ ${path} == *libc++.1.0.dylib ]]; then
install_name_tool -add_rpath @loader_path/.. "${path}.new"
fi
codesign -f -i "$(basename "$path")" -s - "$path.new"
mv -f "$path.new" "$path"
}

View file

@ -50,12 +50,6 @@ stdenv.mkDerivation rec {
lib.optionals stdenv.isLinux [ gnustep.make ] ++
lib.optionals stdenv.isDarwin [ xcbuildHook ];
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
# xcbuild links with clang instead of clang++.
env = lib.optionalAttrs stdenv.isDarwin {
LD_FLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
xcbuildFlags = lib.optionals stdenv.isDarwin [
"-target unar"
"-target lsar"

View file

@ -39,9 +39,7 @@ rustPlatform.buildRustPackage rec {
installShellCompletion artifacts/ouch.{bash,fish} --zsh artifacts/_ouch
'';
env = { OUCH_ARTIFACTS_FOLDER = "artifacts"; } //
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
lib.optionalAttrs stdenv.cc.isClang { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; };
env.OUCH_ARTIFACTS_FOLDER = "artifacts";
meta = with lib; {
description = "A command-line utility for easily compressing and decompressing files and directories";

View file

@ -10,7 +10,6 @@
, gtk-sharp-2_0
, gtk2
, libcxx
, libcxxabi
, coreutils
, requireFile
, archive ? requireFile {
@ -42,7 +41,6 @@ stdenv.mkDerivation rec {
gtk-sharp-2_0
gtk2
libcxx
libcxxabi
];
installPhase = ''

View file

@ -33,11 +33,6 @@ rustPlatform.buildRustPackage rec {
nixVersions.nix_2_19
];
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
passthru = {
updateScript = nix-update-script {
extraArgs = [ "--version-regex" "harmonia-v(.*)" ];

View file

@ -34,11 +34,6 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [ pkg-config rustPlatform.bindgenHook ];
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
meta = with lib; {
description = "A tool to determine which gc-roots take space in your nix store";
homepage = "https://github.com/symphorien/nix-du";

Some files were not shown because too many files have changed in this diff Show more