Skip to content

Commit

Permalink
llvm 4: WIP split out libs from tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Jun 20, 2017
1 parent f00477a commit acf2ed5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 34 deletions.
21 changes: 21 additions & 0 deletions pkgs/development/compilers/llvm/4/compiler-rt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ stdenv
, fetch
, buildPlatform, hostPlatform
}:

stdenv.mkDerivation {
src = fetch "compiler-rt" "059ipqq27gd928ay06f1ck3vw6y5h5z4zd766x8k0k7jpqimpwnk";

# 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
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
'';

# Note from John to Will. This was a build dep for llvm; I'm guessing it's really used by just compiler-rt.
buildInputs = stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
}
43 changes: 25 additions & 18 deletions pkgs/development/compilers/llvm/4/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ newScope, stdenv, cmake, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun }:
{ newScope, stdenv, cmake, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun
, # The same LLVM from `buildPackages`, for building the libraries and getting the tools
buildTools
}:
let
callPackage = newScope (self // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });

release_version = "4.0.0";
version = release_version; # differentiating these is important for rc's

Expand All @@ -10,41 +11,47 @@ let
inherit sha256;
};

compiler-rt_src = fetch "compiler-rt" "059ipqq27gd928ay06f1ck3vw6y5h5z4zd766x8k0k7jpqimpwnk";
clang-tools-extra_src = fetch "clang-tools-extra" "16bwckgcxfn56mbqjlxi7fxja0zm9hjfa6s3ncm3dz98n5zd7ds1";

self = {
llvm = callPackage ./llvm.nix {
inherit compiler-rt_src stdenv;
};
tools = let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
in {
llvm = callPackage ./llvm.nix { };

clang-unwrapped = callPackage ./clang {
inherit clang-tools-extra_src stdenv;
};

clang = wrapCC self.clang-unwrapped;

lld = callPackage ./lld.nix {};

lldb = callPackage ./lldb.nix {};
};

libraries = let
callPackage = newScope (libraries // buildTools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt.nix {};

openmp = callPackage ./openmp.nix {};

libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped;
cc = tools.clang-unwrapped;
isClang = true;
inherit (self) stdenv;
inherit (tools) stdenv;
/* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ];
extraPackages = [ libraries.libcxx tools.libcxxabi tools.compiler-rt ];
};

stdenv = overrideCC stdenv self.clang;
clang = wrapCC tools.clang-unwrapped;

libcxxStdenv = overrideCC stdenv self.libcxxClang;
stdenv = overrideCC stdenv tools.clang;

lld = callPackage ./lld.nix {};

lldb = callPackage ./lldb.nix {};
libcxxStdenv = overrideCC stdenv tools.libcxxClang;

libcxx = callPackage ./libc++ {};

libcxxabi = callPackage ./libc++abi.nix {};
};
in self
in { inherit tools libraries; } // libraries // tools
18 changes: 2 additions & 16 deletions pkgs/development/compilers/llvm/4/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
, version
, release_version
, zlib
, compiler-rt_src
, libcxxabi
, debugVersion ? false
, enableManpages ? true
, enableSharedLibraries ? true
Expand All @@ -35,8 +33,6 @@ in stdenv.mkDerivation rec {
unpackFile ${src}
mv llvm-${version}* llvm
sourceRoot=$PWD/llvm
unpackFile ${compiler-rt_src}
mv compiler-rt-* $sourceRoot/projects/compiler-rt
'';

outputs = [ "out" ]
Expand All @@ -46,22 +42,12 @@ in stdenv.mkDerivation rec {
nativeBuildInputs = [ perl groff cmake python ]
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;

buildInputs = [ libxml2 libffi ]
++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
buildInputs = [ libxml2 libffi ];

propagatedBuildInputs = [ ncurses zlib ];

# 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
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
''
# Patch llvm-config to return correct library path based on --link-{shared,static}.
+ stdenv.lib.optionalString (enableSharedLibraries) ''
postPatch = stdenv.lib.optionalString (enableSharedLibraries) ''
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
patch -p1 < ./llvm-outputs.patch
''
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5674,6 +5674,7 @@ with pkgs;

llvmPackages_4 = callPackage ../development/compilers/llvm/4 ({
inherit (stdenvAdapters) overrideCC;
buildTools = buildPackages.llvmPackages_4.tools;
} // stdenv.lib.optionalAttrs stdenv.isDarwin {
cmake = cmake.override { isBootstrap = true; };
libxml2 = libxml2.override { pythonSupport = false; };
Expand Down

0 comments on commit acf2ed5

Please sign in to comment.