From acf2ed5bafc61345ddc1fa372225c8f479cb8cd8 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 19 Jun 2017 16:56:32 -0400 Subject: [PATCH] llvm 4: WIP split out libs from tools --- .../compilers/llvm/4/compiler-rt.nix | 21 +++++++++ pkgs/development/compilers/llvm/4/default.nix | 43 +++++++++++-------- pkgs/development/compilers/llvm/4/llvm.nix | 18 +------- pkgs/top-level/all-packages.nix | 1 + 4 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 pkgs/development/compilers/llvm/4/compiler-rt.nix diff --git a/pkgs/development/compilers/llvm/4/compiler-rt.nix b/pkgs/development/compilers/llvm/4/compiler-rt.nix new file mode 100644 index 0000000000000..139eaa8401e2f --- /dev/null +++ b/pkgs/development/compilers/llvm/4/compiler-rt.nix @@ -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 ]; +} diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix index 15918f9c1ebdf..a10afb1124599 100644 --- a/pkgs/development/compilers/llvm/4/default.nix +++ b/pkgs/development/compilers/llvm/4/default.nix @@ -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 @@ -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 diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index 98c24495355c2..227f61cb0980a 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -13,8 +13,6 @@ , version , release_version , zlib -, compiler-rt_src -, libcxxabi , debugVersion ? false , enableManpages ? true , enableSharedLibraries ? true @@ -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" ] @@ -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 '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 05fe28236b575..0b4890f305c1d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; };