@ -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
@ -93,7 +94,16 @@ let
# doesn’t 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 +122,8 @@ let
echo " - B ${ targetLlvmLibraries . compiler-rt } / l i b " > > $ out/nix-support/cc-cflags
'' + 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 W a s m ) ''
echo " - - u n w i n d l i b = l i b u n w i n d " > > $ out/nix-support/cc-cflags
'' + 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 A n d r o i d & & 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 ) ''
echo " - l u n w i n d " > > $ out/nix-support/cc-ldflags
'' + 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 W a s m ''
echo " - f n o - e x c e p t i o n s " > > $ 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 ;
@ -120,9 +132,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 +146,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,26 +159,43 @@ let
lldClangNoCompilerRt = wrapCCWith rec {
cc = tools . clang-unwrapped ;
libcxx = null ;
bintools = wrapBintoolsWith {
inherit ( tools ) bintools ;
libc = null ;
} ;
bintools = tools . bintoolsNoLibc ;
extraPackages = [ ] ;
extraBuildCommands = ''
echo " - n o s t a r t f i l e s " > > $ 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 0 c c ;
} ;
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 {
stdenv = if stdenv . hostPlatform . useLLVM or false
then overrideCC stdenv buildLlvmTools . lldClangNoCompilerRtWithLibc
else stdenv ;
} ;
compiler-rt-no-libc = callPackage ./compiler-rt {
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 ;