@ -23,7 +23,7 @@ let
ln - s " ${ cc } / l i b / c l a n g / ${ release_version } / i n c l u d e " " $ r s r c "
ln - s " ${ targetLlvmLibraries . compiler-rt . out } / l i b " " $ r s r c / l i b "
echo " - r e s o u r c e - d i r = $ r s r c " > > $ out/nix-support/cc-cflags
'' + s t d e n v . l i b . o p t i o n a l S t r i n g ( s t d e n v . t a r g e t P l a t f o r m . i s L i n u x & & t o o l s . c l a n g - u n w r a p p e d ? g c c ) ''
'' + s t d e n v . l i b . o p t i o n a l S t r i n g ( s t d e n v . t a r g e t P l a t f o r m . i s L i n u x & & t o o l s . c l a n g - u n w r a p p e d ? g c c & & ! ( s t d e n v . t a r g e t P l a t f o r m . u s e L L V M o r f a l s e ) ) ''
echo " - - g c c - t o o l c h a i n = ${ tools . clang-unwrapped . gcc } " > > $ out/nix-support/cc-cflags
'' ;
in {
@ -78,48 +78,78 @@ let
lldb = callPackage ./lldb.nix { } ;
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
# pulled in. As a consequence, it is very quick to build different
# targets provided by LLVM and we can also build for what GCC
# doesn’t support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix { } ;
lldClang = wrapCCWith rec {
cc = tools . clang-unwrapped ;
libcxx = targetLlvmLibraries . libcxx ;
bintools = wrapBintoolsWith {
inherit ( tools ) bintools ;
} ;
extraPackages = [
targetLlvmLibraries . libcxx
targetLlvmLibraries . libcxxabi
targetLlvmLibraries . compiler-rt
] ;
extraBuildCommands = ''
echo " - t a r g e t ${ stdenv . targetPlatform . config } " > > $ out/nix-support/cc-cflags
echo " - r t l i b = c o m p i l e r - r t - W n o - u n u s e d - c o m m a n d - l i n e - a r g u m e n t " > > $ out/nix-support/cc-cflags
echo " - B ${ targetLlvmLibraries . compiler-rt } / l i b " > > $ out/nix-support/cc-cflags
'' + m k E x t r a B u i l d C o m m a n d s c c ;
} ;
lldClangNoLibcxx = wrapCCWith rec {
cc = tools . clang-unwrapped ;
libcxx = null ;
bintools = wrapBintoolsWith {
inherit ( tools ) bintools ;
} ;
extraPackages = [
# targetLlvmLibraries.libcxx
# targetLlvmLibraries.libcxxabi
targetLlvmLibraries . compiler-rt
] ;
extraBuildCommands = ''
echo " - t a r g e t ${ stdenv . targetPlatform . config } - r t l i b = c o m p i l e r - r t " > > $ out/nix-support/cc-cflags
echo " - t a r g e t ${ stdenv . targetPlatform . config } " > > $ out/nix-support/cc-cflags
echo " - r t l i b = c o m p i l e r - r t " > > $ out/nix-support/cc-cflags
echo " - B ${ targetLlvmLibraries . compiler-rt } / l i b " > > $ out/nix-support/cc-cflags
echo " - n o s t d l i b + + " > > $ out/nix-support/cc-cflags
'' + m k E x t r a B u i l d C o m m a n d s c c ;
} ;
lldClangNoLibc = wrapCCWith rec {
cc = tools . clang-unwrapped ;
libcxx = null ;
bintools = wrapBintoolsWith {
inherit ( tools ) bintools ;
libc = null ;
} ;
extraPackages = [
# targetLlvmLibraries.libcxx
# targetLlvmLibraries.libcxxabi
targetLlvmLibraries . compiler-rt
] ;
extraBuildCommands = ''
echo " - t a r g e t ${ stdenv . targetPlatform . config } - r t l i b = c o m p i l e r - r t " > > $ out/nix-support/cc-cflags
echo " - t a r g e t ${ stdenv . targetPlatform . config } " > > $ out/nix-support/cc-cflags
echo " - r t l i b = c o m p i l e r - r t " > > $ out/nix-support/cc-cflags
echo " - B ${ targetLlvmLibraries . compiler-rt } / l i b " > > $ out/nix-support/cc-cflags
'' + m k E x t r a B u i l d C o m m a n d s c c ;
} ;
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools . clang-unwrapped ;
libcxx = null ;
bintools = wrapBintoolsWith {
inherit ( tools ) bintools ;
libc = null ;
} ;
extraPackages = [ ] ;
extraBuildCommands = ''
echo " - n o s t a r t f i l e s - t a r g e t ${ stdenv . targetPlatform . config } " > > $ out/nix-support/cc-cflags
echo " - n o s t a r t f i l e s " > > $ out/nix-support/cc-cflags
echo " - t a r g e t ${ stdenv . targetPlatform . config } " > > $ out/nix-support/cc-cflags
'' ;
} ;
@ -129,21 +159,33 @@ let
callPackage = newScope ( libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch ; } ) ;
in {
compiler-rt = callPackage ./compiler-rt.nix {
stdenv = if stdenv . hostPlatform . useLLVM or false
then overrideCC stdenv buildLlvmTools . lldClangNoCompilerRt
else stdenv ;
} ;
compiler-rt = callPackage ./compiler-rt.nix ( { } //
( stdenv . lib . optionalAttrs ( stdenv . hostPlatform . useLLVM or false ) {
stdenv = overrideCC stdenv buildLlvmTools . lldClangNoCompilerRt ;
} ) ) ;
stdenv = overrideCC stdenv buildLlvmTools . clang ;
libcxxStdenv = overrideCC stdenv buildLlvmTools . libcxxClang ;
libcxx = callPackage ./libc++ { } ;
libcxx = callPackage ./libc++ ( { } //
( stdenv . lib . optionalAttrs ( stdenv . hostPlatform . useLLVM or false ) {
stdenv = overrideCC stdenv buildLlvmTools . lldClangNoLibcxx ;
} ) ) ;
libcxxabi = callPackage ./libc++abi.nix { } ;
libcxxabi = callPackage ./libc++abi.nix ( { } //
( stdenv . lib . optionalAttrs ( stdenv . hostPlatform . useLLVM or false ) {
stdenv = overrideCC stdenv buildLlvmTools . lldClangNoLibcxx ;
libunwind = libraries . libunwind ;
} ) ) ;
openmp = callPackage ./openmp.nix { } ;
libunwind = callPackage ./libunwind.nix ( { } //
( stdenv . lib . optionalAttrs ( stdenv . hostPlatform . useLLVM or false ) {
stdenv = overrideCC stdenv buildLlvmTools . lldClangNoLibcxx ;
} ) ) ;
} ) ;
in { inherit tools libraries ; } // libraries // tools