2021-05-11 21:12:04 +00:00
|
|
|
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
|
2020-12-20 06:11:26 +00:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
2019-09-19 18:19:41 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2021-05-11 19:43:21 +00:00
|
|
|
pname = "libcxxabi";
|
2019-09-19 18:19:41 +00:00
|
|
|
inherit version;
|
|
|
|
|
2019-12-31 20:53:24 +00:00
|
|
|
src = fetch "libcxxabi" "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8";
|
2019-09-19 18:19:41 +00: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 08:23:57 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
2019-09-19 18:19:41 +00:00
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
unpackFile ${libcxx.src}
|
|
|
|
unpackFile ${llvm.src}
|
|
|
|
cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
|
2021-01-22 11:25:31 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2019-09-19 18:19:41 +00:00
|
|
|
export TRIPLE=x86_64-apple-darwin
|
2021-01-22 11:25:31 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
|
2021-04-15 10:15:07 +00:00
|
|
|
patch -p1 -d $(ls -d libcxx-*) -i ${../../libcxx-0001-musl-hacks.patch}
|
2021-01-22 11:25:31 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
|
2021-03-24 01:40:33 +00:00
|
|
|
patch -p1 -d $(ls -d llvm-*) -i ${./wasm.patch}
|
2019-09-19 18:19:41 +00: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 08:23:57 +00: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-09-19 18:19:41 +00: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 13:37:25 +00:00
|
|
|
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
|
2019-09-19 18:19:41 +00: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 11:25:31 +00:00
|
|
|
'' + lib.optionalString enableShared ''
|
2019-09-19 18:19:41 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2021-05-11 21:12:04 +00:00
|
|
|
meta = llvm_meta // {
|
2020-04-13 16:50:35 +00:00
|
|
|
homepage = "https://libcxxabi.llvm.org/";
|
2021-05-11 21:12:04 +00: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-09-19 18:19:41 +00:00
|
|
|
};
|
|
|
|
}
|