lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 23.05-pre 266 lines 9.1 kB view raw
1{ lowPrio, newScope, pkgs, lib, stdenv, cmake 2, gccForLibs, preLibcCrossHeaders 3, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 4, buildLlvmTools # tools, but from the previous stage, for cross 5, targetLlvmLibraries # libraries, but from the next stage, for cross 6# This is the default binutils, but with *this* version of LLD rather 7# than the default LLVM verion's, if LLD is the choice. We use these for 8# the `useLLVM` bootstrapping below. 9, bootBintoolsNoLibc ? 10 if stdenv.targetPlatform.linker == "lld" 11 then null 12 else pkgs.bintoolsNoLibc 13, bootBintools ? 14 if stdenv.targetPlatform.linker == "lld" 15 then null 16 else pkgs.bintools 17}: 18 19let 20 release_version = "10.0.1"; 21 version = release_version; # differentiating these (variables) is important for RCs 22 targetConfig = stdenv.targetPlatform.config; 23 24 fetch = name: sha256: fetchurl { 25 url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${release_version}/${name}-${version}.src.tar.xz"; 26 inherit sha256; 27 }; 28 29 clang-tools-extra_src = fetch "clang-tools-extra" "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh"; 30 31 llvm_meta = { 32 license = lib.licenses.ncsa; 33 maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ]; 34 platforms = lib.platforms.all; 35 }; 36 37 tools = lib.makeExtensible (tools: let 38 callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; }); 39 mkExtraBuildCommands0 = cc: '' 40 rsrc="$out/resource-root" 41 mkdir "$rsrc" 42 ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc" 43 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags 44 ''; 45 mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' 46 ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" 47 ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share" 48 ''; 49 50 bintoolsNoLibc' = 51 if bootBintoolsNoLibc == null 52 then tools.bintoolsNoLibc 53 else bootBintoolsNoLibc; 54 bintools' = 55 if bootBintools == null 56 then tools.bintools 57 else bootBintools; 58 59 in { 60 61 libllvm = callPackage ./llvm { 62 inherit llvm_meta; 63 }; 64 65 # `llvm` historically had the binaries. When choosing an output explicitly, 66 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 67 llvm = tools.libllvm.out // { outputSpecified = false; }; 68 69 libclang = callPackage ./clang { 70 inherit clang-tools-extra_src llvm_meta; 71 }; 72 73 clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; 74 75 # disabled until recommonmark supports sphinx 3 76 #Llvm-manpages = lowPrio (tools.libllvm.override { 77 # enableManpages = true; 78 # python3 = pkgs.python3; # don't use python-boot 79 #}); 80 81 clang-manpages = lowPrio (tools.libclang.override { 82 enableManpages = true; 83 python3 = pkgs.python3; # don't use python-boot 84 }); 85 86 # disabled until recommonmark supports sphinx 3 87 # lldb-manpages = lowPrio (tools.lldb.override { 88 # enableManpages = true; 89 # python3 = pkgs.python3; # don't use python-boot 90 # }); 91 92 # pick clang appropriate for package set we are targeting 93 clang = 94 /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM 95 else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang 96 else tools.libcxxClang; 97 98 libstdcxxClang = wrapCCWith rec { 99 cc = tools.clang-unwrapped; 100 # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper. 101 libcxx = null; 102 extraPackages = [ 103 targetLlvmLibraries.compiler-rt 104 ]; 105 extraBuildCommands = mkExtraBuildCommands cc; 106 }; 107 108 libcxxClang = wrapCCWith rec { 109 cc = tools.clang-unwrapped; 110 libcxx = targetLlvmLibraries.libcxx; 111 extraPackages = [ 112 targetLlvmLibraries.libcxxabi 113 targetLlvmLibraries.compiler-rt 114 ]; 115 extraBuildCommands = mkExtraBuildCommands cc; 116 }; 117 118 lld = callPackage ./lld { 119 inherit llvm_meta; 120 }; 121 122 lldb = callPackage ./lldb { 123 inherit llvm_meta; 124 }; 125 126 # Below, is the LLVM bootstrapping logic. It handles building a 127 # fully LLVM toolchain from scratch. No GCC toolchain should be 128 # pulled in. As a consequence, it is very quick to build different 129 # targets provided by LLVM and we can also build for what GCC 130 # doesn’t support like LLVM. Probably we should move to some other 131 # file. 132 133 bintools-unwrapped = callPackage ./bintools {}; 134 135 bintoolsNoLibc = wrapBintoolsWith { 136 bintools = tools.bintools-unwrapped; 137 libc = preLibcCrossHeaders; 138 }; 139 140 bintools = wrapBintoolsWith { 141 bintools = tools.bintools-unwrapped; 142 }; 143 144 clangUseLLVM = wrapCCWith rec { 145 cc = tools.clang-unwrapped; 146 libcxx = targetLlvmLibraries.libcxx; 147 bintools = bintools'; 148 extraPackages = [ 149 targetLlvmLibraries.libcxxabi 150 targetLlvmLibraries.compiler-rt 151 ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ 152 targetLlvmLibraries.libunwind 153 ]; 154 extraBuildCommands = '' 155 echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags 156 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 157 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 158 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 159 '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' 160 echo "-lunwind" >> $out/nix-support/cc-ldflags 161 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 162 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 163 '' + mkExtraBuildCommands cc; 164 }; 165 166 clangNoLibcxx = wrapCCWith rec { 167 cc = tools.clang-unwrapped; 168 libcxx = null; 169 bintools = bintools'; 170 extraPackages = [ 171 targetLlvmLibraries.compiler-rt 172 ]; 173 extraBuildCommands = '' 174 echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags 175 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 176 echo "-nostdlib++" >> $out/nix-support/cc-cflags 177 '' + mkExtraBuildCommands cc; 178 }; 179 180 clangNoLibc = wrapCCWith rec { 181 cc = tools.clang-unwrapped; 182 libcxx = null; 183 bintools = bintoolsNoLibc'; 184 extraPackages = [ 185 targetLlvmLibraries.compiler-rt 186 ]; 187 extraBuildCommands = '' 188 echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags 189 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 190 '' + mkExtraBuildCommands cc; 191 }; 192 193 clangNoCompilerRt = wrapCCWith rec { 194 cc = tools.clang-unwrapped; 195 libcxx = null; 196 bintools = bintoolsNoLibc'; 197 extraPackages = [ ]; 198 extraBuildCommands = '' 199 echo "-nostartfiles" >> $out/nix-support/cc-cflags 200 '' + mkExtraBuildCommands0 cc; 201 }; 202 203 clangNoCompilerRtWithLibc = wrapCCWith rec { 204 cc = tools.clang-unwrapped; 205 libcxx = null; 206 bintools = bintools'; 207 extraPackages = [ ]; 208 extraBuildCommands = mkExtraBuildCommands0 cc; 209 }; 210 211 }); 212 213 libraries = lib.makeExtensible (libraries: let 214 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 215 in { 216 217 compiler-rt-libc = callPackage ./compiler-rt { 218 inherit llvm_meta; 219 stdenv = if stdenv.hostPlatform.useLLVM or false 220 then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc 221 else stdenv; 222 }; 223 224 compiler-rt-no-libc = callPackage ./compiler-rt { 225 inherit llvm_meta; 226 stdenv = if stdenv.hostPlatform.useLLVM or false 227 then overrideCC stdenv buildLlvmTools.clangNoCompilerRt 228 else stdenv; 229 }; 230 231 # N.B. condition is safe because without useLLVM both are the same. 232 compiler-rt = if stdenv.hostPlatform.isAndroid 233 then libraries.compiler-rt-libc 234 else libraries.compiler-rt-no-libc; 235 236 stdenv = overrideCC stdenv buildLlvmTools.clang; 237 238 libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; 239 240 libcxx = callPackage ./libcxx { 241 inherit llvm_meta; 242 stdenv = if stdenv.hostPlatform.useLLVM or false 243 then overrideCC stdenv buildLlvmTools.clangNoLibcxx 244 else stdenv; 245 }; 246 247 libcxxabi = callPackage ./libcxxabi { 248 inherit llvm_meta; 249 stdenv = if stdenv.hostPlatform.useLLVM or false 250 then overrideCC stdenv buildLlvmTools.clangNoLibcxx 251 else stdenv; 252 }; 253 254 libunwind = callPackage ./libunwind { 255 inherit llvm_meta; 256 stdenv = if stdenv.hostPlatform.useLLVM or false 257 then overrideCC stdenv buildLlvmTools.clangNoLibcxx 258 else stdenv; 259 }; 260 261 openmp = callPackage ./openmp { 262 inherit llvm_meta; 263 }; 264 }); 265 266in { inherit tools libraries release_version; } // libraries // tools