2021-05-11 14:12:04 -07:00
|
|
|
{ lib, stdenv, llvm_meta, fetch, fetchpatch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
|
2020-12-19 22:11:26 -08:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
2020-08-25 10:29:57 -07:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2021-05-11 12:43:21 -07:00
|
|
|
pname = "libcxx";
|
2020-08-25 10:29:57 -07:00
|
|
|
inherit version;
|
|
|
|
|
2021-02-17 12:39:09 -08:00
|
|
|
src = fetch "libcxx" "1rgqsqpgi0vkga5d7hy0iyfsqgzfz7q1xy7afdfa1snp1qjks8xv";
|
2020-08-25 10:29:57 -07:00
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
unpackFile ${libcxxabi.src}
|
2020-10-07 14:29:47 -07:00
|
|
|
mv libcxxabi-* libcxxabi
|
|
|
|
unpackFile ${llvm.src}
|
|
|
|
mv llvm-* llvm
|
2020-08-25 10:29:57 -07: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 01:23:57 -07:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-02-27 15:09:52 -08:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# Backported from LLVM 12, avoids clashes with commonly used "block.h" header.
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/19bc9ea480b60b607a3e303f20c7a3a2ea553369.patch";
|
|
|
|
sha256 = "sha256-aWa66ogmPkG0xHzSfcpD0qZyZQcNKwLV44js4eiun78=";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
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 01:23:57 -07:00
|
|
|
./gnu-install-dirs.patch
|
2021-05-11 14:12:04 -07:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isMusl [
|
|
|
|
../../libcxx-0001-musl-hacks.patch
|
|
|
|
];
|
2020-08-25 10:29:57 -07:00
|
|
|
|
2020-10-07 14:29:47 -07:00
|
|
|
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
|
2020-08-25 10:29:57 -07:00
|
|
|
patchShebangs utils/cat_files.py
|
|
|
|
'';
|
|
|
|
|
2020-10-07 14:29:47 -07:00
|
|
|
nativeBuildInputs = [ cmake python3 ]
|
|
|
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
|
|
|
|
|
|
|
|
buildInputs = [ libcxxabi ];
|
2020-08-25 10:29:57 -07:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DLIBCXX_CXX_ABI=libcxxabi"
|
2021-01-22 03:25:31 -08:00
|
|
|
] ++ 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.optional stdenv.hostPlatform.isWasm [
|
2020-08-25 10:29:57 -07:00
|
|
|
"-DLIBCXX_ENABLE_THREADS=OFF"
|
|
|
|
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
|
|
|
|
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
|
2021-05-15 21:24:52 -07:00
|
|
|
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
|
|
|
|
|
|
|
|
# TODO: this is a bit of a hack to cross compile to Apple Silicon. libcxx
|
|
|
|
# starting with 11 enables CMAKE_BUILD_WITH_INSTALL_NAME_DIR which requires
|
|
|
|
# platform setup for rpaths. In cmake, this is enabled when macos is newer
|
|
|
|
# than 10.5. However CMAKE_SYSTEM_VERSION is set to empty (TODO: why?)
|
|
|
|
# which prevents the conditional configuration, and configure fails. The
|
|
|
|
# value here corresponds to `uname -r`. If stdenv.hostPlatform.release is
|
|
|
|
# not null, then this property will be set via mkDerivation (TODO: how can
|
|
|
|
# we set this?).
|
|
|
|
++ lib.optional (
|
|
|
|
stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 &&
|
|
|
|
stdenv.hostPlatform != stdenv.buildPlatform
|
|
|
|
) "-DCMAKE_SYSTEM_VERSION=20.1.0";
|
2020-08-25 10:29:57 -07:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
isLLVM = true;
|
|
|
|
};
|
|
|
|
|
2021-05-11 14:12:04 -07:00
|
|
|
meta = llvm_meta // {
|
2020-08-25 10:29:57 -07:00
|
|
|
homepage = "https://libcxx.llvm.org/";
|
2021-05-11 14:12:04 -07:00
|
|
|
description = "C++ standard library";
|
|
|
|
longDescription = ''
|
|
|
|
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 ];
|
2020-08-25 10:29:57 -07:00
|
|
|
};
|
|
|
|
}
|