llvmPackages_12.libcxxabi: Align with 11 libcxxabi

LLVM 11 libcxxabi has some flags to support usage in the Darwin stdenv,
in particular, `standalone` and `withLibunwind`.

Darwin stdenv needs the `standalone` flag because its `hostPlatform` set
doesn't have `useLLVM` set to true. And it needs `withLibunwind` to
explicitly disable including `libunwind` as a build input.

We also prefix `install_name_tool` in case we're cross-compiling.
This commit is contained in:
toonn 2021-11-15 16:12:37 +01:00 committed by Jonathan Ringer
parent d964f211f6
commit d90fb1c038

View file

@ -1,5 +1,7 @@
{ lib, stdenv, llvm_meta, cmake, python3, fetch, libcxx, libunwind, llvm, version { lib, stdenv, llvm_meta, cmake, python3, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic , enableShared ? !stdenv.hostPlatform.isStatic
, standalone ? stdenv.hostPlatform.useLLVM or false
, withLibunwind ? !stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
@ -28,9 +30,9 @@ stdenv.mkDerivation {
]; ];
nativeBuildInputs = [ cmake python3 ]; nativeBuildInputs = [ cmake python3 ];
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; buildInputs = lib.optional withLibunwind libunwind;
cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [ cmakeFlags = lib.optionals standalone [
"-DLLVM_ENABLE_LIBCXX=ON" "-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON" "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optionals stdenv.hostPlatform.isWasm [ ] ++ lib.optionals stdenv.hostPlatform.isWasm [
@ -47,7 +49,7 @@ stdenv.mkDerivation {
# the magic combination of necessary CMake variables # the magic combination of necessary CMake variables
# if you fancy a try, take a look at # if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
install_name_tool -id $out/$file $file ${stdenv.cc.targetPrefix}install_name_tool -id $out/$file $file
done done
make install make install
install -d 755 $out/include install -d 755 $out/include