Merge pull request #122655 from Ericson2314/bootstrapping-consistency

treewide: Some LLVM / bootstrapping / cross cleanups especially for consistency
This commit is contained in:
John Ericson 2021-05-11 23:32:32 -04:00 committed by GitHub
commit d63b57ef34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
112 changed files with 1809 additions and 809 deletions

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -96,11 +96,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -119,6 +128,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,17 +1,18 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation rec {
pname = "compiler-rt";
stdenv.mkDerivation {
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch pname "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr";
src = fetch "compiler-rt" "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr";
nativeBuildInputs = [ cmake python3 llvm.dev ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM && !haveLibc) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
@ -58,7 +60,6 @@ stdenv.mkDerivation rec {
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
@ -89,4 +90,19 @@ stdenv.mkDerivation rec {
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -16,6 +17,12 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
@ -31,14 +38,16 @@ let
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
@ -82,9 +91,13 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
@ -93,7 +106,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -112,6 +134,8 @@ let
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
@ -120,9 +144,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -136,10 +158,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -152,49 +171,74 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libc++abi ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,9 +1,9 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0v78bfr6h2zifvdqnj2wlfk4pvxzrqn3hg1v6lqk3y12bx9p9xny";
@ -17,7 +17,9 @@ stdenv.mkDerivation {
patches = [
./gnu-install-dirs.patch
] ++ lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
preConfigure = ''
# Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
@ -47,10 +49,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
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 ];
};
}

View file

@ -1,9 +1,9 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "0yqs722y76cwvmfsq0lb917r9m3fci7bf5z3yzl71yz9n88ghzm9";
@ -63,11 +63,15 @@ stdenv.mkDerivation {
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.all;
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,4 +1,4 @@
{ lib, stdenv, version, fetch, cmake, fetchpatch
{ lib, stdenv, llvm_meta, version, fetch, cmake, fetchpatch
, enableShared ? !stdenv.hostPlatform.isStatic
}:
@ -17,4 +17,16 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -28,10 +28,16 @@ stdenv.mkDerivation rec {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
WebAssembly in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, cmake
, zlib
@ -76,11 +76,15 @@ stdenv.mkDerivation (rec {
ln -s $out/bin/llvm-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://lldb.llvm.org";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "lldb-manpages";
@ -104,5 +108,7 @@ stdenv.mkDerivation (rec {
doCheck = false;
meta.description = "man pages for LLDB ${version}";
meta = llvm_meta // {
description = "man pages for LLDB ${version}";
};
})

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, cmake
@ -172,12 +172,23 @@ in stdenv.mkDerivation (rec {
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -199,5 +210,7 @@ in stdenv.mkDerivation (rec {
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,25 +0,0 @@
{ lib
, stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation rec {
pname = "openmp";
inherit version;
src = fetch pname "0i4bn84lkpm5w3qkpvwm5z6jdj8fynp7d3bcasa1xyq4is6757yi";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,34 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation rec {
pname = "openmp";
inherit version;
src = fetch pname "0i4bn84lkpm5w3qkpvwm5z6jdj8fynp7d3bcasa1xyq4is6757yi";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -95,11 +95,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -118,6 +127,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,17 +1,18 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation rec {
pname = "compiler-rt";
stdenv.mkDerivation {
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch pname "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy";
src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy";
nativeBuildInputs = [ cmake python3 llvm.dev ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM && !haveLibc) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
@ -59,7 +61,6 @@ stdenv.mkDerivation rec {
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
@ -92,4 +93,19 @@ stdenv.mkDerivation rec {
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -18,6 +19,12 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "18n1w1hkv931xzq02b34wglbv6zd6sd0r5kb8piwvag7klj7qw3n";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
@ -33,14 +40,16 @@ let
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
@ -83,9 +92,13 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
@ -94,7 +107,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -113,6 +135,8 @@ let
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
@ -121,9 +145,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -137,10 +159,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -153,49 +172,74 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libc++abi ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,9 +1,9 @@
{ lib, stdenv, fetch, fetchpatch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
{ lib, stdenv, llvm_meta, fetch, fetchpatch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "1rgqsqpgi0vkga5d7hy0iyfsqgzfz7q1xy7afdfa1snp1qjks8xv";
@ -25,7 +25,9 @@ stdenv.mkDerivation {
stripLen = 1;
})
./gnu-install-dirs.patch
] ++ lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
@ -50,10 +52,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
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 ];
};
}

View file

@ -1,9 +1,9 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "1azcf31mxw59hb1x17xncnm3dyw90ylh8rqx462lvypqh3nr6c8l";
@ -64,11 +64,15 @@ stdenv.mkDerivation {
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.all;
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,4 +1,4 @@
{ lib, stdenv, version, fetch, cmake, fetchpatch
{ lib, stdenv, llvm_meta, version, fetch, cmake, fetchpatch
, enableShared ? !stdenv.hostPlatform.isStatic
}:
@ -17,4 +17,16 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -28,10 +28,16 @@ stdenv.mkDerivation rec {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
WebAssembly in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, cmake
, zlib
@ -76,11 +76,15 @@ stdenv.mkDerivation (rec {
ln -s $out/bin/llvm-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://lldb.llvm.org";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "lldb-manpages";
@ -104,5 +108,7 @@ stdenv.mkDerivation (rec {
doCheck = false;
meta.description = "man pages for LLDB ${version}";
meta = llvm_meta // {
description = "man pages for LLDB ${version}";
};
})

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, cmake
@ -174,12 +174,23 @@ in stdenv.mkDerivation (rec {
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -201,5 +212,7 @@ in stdenv.mkDerivation (rec {
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,35 +0,0 @@
{ lib
, stdenv
, fetch
, fetchpatch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation rec {
pname = "openmp";
inherit version;
src = fetch pname "0bh5cswgpc79awlq8j5i7hp355adaac7s6zaz0zwp6mkflxli1yi";
patches = [
# Fix compilation on aarch64-darwin, remove after the next release.
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/7b5254223acbf2ef9cd278070c5a84ab278d7e5f.patch";
sha256 = "sha256-A+9/IVIoazu68FK5H5CiXcOEYe1Hpp4xTx2mIw7m8Es=";
stripLen = 1;
})
];
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,44 @@
{ lib
, stdenv
, llvm_meta
, fetch
, fetchpatch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation rec {
pname = "openmp";
inherit version;
src = fetch pname "0bh5cswgpc79awlq8j5i7hp355adaac7s6zaz0zwp6mkflxli1yi";
patches = [
# Fix compilation on aarch64-darwin, remove after the next release.
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/7b5254223acbf2ef9cd278070c5a84ab278d7e5f.patch";
sha256 = "sha256-A+9/IVIoazu68FK5H5CiXcOEYe1Hpp4xTx2mIw7m8Es=";
stripLen = 1;
})
];
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -9,7 +9,7 @@ let
in
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch "compiler-rt" "0d444qihq9jhqnfv003cr704v363va72zl6qaw2algj1c85cva45";
@ -61,7 +61,6 @@ stdenv.mkDerivation rec {
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -95,7 +96,6 @@ let
lld = callPackage ./lld {
inherit llvm_meta;
libunwind = libraries.libunwind;
};
lldb = callPackage ./lldb {
@ -112,7 +112,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -141,9 +150,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -157,10 +164,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -173,10 +177,7 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
@ -186,9 +187,7 @@ let
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
@ -199,15 +198,19 @@ let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc;
}));
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
@ -218,24 +221,31 @@ let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libcxx ({ inherit llvm_meta; } //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libcxxabi ({ inherit llvm_meta; } //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp { inherit llvm_meta; };
libunwind = callPackage ./libunwind ({ inherit llvm_meta; } //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind {
inherit llvm_meta;
inherit (buildLlvmTools) llvm;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -15,7 +15,13 @@ stdenv.mkDerivation {
mv llvm-* llvm
'';
patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py

View file

@ -0,0 +1,100 @@
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

@ -8,18 +8,7 @@ stdenv.mkDerivation {
src = fetch "libcxxabi" "1cbmzspwjlr8f6sp73pw6ivf4dpg6rpc61by0q1m2zca2k6yif3a";
nativeBuildInputs = [ cmake python3 ];
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"
];
outputs = [ "out" "dev" ];
postUnpack = ''
unpackFile ${libcxx.src}
@ -34,6 +23,23 @@ stdenv.mkDerivation {
patch -p1 -d llvm -i ${./wasm.patch}
'';
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake python3 ];
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"
];
installPhase = if stdenv.isDarwin
then ''
for file in lib/*.dylib; do

View file

@ -0,0 +1,34 @@
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

@ -18,6 +18,13 @@ stdenv.mkDerivation rec {
./gnu-install-dirs.patch
];
postPatch = ''
substituteInPlace MachO/CMakeLists.txt --replace \
'(''${LLVM_MAIN_SRC_DIR}/' '('
mkdir -p libunwind/include
tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
'';
nativeBuildInputs = [ cmake ];
buildInputs = [ libllvm libxml2 ];
@ -29,13 +36,6 @@ stdenv.mkDerivation rec {
outputs = [ "out" "lib" "dev" ];
postPatch = ''
substituteInPlace MachO/CMakeLists.txt --replace \
'(''${LLVM_MAIN_SRC_DIR}/' '('
mkdir -p libunwind/include
tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
'';
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS) and
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
WebAssembly in descending order of completeness. Internally, LLD consists
of several different linkers.
'';

View file

@ -205,6 +205,8 @@ in stdenv.mkDerivation (rec {
make docs-llvm-man
'';
propagatedBuildInputs = [];
installPhase = ''
make -C docs install
'';

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -88,11 +88,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -111,6 +120,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,4 +1,4 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
@ -86,4 +86,19 @@ stdenv.mkDerivation {
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -16,30 +16,41 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
'';
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libllvm-polly = callPackage ./llvm { enablePolly = true; };
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
@ -76,26 +87,38 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt {};
compiler-rt = callPackage ./compiler-rt {
inherit llvm_meta;
};
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ {};
libcxx = callPackage ./libcxx {
inherit llvm_meta;
};
libcxxabi = callPackage ./libc++abi {};
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
};
openmp = callPackage ./openmp.nix {};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,7 +1,7 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "1672aaf95fgy4xsfra8pw24f6r93zwzpan1033hkcm8p2glqipvf";
@ -45,10 +45,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.unix;
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 ];
};
}

View file

@ -1,7 +1,7 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version }:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "12lp799rskr4fc2xr64qn4jfkjnfd8b1aymvsxyn4k9ar7r9pgqv";
@ -47,11 +47,15 @@ stdenv.mkDerivation {
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.unix;
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,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -6,7 +6,7 @@
, version
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
@ -27,11 +27,16 @@ stdenv.mkDerivation {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
badPlatforms = [ "x86_64-darwin" ];
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), and Mach-O (macOS)
in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, fetchpatch
, cmake
@ -73,10 +73,14 @@ stdenv.mkDerivation rec {
cp ../docs/lldb.1 $out/share/man/man1/
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://llvm.org/";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, fetchpatch
@ -173,12 +173,23 @@ stdenv.mkDerivation ({
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -197,5 +208,7 @@ stdenv.mkDerivation ({
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,25 +0,0 @@
{ lib
, stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0p2n52676wlq6y9q99n5pivq6pvvda1p994r69fxj206ahn59jir";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,34 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0p2n52676wlq6y9q99n5pivq6pvvda1p994r69fxj206ahn59jir";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -88,11 +88,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -111,6 +120,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,4 +1,4 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
@ -88,4 +88,19 @@ stdenv.mkDerivation {
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -16,30 +16,41 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "1w8ml7fyn4vyxmy59n2qm4r1k1kgwgwkaldp6m45fdv4g0kkfbhd";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
'';
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libllvm-polly = callPackage ./llvm { enablePolly = true; };
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
@ -77,26 +88,38 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt {};
compiler-rt = callPackage ./compiler-rt {
inherit llvm_meta;
};
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ {};
libcxx = callPackage ./libcxx {
inherit llvm_meta;
};
libcxxabi = callPackage ./libc++abi {};
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
};
openmp = callPackage ./openmp.nix {};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,7 +1,7 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n";
@ -45,10 +45,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.unix;
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 ];
};
}

View file

@ -1,7 +1,7 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version }:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "0prqvdj317qrc8nddaq1hh2ag9algkd9wbkj3y4mr5588k12x7r0";
@ -47,11 +47,15 @@ stdenv.mkDerivation {
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.unix;
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,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -7,11 +7,11 @@
, version
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
src = fetch "lld" "04afcfq2h7ysyqxxhyhb7ig4p0vdw7mi63kh8mffl74j0rc781p7";
src = fetch pname "04afcfq2h7ysyqxxhyhb7ig4p0vdw7mi63kh8mffl74j0rc781p7";
patches = [
./gnu-install-dirs.patch
@ -28,10 +28,16 @@ stdenv.mkDerivation {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), and Mach-O (macOS)
in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, fetchpatch
, cmake
@ -73,10 +73,14 @@ stdenv.mkDerivation rec {
cp ../docs/lldb.1 $out/share/man/man1/
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://llvm.org/";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, cmake
@ -167,12 +167,23 @@ stdenv.mkDerivation ({
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -191,5 +202,7 @@ stdenv.mkDerivation ({
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,25 +0,0 @@
{ lib
, stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0nhwfba9c351r16zgyjyfwdayr98nairky3c2f0b2lc360mwmbv6";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,34 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0nhwfba9c351r16zgyjyfwdayr98nairky3c2f0b2lc360mwmbv6";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -100,11 +100,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -123,6 +132,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,15 +1,16 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation {
pname = "compiler-rt";
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
@ -29,14 +30,15 @@ stdenv.mkDerivation {
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM && !haveLibc) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
@ -83,10 +85,25 @@ stdenv.mkDerivation {
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
ln -s "$out/lib"/*/* "$out/lib"
'' + lib.optionalString (useLLVM) ''
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -16,6 +17,12 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "0lb4kdh7j2fhfz8kd6iv5df7m3pikiryk1vvwsf87spc90n09q0w";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
@ -30,23 +37,29 @@ let
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libllvm-polly = callPackage ./llvm { enablePolly = true; };
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
clang-polly-unwrapped = callPackage ./clang {
inherit llvm_meta;
inherit clang-tools-extra_src;
libllvm = tools.libllvm-polly;
enablePolly = true;
@ -84,9 +97,13 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
@ -95,7 +112,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -106,12 +132,16 @@ let
extraPackages = [
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
];
extraBuildCommands = ''
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
@ -120,9 +150,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -136,10 +164,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -152,50 +177,75 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt {
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libc++abi ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libunwind = callPackage ./libunwind ({
libunwind = callPackage ./libunwind {
inherit llvm_meta;
inherit (buildLlvmTools) llvm;
} // lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
});
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp.nix {};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,9 +1,9 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0kmhcapm2cjwalyiqasj9dmqbw59mcwdl8fgl951wg7ax84b8hj4";
@ -17,7 +17,9 @@ stdenv.mkDerivation {
patches = [
./gnu-install-dirs.patch
] ++ lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
prePatch = ''
substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
@ -34,7 +36,7 @@ stdenv.mkDerivation {
++ lib.optional stdenv.hostPlatform.isMusl python3
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ libcxxabi ] ;
buildInputs = [ libcxxabi ];
cmakeFlags = [
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
@ -48,10 +50,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.unix;
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 ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, standalone ? stdenv.hostPlatform.useLLVM or false
, withLibunwind ? !stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm
# on musl the shared objects don't build
@ -6,7 +6,7 @@
}:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "1zcqxsdjhawgz1cvpk07y3jl6fg9p3ay4nl69zsirqb2ghgyhhb2";
@ -58,11 +58,15 @@ stdenv.mkDerivation {
${lib.optionalString enableShared "ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1"}
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.unix;
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,12 +1,17 @@
{ lib, stdenv, version, fetch, fetchpatch, cmake, llvm, libcxx
{ lib, stdenv, llvm_meta, version, fetch, fetchpatch, cmake, llvm
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
src = fetch "libunwind" "035dsxs10nyiqd00q07yycvmkjl01yz4jdlrjvmch8klxg4pyjhp";
src = fetch pname "035dsxs10nyiqd00q07yycvmkjl01yz4jdlrjvmch8klxg4pyjhp";
postUnpack = ''
unpackFile ${llvm.src}
cmakeFlagsArray=($cmakeFlagsArray -DLLVM_PATH=$PWD/$(ls -d llvm-*))
'';
patches = [
./gnu-install-dirs.patch
@ -24,12 +29,25 @@ stdenv.mkDerivation {
})
];
nativeBuildInputs = [ cmake llvm.dev ];
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optionals (!enableShared) [
"-DLIBUNWIND_ENABLE_SHARED=OFF"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLIBUNWIND_HAS_NOSTDINCXX_FLAG=ON"
"-DLLVM_ENABLE_LIBCXX=ON"
];
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -7,11 +7,11 @@
, version
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
src = fetch "lld" "0rsqb7zcnij5r5ipfhr129j7skr5n9pyr388kjpqwh091952f3x1";
src = fetch pname "0rsqb7zcnij5r5ipfhr129j7skr5n9pyr388kjpqwh091952f3x1";
patches = [
./gnu-install-dirs.patch
@ -28,10 +28,16 @@ stdenv.mkDerivation {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), and Mach-O (macOS)
in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, cmake
, zlib
@ -76,10 +76,14 @@ stdenv.mkDerivation rec {
cp ../docs/lldb.1 $out/share/man/man1/
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://llvm.org/";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, fetchpatch
@ -184,12 +184,23 @@ in stdenv.mkDerivation ({
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -211,5 +222,7 @@ in stdenv.mkDerivation ({
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,25 +0,0 @@
{ lib
, stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,34 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -107,11 +107,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -130,6 +139,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,15 +1,16 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation {
pname = "compiler-rt";
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
@ -29,14 +30,15 @@ stdenv.mkDerivation {
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM && !haveLibc) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
@ -89,4 +91,19 @@ stdenv.mkDerivation {
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -16,6 +17,12 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "1qf3097bc5ia8p6cpmbx985rjr3yaah5s8fc0nv7pw742yv7jw8q";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
@ -30,23 +37,29 @@ let
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libllvm-polly = callPackage ./llvm { enablePolly = true; };
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
clang-polly-unwrapped = callPackage ./clang {
inherit llvm_meta;
inherit clang-tools-extra_src;
libllvm = tools.libllvm-polly;
enablePolly = true;
@ -85,9 +98,13 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
@ -96,7 +113,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -115,6 +141,8 @@ let
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
@ -123,9 +151,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -139,10 +165,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -155,49 +178,74 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libc++abi ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,9 +1,9 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0y4vc9z36c1zlq15cnibdzxnc1xi5glbc6klnm8a41q3db4541kz";
@ -17,7 +17,9 @@ stdenv.mkDerivation {
patches = [
./gnu-install-dirs.patch
] ++ lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
prePatch = ''
substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
@ -51,10 +53,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
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 ];
};
}

View file

@ -1,9 +1,9 @@
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++abi";
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "1vznz8n1z1h8af0ga451m98lc2hjnv4fyzl71napsvjhvk4g6nxp";
@ -63,11 +63,15 @@ stdenv.mkDerivation {
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.all;
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,4 +1,4 @@
{ lib, stdenv, version, fetch, cmake, fetchpatch
{ lib, stdenv, llvm_meta, version, fetch, cmake, fetchpatch
, enableShared ? !stdenv.hostPlatform.isStatic
}:
@ -25,4 +25,16 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
@ -7,11 +7,11 @@
, version
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
src = fetch "lld" "121xhxrlvwy3k5nf6p1wv31whxlb635ssfkci8z93mwv4ja1xflz";
src = fetch pname "121xhxrlvwy3k5nf6p1wv31whxlb635ssfkci8z93mwv4ja1xflz";
patches = [
./gnu-install-dirs.patch
@ -28,10 +28,16 @@ stdenv.mkDerivation {
outputs = [ "out" "lib" "dev" ];
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
WebAssembly in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, fetch
, cmake
, zlib
@ -70,10 +70,14 @@ stdenv.mkDerivation rec {
ln -s $out/bin/llvm-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';
meta = with lib; {
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
homepage = "https://llvm.org/";
license = licenses.ncsa;
platforms = platforms.all;
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, fetchpatch
@ -168,12 +168,23 @@ in stdenv.mkDerivation ({
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
@ -195,5 +206,7 @@ in stdenv.mkDerivation ({
doCheck = false;
meta.description = "man pages for LLVM ${version}";
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,25 +0,0 @@
{ lib
, stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0b3jlxhqbpyd1nqkpxjfggm5d9va5qpyf7d4i5y7n4a1mlydv19y";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,34 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0b3jlxhqbpyd1nqkpxjfggm5d9va5qpyf7d4i5y7n4a1mlydv19y";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
@ -102,11 +102,20 @@ let
inherit libllvm;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
meta = llvm_meta // {
homepage = "https://clang.llvm.org/";
description = "A C language family frontend for LLVM";
longDescription = ''
The Clang project provides a language front-end and tooling
infrastructure for languages in the C language family (C, C++, Objective
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
It aims to deliver amazingly fast compiles, extremely useful error and
warning messages and to provide a platform for building great source
level tools. The Clang Static Analyzer and clang-tidy are tools that
automatically find bugs in your code, and are great examples of the sort
of tools that can be built using the Clang frontend as a library to
parse C/C++ code.
'';
};
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
@ -125,6 +134,8 @@ let
doCheck = false;
meta.description = "man page for Clang ${version}";
meta = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,17 +1,18 @@
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, llvm, libcxxabi }:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation rec {
pname = "compiler-rt";
stdenv.mkDerivation {
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch pname "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
src = fetch "compiler-rt" "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
nativeBuildInputs = [ cmake python3 llvm.dev ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ lib.optionals (useLLVM && !haveLibc) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
] ++ lib.optionals (useLLVM) [
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
"-DCMAKE_C_FLAGS=-nodefaultlibs"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ lib.optionals (bareMetal) [
@ -87,4 +89,20 @@ stdenv.mkDerivation rec {
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,4 +1,5 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
@ -16,6 +17,12 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "01vgzd4k1q93nfs8gyl83mjlc4x0qsgfqw32lacbjzdxg0mdfvxj";
llvm_meta = {
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
@ -30,23 +37,29 @@ let
in {
libllvm = callPackage ./llvm { };
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm.out // { outputUnspecified = true; };
libllvm-polly = callPackage ./llvm { enablePolly = true; };
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src;
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
clang-polly-unwrapped = callPackage ./clang {
inherit llvm_meta;
inherit clang-tools-extra_src;
libllvm = tools.libllvm-polly;
enablePolly = true;
@ -85,9 +98,13 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
@ -96,7 +113,16 @@ let
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
bintools-unwrapped = callPackage ./bintools {};
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
@ -115,6 +141,8 @@ let
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
@ -123,9 +151,7 @@ let
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
inherit (tools) bintools;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -139,10 +165,7 @@ let
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [
targetLlvmLibraries.compiler-rt
];
@ -155,49 +178,74 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
bintools = tools.bintoolsNoLibc;
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
inherit (tools) bintools;
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt = if stdenv.hostPlatform.isAndroid
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libc++abi ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind ({} //
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libunwind = callPackage ./libunwind {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.lldClangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta;
};
});
in { inherit tools libraries; } // libraries // tools

View file

@ -1,9 +1,9 @@
{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
{ lib, stdenv, llvm_meta, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libc++";
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089";
@ -17,7 +17,9 @@ stdenv.mkDerivation {
patches = [
./gnu-install-dirs.patch
] ++ lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
preConfigure = ''
# Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
@ -47,10 +49,15 @@ stdenv.mkDerivation {
isLLVM = true;
};
meta = {
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
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 ];
};
}

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