diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm/10/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/compilers/llvm/10/default.nix | 177 |
1 files changed, 122 insertions, 55 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix index 3fa91cd83749..11367d453cde 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix @@ -1,8 +1,19 @@ -{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs +{ lowPrio, newScope, pkgs, lib, stdenv, cmake +, gccForLibs, preLibcCrossHeaders , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith -, buildPackages , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross +# This is the default binutils, but with *this* version of LLD rather +# than the default LLVM verion's, if LLD is the choice. We use these for +# the `useLLVM` bootstrapping below. +, bootBintoolsNoLibc ? + if stdenv.targetPlatform.linker == "lld" + then null + else pkgs.bintoolsNoLibc +, bootBintools ? + if stdenv.targetPlatform.linker == "lld" + then null + else pkgs.bintools }: let @@ -17,32 +28,57 @@ 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; }); - mkExtraBuildCommands = cc: '' + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; }); + mkExtraBuildCommands0 = cc: '' rsrc="$out/resource-root" mkdir "$rsrc" - ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + ''; + mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share" - echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags ''; + + bintoolsNoLibc' = + if bootBintoolsNoLibc == null + then tools.bintoolsNoLibc + else bootBintoolsNoLibc; + bintools' = + if bootBintools == null + then tools.bintools + else bootBintools; + in { - llvm = 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; }; - clang-unwrapped = callPackage ./clang { - inherit (tools) lld; - inherit clang-tools-extra_src; + libclang = callPackage ./clang { + inherit clang-tools-extra_src llvm_meta; }; + clang-unwrapped = tools.libclang.out // { outputUnspecified = true; }; + # disabled until recommonmark supports sphinx 3 - #Llvm-manpages = lowPrio (tools.llvm.override { + #Llvm-manpages = lowPrio (tools.libllvm.override { # enableManpages = true; # python3 = pkgs.python3; # don't use python-boot #}); - clang-manpages = lowPrio (tools.clang-unwrapped.override { + clang-manpages = lowPrio (tools.libclang.override { enableManpages = true; python3 = pkgs.python3; # don't use python-boot }); @@ -53,8 +89,6 @@ let # python3 = pkgs.python3; # don't use python-boot # }); - libclang = tools.clang-unwrapped.lib; - clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; libstdcxxClang = wrapCCWith rec { @@ -77,9 +111,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 @@ -88,14 +126,21 @@ 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; + }; - lldClang = wrapCCWith rec { + bintools = wrapBintoolsWith { + bintools = tools.bintools-unwrapped; + }; + + clangUseLLVM = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; - bintools = wrapBintoolsWith { - inherit (tools) bintools; - }; + bintools = bintools'; extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt @@ -107,17 +152,17 @@ 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.isWasm && stdenv.targetPlatform.useLLVM or false) '' + echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; }; - lldClangNoLibcxx = wrapCCWith rec { + clangNoLibcxx = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = null; - bintools = wrapBintoolsWith { - inherit (tools) bintools; - }; + bintools = bintools'; extraPackages = [ targetLlvmLibraries.compiler-rt ]; @@ -128,13 +173,10 @@ let '' + mkExtraBuildCommands cc; }; - lldClangNoLibc = wrapCCWith rec { + clangNoLibc = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = null; - bintools = wrapBintoolsWith { - inherit (tools) bintools; - libc = null; - }; + bintools = bintoolsNoLibc'; extraPackages = [ targetLlvmLibraries.compiler-rt ]; @@ -144,17 +186,22 @@ let '' + mkExtraBuildCommands cc; }; - lldClangNoCompilerRt = wrapCCWith { + clangNoCompilerRt = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = null; - bintools = wrapBintoolsWith { - inherit (tools) bintools; - libc = null; - }; + bintools = bintoolsNoLibc'; extraPackages = [ ]; extraBuildCommands = '' echo "-nostartfiles" >> $out/nix-support/cc-cflags - ''; + '' + mkExtraBuildCommands0 cc; + }; + + clangNoCompilerRtWithLibc = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = bintools'; + extraPackages = [ ]; + extraBuildCommands = mkExtraBuildCommands0 cc; }; }); @@ -163,33 +210,53 @@ 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.clangNoCompilerRtWithLibc + else stdenv; + }; + + compiler-rt-no-libc = callPackage ./compiler-rt { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoCompilerRt + 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; - })); - - libcxxabi = callPackage ./libc++abi ({} // - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; - libunwind = libraries.libunwind; - })); + libcxx = callPackage ./libcxx { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoLibcxx + else stdenv; + }; - openmp = callPackage ./openmp.nix {}; + libcxxabi = callPackage ./libcxxabi { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoLibcxx + else stdenv; + }; - 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.clangNoLibcxx + else stdenv; + }; + openmp = callPackage ./openmp { + inherit llvm_meta; + }; }); in { inherit tools libraries; } // libraries // tools |