2021-05-11 23:12:04 +02:00
|
|
|
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
|
2020-12-20 07:11:26 +01:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
2019-02-28 19:01:31 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2021-05-11 21:43:21 +02:00
|
|
|
pname = "libcxxabi";
|
2019-08-13 23:52:01 +02:00
|
|
|
inherit version;
|
2019-02-28 19:01:31 +01:00
|
|
|
|
2019-08-06 01:32:16 +02:00
|
|
|
src = fetch "libcxxabi" "1vznz8n1z1h8af0ga451m98lc2hjnv4fyzl71napsvjhvk4g6nxp";
|
2019-02-28 19:01:31 +01:00
|
|
|
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 10:23:57 +02:00
|
|
|
outputs = [ "out" "dev" ];
|
2019-01-30 03:01:24 +01:00
|
|
|
|
2019-02-28 19:01:31 +01:00
|
|
|
postUnpack = ''
|
|
|
|
unpackFile ${libcxx.src}
|
|
|
|
unpackFile ${llvm.src}
|
2019-04-12 02:51:48 +02:00
|
|
|
cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
|
2021-01-22 12:25:31 +01:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2019-02-28 19:01:31 +01:00
|
|
|
export TRIPLE=x86_64-apple-darwin
|
2021-01-22 12:25:31 +01:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
|
2021-04-15 12:15:07 +02:00
|
|
|
patch -p1 -d $(ls -d libcxx-*) -i ${../../libcxx-0001-musl-hacks.patch}
|
2021-01-22 12:25:31 +01:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
|
2021-03-24 02:40:33 +01:00
|
|
|
patch -p1 -d $(ls -d llvm-*) -i ${./wasm.patch}
|
2019-02-28 19:01:31 +01:00
|
|
|
'';
|
|
|
|
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 10:23:57 +02:00
|
|
|
patches = [
|
|
|
|
./no-threads.patch
|
|
|
|
./gnu-install-dirs.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
|
|
|
|
|
|
|
|
cmakeFlags = 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"
|
|
|
|
];
|
|
|
|
|
2019-02-28 19:01:31 +01:00
|
|
|
installPhase = if stdenv.isDarwin
|
|
|
|
then ''
|
|
|
|
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
|
2020-02-25 14:37:25 +01:00
|
|
|
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
|
2019-02-28 19:01:31 +01:00
|
|
|
install_name_tool -id $out/$file $file
|
|
|
|
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
|
2021-01-22 12:25:31 +01:00
|
|
|
'' + lib.optionalString enableShared ''
|
2019-01-30 03:01:24 +01:00
|
|
|
install -m 644 lib/libc++abi.so.1.0 $out/lib
|
2019-02-28 19:01:31 +01:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2021-05-11 23:12:04 +02:00
|
|
|
meta = llvm_meta // {
|
2020-04-13 18:50:35 +02:00
|
|
|
homepage = "https://libcxxabi.llvm.org/";
|
2021-05-11 23:12:04 +02:00
|
|
|
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 ];
|
2019-02-28 19:01:31 +01:00
|
|
|
};
|
|
|
|
}
|