aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/compilers/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm')
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix19
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/clang/clang-extension-handling.patch18
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/clang/compiler-rt-baremetal.patch53
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix121
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/clang/purity.patch30
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt-codesign.patch33
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix73
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/default.nix203
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/find-darwin-sdk-version.patch62
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix55
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh6
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix67
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-no-threads.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-wasm.patch16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix14
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/lld.nix33
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/lldb-procfs.patch31
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix101
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch146
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/llvm-outputs.patch26
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix190
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix26
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/sanitizers-nongnu.patch412
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-sys-ustat.patch58
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix3
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch68
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix10
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch80
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch80
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/default.nix1
34 files changed, 2053 insertions, 8 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix
new file mode 100644
index 00000000000..72a2a733193
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix
@@ -0,0 +1,19 @@
+{ runCommand, stdenv, llvm, lld, version }:
+
+let
+ prefix =
+ if stdenv.hostPlatform != stdenv.targetPlatform
+ then "${stdenv.targetPlatform.config}-"
+ else "";
+in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } ''
+ mkdir -p $out/bin
+ for prog in ${lld}/bin/*; do
+ ln -s $prog $out/bin/${prefix}$(basename $prog)
+ done
+ for prog in ${llvm}/bin/*; do
+ ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||")
+ ln -sf $prog $out/bin/${prefix}$(basename $prog)
+ done
+ rm -f $out/bin/${prefix}cat
+ ln -s ${lld}/bin/lld $out/bin/${prefix}ld
+''
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/clang/clang-extension-handling.patch b/nixpkgs/pkgs/development/compilers/llvm/10/clang/clang-extension-handling.patch
new file mode 100644
index 00000000000..a74d10989ff
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/clang-extension-handling.patch
@@ -0,0 +1,18 @@
+Compressed diff from
+```
+git show d21664cce1db8debe2528f36b1fbd2b8af9c9401 87dac7da68ea1e0adac78c59ef1891dcf9632b67 3a0f6e699bb6d96dc62dce6faef20ac26cf103fd
+```
+with the purpose of avoiding linker errors arising in the polly-flavoured clang.
+
+diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
+index 781c3eb7f2f..dc1413f4b59 100644
+--- clang/CMakeLists.txt
++++ clang/CMakeLists.txt
+@@ -864,6 +864,7 @@ add_subdirectory(utils/hmaptool)
+
+ if(CLANG_BUILT_STANDALONE)
+ llvm_distribution_add_targets()
++ process_llvm_pass_plugins()
+ endif()
+
+ configure_file(
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/clang/compiler-rt-baremetal.patch b/nixpkgs/pkgs/development/compilers/llvm/10/clang/compiler-rt-baremetal.patch
new file mode 100644
index 00000000000..a4a0f21b0fc
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/compiler-rt-baremetal.patch
@@ -0,0 +1,53 @@
+Index: lib/Driver/ToolChains/BareMetal.cpp
+===================================================================
+--- a/lib/Driver/ToolChains/BareMetal.cpp
++++ b/lib/Driver/ToolChains/BareMetal.cpp
+@@ -157,7 +157,7 @@
+ void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
+- getTriple().getArchName() + ".a"));
++ getTriple().getArchName()));
+ }
+
+ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+Index: test/Driver/baremetal.cpp
+===================================================================
+--- a/test/Driver/baremetal.cpp
++++ b/test/Driver/baremetal.cpp
+@@ -13,7 +13,7 @@
+ // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+ // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+ // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
+-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
++// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+ // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+@@ -35,7 +35,7 @@
+ // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+ // CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+ // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
++// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+ // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
+
+ // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+@@ -48,7 +48,7 @@
+ // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+ // CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+ // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
++// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+ // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
+
+ // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+@@ -61,7 +61,7 @@
+ // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+ // CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+ // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
+-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
++// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+ // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
+
+ // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix
new file mode 100644
index 00000000000..13fe4bedd46
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix
@@ -0,0 +1,121 @@
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+, fixDarwinDylibNames
+, enableManpages ? false
+}:
+
+let
+ self = stdenv.mkDerivation ({
+ pname = "clang";
+ inherit version;
+
+ src = fetch "clang" "1w7ixr16a9f0g5kv4irvhwq973wn0d418kb0p9rabyfscm05wfmq";
+
+ unpackPhase = ''
+ unpackFile $src
+ mv clang-${version}* clang
+ sourceRoot=$PWD/clang
+ unpackFile ${clang-tools-extra_src}
+ mv clang-tools-extra-* $sourceRoot/tools/extra
+ '';
+
+ nativeBuildInputs = [ cmake python3 lld ]
+ ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
+
+ buildInputs = [ libxml2 llvm ]
+ ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+ cmakeFlags = [
+ "-DCMAKE_CXX_FLAGS=-std=c++14"
+ "-DCLANGD_BUILD_XPC=OFF"
+ ] ++ stdenv.lib.optionals enableManpages [
+ "-DCLANG_INCLUDE_DOCS=ON"
+ "-DLLVM_ENABLE_SPHINX=ON"
+ "-DSPHINX_OUTPUT_MAN=ON"
+ "-DSPHINX_OUTPUT_HTML=OFF"
+ "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+ ];
+
+ patches = [
+ # 10.0.0rc3-only
+ ./clang-extension-handling.patch
+
+ ./purity.patch
+ # https://reviews.llvm.org/D51899
+ ./compiler-rt-baremetal.patch
+ ];
+
+ postPatch = ''
+ sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
+ -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
+ lib/Driver/ToolChains/*.cpp
+
+ # Patch for standalone doc building
+ sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+ sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+ substituteInPlace tools/extra/clangd/CMakeLists.txt \
+ --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
+ '';
+
+ outputs = [ "out" "lib" "python" ];
+
+ # Clang expects to find LLVMgold in its own prefix
+ postInstall = ''
+ if [ -e ${llvm}/lib/LLVMgold.so ]; then
+ ln -sv ${llvm}/lib/LLVMgold.so $out/lib
+ fi
+
+ ln -sv $out/bin/clang $out/bin/cpp
+
+ # Move libclang to 'lib' output
+ moveToOutput "lib/libclang.*" "$lib"
+ moveToOutput "lib/libclang-cpp.*" "$lib"
+ substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
+ --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
+ --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
+
+ mkdir -p $python/bin $python/share/clang/
+ mv $out/bin/{git-clang-format,scan-view} $python/bin
+ if [ -e $out/bin/set-xcode-analyzer ]; then
+ mv $out/bin/set-xcode-analyzer $python/bin
+ fi
+ mv $out/share/clang/*.py $python/share/clang
+ rm $out/bin/c-index-test
+ '';
+
+ enableParallelBuilding = true;
+
+ passthru = {
+ isClang = true;
+ inherit llvm;
+ } // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) {
+ gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
+ };
+
+ meta = {
+ description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
+ homepage = http://llvm.org/;
+ license = stdenv.lib.licenses.ncsa;
+ platforms = stdenv.lib.platforms.all;
+ };
+ } // stdenv.lib.optionalAttrs enableManpages {
+ pname = "clang-manpages";
+
+ buildPhase = ''
+ make docs-clang-man
+ '';
+
+ installPhase = ''
+ mkdir -p $out/share/man/man1
+ # Manually install clang manpage
+ cp docs/man/*.1 $out/share/man/man1/
+ '';
+
+ outputs = [ "out" ];
+
+ doCheck = false;
+
+ meta.description = "man page for Clang ${version}";
+ });
+in self
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/10/clang/purity.patch
new file mode 100644
index 00000000000..a6729a9b004
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/purity.patch
@@ -0,0 +1,30 @@
+From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Thu, 18 May 2017 11:56:12 -0500
+Subject: [PATCH] "purity" patch for 5.0
+
+---
+ lib/Driver/ToolChains/Gnu.cpp | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index fe3c0191bb..c6a482bece 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ if (!IsStatic) {
+ if (Args.hasArg(options::OPT_rdynamic))
+ CmdArgs.push_back("-export-dynamic");
+-
+- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
+- const std::string Loader =
+- D.DyldPrefix + ToolChain.getDynamicLinker(Args);
+- CmdArgs.push_back("-dynamic-linker");
+- CmdArgs.push_back(Args.MakeArgString(Loader));
+- }
+ }
+
+ CmdArgs.push_back("-o");
+--
+2.11.0
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt-codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt-codesign.patch
new file mode 100644
index 00000000000..3cc12b94b20
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt-codesign.patch
@@ -0,0 +1,33 @@
+From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Tue, 19 Sep 2017 13:13:06 -0500
+Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that
+ needs it
+
+---
+ cmake/Modules/AddCompilerRT.cmake | 8 ------
+ test/asan/CMakeLists.txt | 52 ---------------------------------------
+ test/tsan/CMakeLists.txt | 47 -----------------------------------
+ 3 files changed, 107 deletions(-)
+
+diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
+index bc5fb9ff7..b64eb4246 100644
+--- a/cmake/Modules/AddCompilerRT.cmake
++++ b/cmake/Modules/AddCompilerRT.cmake
+@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type)
+ set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
+ set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
+ endif()
+- if(APPLE)
+- # Ad-hoc sign the dylibs
+- add_custom_command(TARGET ${libname}
+- POST_BUILD
+- COMMAND codesign --sign - $<TARGET_FILE:${libname}>
+- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+- )
+- endif()
+ endif()
+ install(TARGETS ${libname}
+ ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+2.14.1
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix
new file mode 100644
index 00000000000..2d71268c662
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix
@@ -0,0 +1,73 @@
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+stdenv.mkDerivation rec {
+ pname = "compiler-rt";
+ inherit version;
+ src = fetch pname "0qv40mv91630l6f75w9g5y6v97s5shz94n82rms12gcd8mir6qp5";
+
+ nativeBuildInputs = [ cmake python3 llvm ];
+ buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+
+ NIX_CFLAGS_COMPILE = [
+ "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
+ ];
+
+ cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
+ "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
+ "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
+ "-DCMAKE_C_FLAGS=-nodefaultlibs"
+ "-DCMAKE_CXX_COMPILER_WORKS=ON"
+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
+ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
+ "-DCOMPILER_RT_BUILD_PROFILE=OFF"
+ "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
+ #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
+ "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
+ "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
+ ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
+ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
+ "-DCOMPILER_RT_BUILD_PROFILE=OFF"
+ ] ++ stdenv.lib.optionals (stdenv.hostPlatform.parsed.kernel.name == "none") [
+ "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
+ "-DCOMPILER_RT_OS_DIR=baremetal"
+ ];
+
+ outputs = [ "out" "dev" ];
+
+ patches = [
+ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
+ ./find-darwin-sdk-version.patch # don't test for macOS being >= 10.15
+ ];# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+
+ # 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 cmake/config-ix.cmake \
+ --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
+ '' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) ''
+ substituteInPlace lib/builtins/int_util.c \
+ --replace "#include <stdlib.h>" ""
+ substituteInPlace lib/builtins/clear_cache.c \
+ --replace "#include <assert.h>" ""
+ substituteInPlace lib/builtins/cpu_model.c \
+ --replace "#include <assert.h>" ""
+ '';
+
+ # Hack around weird upsream RPATH bug
+ postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+ ln -s "$out/lib"/*/* "$out/lib"
+ '' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) ''
+ ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
+ ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
+ ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
+ ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
+ '';
+
+ enableParallelBuilding = true;
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix
new file mode 100644
index 00000000000..f2a8883a9a7
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix
@@ -0,0 +1,203 @@
+{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
+, 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
+}:
+
+let
+ release_version = "10.0.0";
+ candidate = "rc3";
+ version = "10.0.0${candidate}"; # differentiating these is important for rc's
+
+ fetch = name: sha256: fetchurl {
+ url = "https://prereleases.llvm.org/${release_version}/${candidate}/${name}-${version}.src.tar.xz";
+ inherit sha256;
+ };
+
+ clang-tools-extra_src = fetch "clang-tools-extra" "03669c93wzmbmfpv0pyzb7y4z1xc912l95iqywyx01xgdl1xws0r";
+
+ tools = stdenv.lib.makeExtensible (tools: let
+ callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
+ mkExtraBuildCommands = cc: ''
+ rsrc="$out/resource-root"
+ mkdir "$rsrc"
+ ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
+ ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
+ echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
+ '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && tools.clang-unwrapped ? gcc && !(stdenv.targetPlatform.useLLVM or false)) ''
+ echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
+ '';
+ in {
+
+ llvm = callPackage ./llvm.nix { };
+ llvm-polly = callPackage ./llvm.nix { enablePolly = true; };
+
+ clang-unwrapped = callPackage ./clang {
+ inherit (tools) lld;
+ inherit clang-tools-extra_src;
+ };
+ clang-polly-unwrapped = callPackage ./clang {
+ inherit clang-tools-extra_src;
+ llvm = tools.llvm-polly;
+ };
+
+ llvm-manpages = lowPrio (tools.llvm.override {
+ enableManpages = true;
+ python3 = pkgs.python3; # don't use python-boot
+ });
+
+ clang-manpages = lowPrio (tools.clang-unwrapped.override {
+ enableManpages = true;
+ python3 = pkgs.python3; # don't use python-boot
+ });
+
+ lldb-manpages = lowPrio (tools.lldb.override {
+ enableManpages = true;
+ 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 {
+ cc = tools.clang-unwrapped;
+ extraPackages = [
+ libstdcxxHook
+ targetLlvmLibraries.compiler-rt
+ ];
+ extraBuildCommands = mkExtraBuildCommands cc;
+ };
+
+ libcxxClang = wrapCCWith rec {
+ cc = tools.clang-unwrapped;
+ libcxx = targetLlvmLibraries.libcxx;
+ extraPackages = [
+ targetLlvmLibraries.libcxx
+ targetLlvmLibraries.libcxxabi
+ targetLlvmLibraries.compiler-rt
+ ];
+ extraBuildCommands = mkExtraBuildCommands cc;
+ };
+
+ lld = callPackage ./lld.nix {};
+
+ 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
+ ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
+ targetLlvmLibraries.libunwind
+ ];
+ extraBuildCommands = ''
+ echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
+ echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
+ echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
+ '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+ echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
+ '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+ echo "-fno-exceptions" >> $out/nix-support/cc-cflags
+ '' + mkExtraBuildCommands cc;
+ };
+
+ lldClangNoLibcxx = wrapCCWith rec {
+ cc = tools.clang-unwrapped;
+ libcxx = null;
+ bintools = wrapBintoolsWith {
+ inherit (tools) bintools;
+ };
+ extraPackages = [
+ targetLlvmLibraries.compiler-rt
+ ];
+ extraBuildCommands = ''
+ echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
+ echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
+ echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
+ echo "-nostdlib++" >> $out/nix-support/cc-cflags
+ '' + mkExtraBuildCommands cc;
+ };
+
+ lldClangNoLibc = wrapCCWith rec {
+ cc = tools.clang-unwrapped;
+ libcxx = null;
+ bintools = wrapBintoolsWith {
+ inherit (tools) bintools;
+ libc = null;
+ };
+ extraPackages = [
+ targetLlvmLibraries.compiler-rt
+ ];
+ extraBuildCommands = ''
+ echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
+ echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
+ echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
+ '' + mkExtraBuildCommands cc;
+ };
+
+ lldClangNoCompilerRt = wrapCCWith {
+ cc = tools.clang-unwrapped;
+ libcxx = null;
+ bintools = wrapBintoolsWith {
+ inherit (tools) bintools;
+ libc = null;
+ };
+ extraPackages = [ ];
+ extraBuildCommands = ''
+ echo "-nostartfiles" >> $out/nix-support/cc-cflags
+ echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
+ '';
+ };
+
+ });
+
+ libraries = stdenv.lib.makeExtensible (libraries: let
+ callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
+ in {
+
+ 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++ ({} //
+ (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+ stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
+ }));
+
+ 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
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/find-darwin-sdk-version.patch b/nixpkgs/pkgs/development/compilers/llvm/10/find-darwin-sdk-version.patch
new file mode 100644
index 00000000000..fc16ddda76b
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/find-darwin-sdk-version.patch
@@ -0,0 +1,62 @@
+--- a/cmake/Modules/CompilerRTDarwinUtils.cmake 2020-01-25 23:13:55.000000000 +0100
++++ b/cmake/Modules/CompilerRTDarwinUtils.cmake 2020-01-25 23:19:37.000000000 +0100
+@@ -43,41 +43,6 @@
+ set(DARWIN_${sdk_name}_CACHED_SYSROOT ${var_internal} CACHE STRING "Darwin SDK path for SDK ${sdk_name}." FORCE)
+ endfunction()
+
+-function(find_darwin_sdk_version var sdk_name)
+- # We deliberately don't cache the result here because
+- # CMake's caching causes too many problems.
+- set(result_process 1)
+- if(NOT DARWIN_PREFER_PUBLIC_SDK)
+- # Let's first try the internal SDK, otherwise use the public SDK.
+- execute_process(
+- COMMAND xcrun --sdk ${sdk_name}.internal --show-sdk-version
+- RESULT_VARIABLE result_process
+- OUTPUT_VARIABLE var_internal
+- OUTPUT_STRIP_TRAILING_WHITESPACE
+- ERROR_FILE /dev/null
+- )
+- endif()
+- if((NOT ${result_process} EQUAL 0) OR "" STREQUAL "${var_internal}")
+- execute_process(
+- COMMAND xcrun --sdk ${sdk_name} --show-sdk-version
+- RESULT_VARIABLE result_process
+- OUTPUT_VARIABLE var_internal
+- OUTPUT_STRIP_TRAILING_WHITESPACE
+- ERROR_FILE /dev/null
+- )
+- endif()
+- if(NOT result_process EQUAL 0)
+- message(FATAL_ERROR
+- "Failed to determine SDK version for \"${sdk_name}\" SDK")
+- endif()
+- # Check reported version looks sane.
+- if (NOT "${var_internal}" MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+)?$")
+- message(FATAL_ERROR
+- "Reported SDK version \"${var_internal}\" does not look like a version")
+- endif()
+- set(${var} ${var_internal} PARENT_SCOPE)
+-endfunction()
+-
+ # There isn't a clear mapping of what architectures are supported with a given
+ # target platform, but ld's version output does list the architectures it can
+ # link for.
+@@ -119,17 +84,6 @@
+ foreach(flag ${DARWIN_${os}_LINK_FLAGS})
+ set(os_linker_flags "${os_linker_flags} ${flag}")
+ endforeach()
+-
+- # Disable building for i386 for macOS SDK >= 10.15. The SDK doesn't support
+- # linking for i386 and the corresponding OS doesn't allow running macOS i386
+- # binaries.
+- if ("${os}" STREQUAL "osx")
+- find_darwin_sdk_version(macosx_sdk_version "macosx")
+- if ("${macosx_sdk_version}" VERSION_GREATER 10.15 OR "${macosx_sdk_version}" VERSION_EQUAL 10.15)
+- message(STATUS "Disabling i386 slice for ${valid_archs}")
+- list(REMOVE_ITEM archs "i386")
+- endif()
+- endif()
+ endif()
+
+ # The simple program will build for x86_64h on the simulator because it is
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix
new file mode 100644
index 00000000000..767b1cbbc58
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix
@@ -0,0 +1,55 @@
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
+, enableShared ? true }:
+
+stdenv.mkDerivation {
+ pname = "libc++";
+ inherit version;
+
+ src = fetch "libcxx" "1cjxiby8nq95g02rgx08iy86pswpi66b9wmxqjiyga1s92nb19j0";
+
+ postUnpack = ''
+ unpackFile ${libcxxabi.src}
+ export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
+ '';
+
+ patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+
+ preConfigure = ''
+ # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
+ cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
+ '' + lib.optionalString stdenv.hostPlatform.isMusl ''
+ patchShebangs utils/cat_files.py
+ '';
+ nativeBuildInputs = [ cmake ]
+ ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3;
+
+ buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+ cmakeFlags = [
+ "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
+ "-DLIBCXX_LIBCPPABI_VERSION=2"
+ "-DLIBCXX_CXX_ABI=libcxxabi"
+ ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
+ ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
+ ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
+ "-DLIBCXX_ENABLE_THREADS=OFF"
+ "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+ "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+ ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
+
+ enableParallelBuilding = true;
+
+ linkCxxAbi = stdenv.isLinux;
+
+ setupHooks = [
+ ../../../../../build-support/setup-hooks/role.bash
+ ./setup-hook.sh
+ ];
+
+ meta = {
+ homepage = http://libcxx.llvm.org/;
+ description = "A new implementation of the C++ standard library, targeting C++11";
+ license = with stdenv.lib.licenses; [ ncsa mit ];
+ platforms = stdenv.lib.platforms.all;
+ };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh
new file mode 100644
index 00000000000..6611259165a
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh
@@ -0,0 +1,6 @@
+# See pkgs/build-support/setup-hooks/role.bash
+getHostRole
+
+linkCxxAbi="@linkCxxAbi@"
+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix
new file mode 100644
index 00000000000..8ad52b5ed57
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix
@@ -0,0 +1,67 @@
+{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
+, enableShared ? true }:
+
+stdenv.mkDerivation {
+ pname = "libc++abi";
+ inherit version;
+
+ src = fetch "libcxxabi" "1xs7dr91qzz7lq9am4q3vcj2jf1gx23ar1jbnhn763011hl94vs0";
+
+ nativeBuildInputs = [ cmake ];
+ buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
+
+ cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+ "-DLLVM_ENABLE_LIBCXX=ON"
+ "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+ ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
+ "-DLIBCXXABI_ENABLE_THREADS=OFF"
+ "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+ ] ++ stdenv.lib.optionals (!enableShared) [
+ "-DLIBCXXABI_ENABLE_SHARED=OFF"
+ ];
+
+ patches = [ ./libcxxabi-no-threads.patch ];
+
+ postUnpack = ''
+ unpackFile ${libcxx.src}
+ unpackFile ${llvm.src}
+ cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export TRIPLE=x86_64-apple-darwin
+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+ patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
+ patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch}
+ '';
+
+ installPhase = if stdenv.isDarwin
+ then ''
+ for file in lib/*.dylib; do
+ # this should be done in CMake, but having trouble figuring out
+ # the magic combination of necessary CMake variables
+ # if you fancy a try, take a look at
+ # http://www.cmake.org/Wiki/CMake_RPATH_handling
+ install_name_tool -id $out/$file $file
+ done
+ make install
+ install -d 755 $out/include
+ install -m 644 ../include/*.h $out/include
+ ''
+ else ''
+ install -d -m 755 $out/include $out/lib
+ install -m 644 lib/libc++abi.a $out/lib
+ install -m 644 ../include/cxxabi.h $out/include
+ '' + stdenv.lib.optionalString enableShared ''
+ install -m 644 lib/libc++abi.so.1.0 $out/lib
+ ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
+ ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
+ '';
+
+ meta = {
+ homepage = http://libcxxabi.llvm.org/;
+ description = "A new implementation of low level support for a standard C++ library";
+ license = with stdenv.lib.licenses; [ ncsa mit ];
+ maintainers = with stdenv.lib.maintainers; [ vlstill ];
+ platforms = stdenv.lib.platforms.all;
+ };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-no-threads.patch b/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-no-threads.patch
new file mode 100644
index 00000000000..787f3e16500
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-no-threads.patch
@@ -0,0 +1,12 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4138acf..41b4763 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -362,6 +362,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS)
+ " is also set to ON.")
+ endif()
+ add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
++ add_definitions(-D_LIBCPP_HAS_NO_THREADS)
+ endif()
+
+ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-wasm.patch b/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-wasm.patch
new file mode 100644
index 00000000000..4ebfe46aa81
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libcxxabi-wasm.patch
@@ -0,0 +1,16 @@
+diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
+index 15497d405e0..33f7f18193a 100644
+--- a/cmake/modules/HandleLLVMOptions.cmake
++++ b/cmake/modules/HandleLLVMOptions.cmake
+@@ -127,7 +127,10 @@ else(WIN32)
+ set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
+ endif()
+ else(FUCHSIA OR UNIX)
+- MESSAGE(SEND_ERROR "Unable to determine platform")
++ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi")
++ else()
++ MESSAGE(SEND_ERROR "Unable to determine platform")
++ endif()
+ endif(FUCHSIA OR UNIX)
+ endif(WIN32)
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix b/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix
new file mode 100644
index 00000000000..74a8687179f
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix
@@ -0,0 +1,14 @@
+{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
+
+stdenv.mkDerivation rec {
+ pname = "libunwind";
+ inherit version;
+
+ src = fetch pname "1dm7l75ajnjy6kbg2157v2g5gfia3n47fc56ayryyp2jdvbgprwl";
+
+ nativeBuildInputs = [ cmake ];
+
+ enableParallelBuilding = true;
+
+ cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix
new file mode 100644
index 00000000000..6323866ae88
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix
@@ -0,0 +1,33 @@
+{ stdenv
+, fetch
+, cmake
+, libxml2
+, llvm
+, version
+}:
+
+stdenv.mkDerivation rec {
+ pname = "lld";
+ inherit version;
+
+ src = fetch pname "1w9c9xmzbdnkwgal612hqz2lxj9jgqpfzxr2rllcspmf6v7arvf4";
+
+ nativeBuildInputs = [ cmake ];
+ buildInputs = [ llvm libxml2 ];
+
+ outputs = [ "out" "dev" ];
+
+ enableParallelBuilding = true;
+
+ postInstall = ''
+ moveToOutput include "$dev"
+ moveToOutput lib "$dev"
+ '';
+
+ meta = {
+ description = "The LLVM Linker";
+ homepage = http://lld.llvm.org/;
+ license = stdenv.lib.licenses.ncsa;
+ platforms = stdenv.lib.platforms.all;
+ };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lldb-procfs.patch b/nixpkgs/pkgs/development/compilers/llvm/10/lldb-procfs.patch
new file mode 100644
index 00000000000..b075dbaeee0
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/lldb-procfs.patch
@@ -0,0 +1,31 @@
+--- a/source/Plugins/Process/Linux/Procfs.h
++++ b/source/Plugins/Process/Linux/Procfs.h
+@@ -11,21 +11,12 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
+
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix
new file mode 100644
index 00000000000..fd318314dea
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix
@@ -0,0 +1,101 @@
+{ stdenv
+, fetch
+, cmake
+, zlib
+, ncurses
+, swig
+, which
+, libedit
+, libxml2
+, llvm
+, clang-unwrapped
+, python3
+, version
+, darwin
+, lit
+, enableManpages ? false
+}:
+
+stdenv.mkDerivation (rec {
+ pname = "lldb";
+ inherit version;
+
+ src = fetch pname "06qzh13cr20wrd5925698yq696bhl68zbvm7kjxp7c2rx5swxmg8";
+
+ patches = [ ./lldb-procfs.patch ];
+
+ nativeBuildInputs = [ cmake python3 which swig lit ]
+ ++ stdenv.lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
+
+ buildInputs = [
+ ncurses
+ zlib
+ libedit
+ libxml2
+ llvm
+ ]
+ ++ stdenv.lib.optionals stdenv.isDarwin [
+ darwin.libobjc
+ darwin.apple_sdk.libs.xpc
+ darwin.apple_sdk.frameworks.Foundation
+ darwin.bootstrap_cmds
+ darwin.apple_sdk.frameworks.Carbon
+ darwin.apple_sdk.frameworks.Cocoa
+ ];
+
+ CXXFLAGS = "-fno-rtti";
+ hardeningDisable = [ "format" ];
+
+ cmakeFlags = [
+ "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
+ "-DClang_DIR=${clang-unwrapped}/lib/cmake"
+ "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
+ ] ++ stdenv.lib.optionals stdenv.isDarwin [
+ "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
+ ] ++ stdenv.lib.optionals enableManpages [
+ "-DLLVM_ENABLE_SPHINX=ON"
+ "-DSPHINX_OUTPUT_MAN=ON"
+ "-DSPHINX_OUTPUT_HTML=OFF"
+ ]
+;
+
+ enableParallelBuilding = true;
+
+ postInstall = ''
+ # Editor support
+ # vscode:
+ install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
+ mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
+ ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
+ '';
+
+ meta = with stdenv.lib; {
+ description = "A next-generation high-performance debugger";
+ homepage = http://lldb.llvm.org;
+ license = licenses.ncsa;
+ platforms = platforms.all;
+ };
+} // stdenv.lib.optionalAttrs enableManpages {
+ pname = "lldb-manpages";
+
+ buildPhase = ''
+ make docs-lldb-man
+ '';
+
+ propagatedBuildInputs = [];
+
+ installPhase = ''
+ # manually install lldb man page
+ mkdir -p $out/share/man/man1
+ install docs/man/lldb.1 -t $out/share/man/man1/
+ '';
+
+ postPatch = null;
+ postInstall = null;
+
+ outputs = [ "out" ];
+
+ doCheck = false;
+
+ meta.description = "man pages for LLDB ${version}";
+})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch b/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch
new file mode 100644
index 00000000000..cf4b1eaacf7
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch
@@ -0,0 +1,146 @@
+Compressed diff from
+```
+git show d21664cce1db8debe2528f36b1fbd2b8af9c9401 87dac7da68ea1e0adac78c59ef1891dcf9632b67 3a0f6e699bb6d96dc62dce6faef20ac26cf103fd
+```
+with the purpose of avoiding linker errors arising in the polly-flavoured clang.
+
+diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
+index a02c2a5a23f..faf8f561faa 100644
+--- llvm/CMakeLists.txt
++++ llvm/CMakeLists.txt
+@@ -1069,6 +1069,7 @@ endif()
+ # after all targets are created.
+ include(LLVMDistributionSupport)
+ llvm_distribution_add_targets()
++process_llvm_pass_plugins(GEN_CONFIG)
+
+ # This allows us to deploy the Universal CRT DLLs by passing -DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
+ if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_INSTALL_UCRT_LIBRARIES)
+@@ -1093,5 +1094,3 @@ endif()
+ if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
+ add_subdirectory(utils/llvm-locstats)
+ endif()
+-
+-process_llvm_pass_plugins()
+diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
+index fd69786544a..8fbb33a22fd 100644
+--- llvm/cmake/modules/AddLLVM.cmake
++++ llvm/cmake/modules/AddLLVM.cmake
+@@ -884,53 +884,71 @@ function(add_llvm_pass_plugin name)
+ if (TARGET intrinsics_gen)
+ add_dependencies(obj.${name} intrinsics_gen)
+ endif()
+- message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
+- set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name})
++ set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
+ elseif(NOT ARG_NO_MODULE)
+ add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
+ else()
+ add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
+ endif()
++ message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
+
+ endfunction(add_llvm_pass_plugin)
+
+-# Generate X Macro file for extension handling. It provides a
+-# HANDLE_EXTENSION(extension_namespace, ExtensionProject) call for each extension
+-# allowing client code to define HANDLE_EXTENSION to have a specific code be run for
+-# each extension.
++# process_llvm_pass_plugins([GEN_CONFIG])
++#
++# Correctly set lib dependencies between plugins and tools, based on tools
++# registered with the ENABLE_PLUGINS option.
++#
++# if GEN_CONFIG option is set, also generate X Macro file for extension
++# handling. It provides a HANDLE_EXTENSION(extension_namespace, ExtensionProject)
++# call for each extension allowing client code to define
++# HANDLE_EXTENSION to have a specific code be run for each extension.
+ #
+-# Also correctly set lib dependencies between plugins and tools.
+ function(process_llvm_pass_plugins)
+- get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
+- file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
+- foreach(llvm_extension ${LLVM_EXTENSIONS})
+- string(TOLOWER ${llvm_extension} llvm_extension_lower)
+-
+- string(TOUPPER ${llvm_extension} llvm_extension_upper)
+- string(SUBSTRING ${llvm_extension_upper} 0 1 llvm_extension_upper_first)
+- string(SUBSTRING ${llvm_extension_lower} 1 -1 llvm_extension_lower_tail)
+- string(CONCAT llvm_extension_project ${llvm_extension_upper_first} ${llvm_extension_lower_tail})
+-
+- if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
+- file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")
+-
+- get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
+- foreach(llvm_plugin_target ${llvm_plugin_targets})
+- set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
+- set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+- endforeach()
+- else()
+- add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
+- endif()
++ cmake_parse_arguments(ARG
++ "GEN_CONFIG" "" ""
++ ${ARGN})
+
++ if(ARG_GEN_CONFIG)
++ get_property(LLVM_STATIC_EXTENSIONS GLOBAL PROPERTY LLVM_STATIC_EXTENSIONS)
++ else()
++ include(LLVMConfigExtensions)
++ endif()
++
++ # Add static plugins to each plugin target.
++ foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
++ get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
++ foreach(llvm_plugin_target ${llvm_plugin_targets})
++ set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
++ set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
++ endforeach()
+ endforeach()
+- file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "#undef HANDLE_EXTENSION\n")
+
+- # only replace if there's an actual change
+- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+- "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp"
+- "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
+- file(REMOVE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
++ # Eventually generate the extension header, and store config to a cmake file
++ # for usage in third-party configuration.
++ if(ARG_GEN_CONFIG)
++ set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
++ set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
++ file(WRITE
++ "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
++ "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
++ install(FILES
++ ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake
++ DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
++ COMPONENT cmake-exports)
++
++ file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
++ foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
++ file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension})\n")
++ endforeach()
++ file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "#undef HANDLE_EXTENSION\n")
++
++ # only replace if there's an actual change
++ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
++ "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp"
++ "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
++ file(REMOVE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
++ endif()
+ endfunction()
+
+ function(export_executable_symbols target)
+diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
+index 9cf22b436fa..af757d6199a 100644
+--- llvm/cmake/modules/CMakeLists.txt
++++ llvm/cmake/modules/CMakeLists.txt
+@@ -136,6 +136,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ FILES_MATCHING PATTERN *.cmake
+ PATTERN .svn EXCLUDE
+ PATTERN LLVMConfig.cmake EXCLUDE
++ PATTERN LLVMConfigExtensions.cmake EXCLUDE
+ PATTERN LLVMConfigVersion.cmake EXCLUDE
+ PATTERN LLVM-Config.cmake EXCLUDE
+ PATTERN GetHostTriple.cmake EXCLUDE)
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/10/llvm-outputs.patch
new file mode 100644
index 00000000000..40096fa3497
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/llvm-outputs.patch
@@ -0,0 +1,26 @@
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 94d426b..37f7794 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
++ if (!IsInDevelopmentTree) {
++ bool WantShared = true;
++ for (int i = 1; i < argc; ++i) {
++ StringRef Arg = argv[i];
++ if (Arg == "--link-shared")
++ WantShared = true;
++ else if (Arg == "--link-static")
++ WantShared = false; // the last one wins
++ }
++
++ if (WantShared)
++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
++ }
++
+ /// We only use `shared library` mode in cases where the static library form
+ /// of the components provided are not available; note however that this is
+ /// skipped if we're run from within the build dir. However, once installed,
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix
new file mode 100644
index 00000000000..eb93d8648f9
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix
@@ -0,0 +1,190 @@
+{ stdenv
+, fetch
+, cmake
+, python3
+, libffi
+, libbfd
+, libpfm
+, libxml2
+, ncurses
+, version
+, release_version
+, zlib
+, buildPackages
+, debugVersion ? false
+, enableManpages ? false
+, enableSharedLibraries ? true
+, enablePFM ? !(stdenv.isDarwin
+ || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
+)
+, enablePolly ? false
+}:
+
+let
+ inherit (stdenv.lib) optional optionals optionalString;
+
+ # Used when creating a version-suffixed symlink of libLLVM.dylib
+ shortVersion = with stdenv.lib;
+ concatStringsSep "." (take 1 (splitString "." release_version));
+
+in stdenv.mkDerivation (rec {
+ pname = "llvm";
+ inherit version;
+
+ src = fetch pname "1pa322iwqg071gxdn5wxri263j6aki6ag36xbdzbyi3g8m8v8jci";
+ polly_src = fetch "polly" "0p9dmv4hxwx4f5k1v4r9b5jp7fbi71ajpmrv3xf3vmp6m4i3r0pc";
+
+ unpackPhase = ''
+ unpackFile $src
+ mv llvm-${version}* llvm
+ sourceRoot=$PWD/llvm
+ '' + optionalString enablePolly ''
+ unpackFile $polly_src
+ mv polly-* $sourceRoot/tools/polly
+ '';
+
+ outputs = [ "out" "python" ]
+ ++ optional enableSharedLibraries "lib";
+
+ nativeBuildInputs = [ cmake python3 ]
+ ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
+
+ buildInputs = [ libxml2 libffi ]
+ ++ optional enablePFM libpfm; # exegesis
+
+ propagatedBuildInputs = [ ncurses zlib ];
+
+ patches = [
+ # 10.0.0rc3-only
+ ./llvm-extension-handling.patch
+ ];
+
+ postPatch = optionalString stdenv.isDarwin ''
+ substituteInPlace cmake/modules/AddLLVM.cmake \
+ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
+ --replace 'set(_install_rpath "@loader_path/../lib''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
+ ''
+ # Patch llvm-config to return correct library path based on --link-{shared,static}.
+ + optionalString (enableSharedLibraries) ''
+ substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
+ patch -p1 < ./llvm-outputs.patch
+ '' + ''
+ # FileSystem permissions tests fail with various special bits
+ substituteInPlace unittests/Support/CMakeLists.txt \
+ --replace "Path.cpp" ""
+ rm unittests/Support/Path.cpp
+ '' + optionalString stdenv.hostPlatform.isMusl ''
+ patch -p1 -i ${../TLI-musl.patch}
+ substituteInPlace unittests/Support/CMakeLists.txt \
+ --replace "add_subdirectory(DynamicLibrary)" ""
+ rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+ # valgrind unhappy with musl or glibc, but fails w/musl only
+ rm test/CodeGen/AArch64/wineh4.mir
+ '' + optionalString stdenv.hostPlatform.isAarch32 ''
+ # skip failing X86 test cases on 32-bit ARM
+ rm test/DebugInfo/X86/convert-debugloc.ll
+ rm test/DebugInfo/X86/convert-inlined.ll
+ rm test/DebugInfo/X86/convert-linked.ll
+ rm test/tools/dsymutil/X86/op-convert.test
+ '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
+ # Seems to require certain floating point hardware (NEON?)
+ rm test/ExecutionEngine/frem.ll
+ '' + ''
+ patchShebangs test/BugPoint/compile-custom.ll.py
+ '';
+
+ # hacky fix: created binaries need to be run before installation
+ preBuild = ''
+ mkdir -p $out/
+ ln -sv $PWD/lib $out
+ '';
+
+ cmakeFlags = with stdenv; [
+ "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
+ "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
+ "-DLLVM_BUILD_TESTS=ON"
+ "-DLLVM_ENABLE_FFI=ON"
+ "-DLLVM_ENABLE_RTTI=ON"
+ "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
+ "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
+ "-DLLVM_ENABLE_DUMP=ON"
+ ] ++ optionals enableSharedLibraries [
+ "-DLLVM_LINK_LLVM_DYLIB=ON"
+ ] ++ optionals enableManpages [
+ "-DLLVM_BUILD_DOCS=ON"
+ "-DLLVM_ENABLE_SPHINX=ON"
+ "-DSPHINX_OUTPUT_MAN=ON"
+ "-DSPHINX_OUTPUT_HTML=OFF"
+ "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+ ] ++ optionals (!isDarwin) [
+ "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
+ ] ++ optionals isDarwin [
+ "-DLLVM_ENABLE_LIBCXX=ON"
+ "-DCAN_TARGET_i386=false"
+ ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+ "-DCMAKE_CROSSCOMPILING=True"
+ "-DLLVM_TABLEGEN=${buildPackages.llvm_10}/bin/llvm-tblgen"
+ ];
+
+ postBuild = ''
+ rm -fR $out
+ '';
+
+ preCheck = ''
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
+ '';
+
+ postInstall = ''
+ mkdir -p $python/share
+ mv $out/share/opt-viewer $python/share/opt-viewer
+ ''
+ + optionalString enableSharedLibraries ''
+ moveToOutput "lib/libLLVM-*" "$lib"
+ moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
+ ''
+ + optionalString (enableSharedLibraries && (!stdenv.isDarwin)) ''
+ substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
+ ''
+ + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+ substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
+ ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
+ ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+ '';
+
+ doCheck = stdenv.isLinux && (!stdenv.isx86_32);
+
+ checkTarget = "check-all";
+
+ enableParallelBuilding = true;
+
+ meta = {
+ description = "Collection of modular and reusable compiler and toolchain technologies";
+ homepage = http://llvm.org/;
+ license = stdenv.lib.licenses.ncsa;
+ maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
+ platforms = stdenv.lib.platforms.all;
+ };
+} // stdenv.lib.optionalAttrs enableManpages {
+ pname = "llvm-manpages";
+
+ buildPhase = ''
+ make docs-llvm-man
+ '';
+
+ propagatedBuildInputs = [];
+
+ installPhase = ''
+ make -C docs install
+ '';
+
+ postPatch = null;
+ postInstall = null;
+
+ outputs = [ "out" ];
+
+ doCheck = false;
+
+ meta.description = "man pages for LLVM ${version}";
+})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix
new file mode 100644
index 00000000000..cff2ad36536
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix
@@ -0,0 +1,26 @@
+{ stdenv
+, fetch
+, cmake
+, llvm
+, perl
+, version
+}:
+
+stdenv.mkDerivation rec {
+ pname = "openmp";
+ inherit version;
+
+ src = fetch pname "0axdxar18rvk9r4yx7y55ywqr3070mixag9sg2fcck1jzwfgymjb";
+
+ nativeBuildInputs = [ cmake perl ];
+ buildInputs = [ llvm ];
+
+ enableParallelBuilding = true;
+
+ meta = {
+ description = "Components required to build an executable OpenMP program";
+ homepage = http://openmp.llvm.org/;
+ license = stdenv.lib.licenses.mit;
+ platforms = stdenv.lib.platforms.all;
+ };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/10/sanitizers-nongnu.patch
new file mode 100644
index 00000000000..1f2ac97818e
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/sanitizers-nongnu.patch
@@ -0,0 +1,412 @@
+From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Mon, 24 Sep 2018 11:17:25 -0500
+Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project.
+
+------
+Ported to compiler-rt-sanitizers-5.0.0. Taken from
+
+https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
+Signed-off-by: Jory A. Pratt <anarchy@gentoo.org>
+
+Taken from gentoo-musl project, with a few additional minor fixes.
+---
+ lib/asan/asan_linux.cc | 4 +-
+ lib/interception/interception_linux.cc | 2 +-
+ lib/interception/interception_linux.h | 2 +-
+ lib/msan/msan_linux.cc | 2 +-
+ lib/sanitizer_common/sanitizer_allocator.cc | 2 +-
+ .../sanitizer_common_interceptors_ioctl.inc | 4 +-
+ .../sanitizer_common_syscalls.inc | 2 +-
+ lib/sanitizer_common/sanitizer_linux.cc | 8 +++-
+ .../sanitizer_linux_libcdep.cc | 10 ++---
+ lib/sanitizer_common/sanitizer_platform.h | 6 +++
+ .../sanitizer_platform_interceptors.h | 4 +-
+ .../sanitizer_platform_limits_posix.cc | 37 +++++++++++--------
+ lib/tsan/rtl/tsan_platform_linux.cc | 2 +-
+ 13 files changed, 51 insertions(+), 34 deletions(-)
+
+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
+index 625f32d40..73cf77aca 100644
+--- a/lib/asan/asan_linux.cc
++++ b/lib/asan/asan_linux.cc
+@@ -46,7 +46,7 @@
+ #include <link.h>
+ #endif
+
+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
+ #include <ucontext.h>
+ extern "C" void* _DYNAMIC;
+ #elif SANITIZER_NETBSD
+@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
+ UNIMPLEMENTED();
+ }
+
+-#if SANITIZER_ANDROID
++#if SANITIZER_ANDROID || SANITIZER_NONGNU
+ // FIXME: should we do anything for Android?
+ void AsanCheckDynamicRTPrereqs() {}
+ void AsanCheckIncompatibleRT() {}
+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
+index 26bfcd8f6..529b234f7 100644
+--- a/lib/interception/interception_linux.cc
++++ b/lib/interception/interception_linux.cc
+@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+ }
+
+ // Android and Solaris do not have dlvsym
+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
+ return dlvsym(RTLD_NEXT, func_name, ver);
+ }
+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
+index 942c25609..24a4d5080 100644
+--- a/lib/interception/interception_linux.h
++++ b/lib/interception/interception_linux.h
+@@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
+ (::__interception::uptr) & WRAP(func))
+
+ // Android, Solaris and OpenBSD do not have dlvsym
+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+ (::__interception::real_##func = (func##_f)( \
+ unsigned long)::__interception::GetFuncAddrVer(#func, symver))
+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
+index 385a650c4..6e30a8ce9 100644
+--- a/lib/msan/msan_linux.cc
++++ b/lib/msan/msan_linux.cc
+@@ -13,7 +13,7 @@
+ //===----------------------------------------------------------------------===//
+
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD
+
+ #include "msan.h"
+ #include "msan_report.h"
+diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc
+index 6bfd5e5ee..048f6154f 100644
+--- a/lib/sanitizer_common/sanitizer_allocator.cc
++++ b/lib/sanitizer_common/sanitizer_allocator.cc
+@@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator";
+
+ // ThreadSanitizer for Go uses libc malloc/free.
+ #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC)
+-# if SANITIZER_LINUX && !SANITIZER_ANDROID
++# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ extern "C" void *__libc_malloc(uptr size);
+ # if !SANITIZER_GO
+ extern "C" void *__libc_memalign(uptr alignment, uptr size);
+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+index 2d633c173..b6eb23116 100644
+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+@@ -104,7 +104,7 @@ static void ioctl_table_fill() {
+ _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
+ #endif
+
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ // Conflicting request ids.
+ // _(CDROMAUDIOBUFSIZ, NONE, 0);
+ // _(SNDCTL_TMR_CONTINUE, NONE, 0);
+@@ -365,7 +365,7 @@ static void ioctl_table_fill() {
+ _(VT_WAITACTIVE, NONE, 0);
+ #endif
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+ _(CYGETDEFTHRESH, WRITE, sizeof(int));
+ _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+index 469c8eb7e..24f87867d 100644
+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
+ }
+ }
+
+-#if !SANITIZER_ANDROID
++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
+ void *old_rlim) {
+ if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
+diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc
+index 96d6c1eff..9e2b7fb9d 100644
+--- a/lib/sanitizer_common/sanitizer_linux.cc
++++ b/lib/sanitizer_common/sanitizer_linux.cc
+@@ -541,13 +541,13 @@ const char *GetEnv(const char *name) {
+ #endif
+ }
+
+-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
+ extern "C" {
+ SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;
+ }
+ #endif
+
+-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
++#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
+ !SANITIZER_OPENBSD
+ static void ReadNullSepFileToArray(const char *path, char ***arr,
+ int arr_size) {
+@@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) {
+ #elif SANITIZER_NETBSD
+ *argv = __ps_strings->ps_argvstr;
+ *envp = __ps_strings->ps_envstr;
++#elif SANITIZER_NONGNU
++ static const int kMaxArgv = 2000, kMaxEnvp = 2000;
++ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv);
++ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp);
+ #else // SANITIZER_FREEBSD
+ #if !SANITIZER_GO
+ if (&__libc_stack_end) {
+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+index 4962ff832..438f94dbe 100644
+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+@@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
+ }
+
+ #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
+- !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS
++ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
+ static uptr g_tls_size;
+
+ #ifdef __i386__
+@@ -261,7 +261,7 @@ void InitTlsSize() { }
+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \
+ defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \
+ defined(__arm__)) && \
+- SANITIZER_LINUX && !SANITIZER_ANDROID
++ SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // sizeof(struct pthread) from glibc.
+ static atomic_uintptr_t thread_descriptor_size;
+
+@@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
+
+ #if !SANITIZER_GO
+ static void GetTls(uptr *addr, uptr *size) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
+ *addr = ThreadSelf();
+ *size = GetTlsSize();
+@@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) {
+ #elif SANITIZER_OPENBSD
+ *addr = 0;
+ *size = 0;
+-#elif SANITIZER_ANDROID
++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
+ *addr = 0;
+ *size = 0;
+ #elif SANITIZER_SOLARIS
+@@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) {
+ #if !SANITIZER_GO
+ uptr GetTlsSize() {
+ #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \
+- SANITIZER_OPENBSD || SANITIZER_SOLARIS
++ SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
+ uptr addr, size;
+ GetTls(&addr, &size);
+ return size;
+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
+index d81e25580..e10680ac8 100644
+--- a/lib/sanitizer_common/sanitizer_platform.h
++++ b/lib/sanitizer_common/sanitizer_platform.h
+@@ -208,6 +208,12 @@
+ # define SANITIZER_SOLARIS32 0
+ #endif
+
++#if defined(__linux__) && !defined(__GLIBC__)
++# define SANITIZER_NONGNU 1
++#else
++# define SANITIZER_NONGNU 0
++#endif
++
+ #if defined(__myriad2__)
+ # define SANITIZER_MYRIAD2 1
+ #else
+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+index f95539a73..6c53b3415 100644
+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -39,7 +39,7 @@
+ # include "sanitizer_platform_limits_solaris.h"
+ #endif
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # define SI_LINUX_NOT_ANDROID 1
+ #else
+ # define SI_LINUX_NOT_ANDROID 0
+@@ -322,7 +322,7 @@
+ #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID)
+ #define SANITIZER_INTERCEPT_SHMCTL \
+ (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \
+- ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
++ ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \
+ SANITIZER_WORDSIZE == 64)) // NOLINT
+ #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
+ #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX
+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+index 54da635d7..2f6ff69c3 100644
+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -14,6 +14,9 @@
+
+ #include "sanitizer_platform.h"
+
++// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
++#define _LINUX_SYSINFO_H
++
+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
+ // Tests in this file assume that off_t-dependent data structures match the
+ // libc ABI. For example, struct dirent here is what readdir() function (as
+@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ #include <glob.h>
+-#include <obstack.h>
++# if !SANITIZER_NONGNU
++# include <obstack.h>
++# endif
+ #include <mqueue.h>
+-#include <net/if_ppp.h>
+-#include <netax25/ax25.h>
+-#include <netipx/ipx.h>
+-#include <netrom/netrom.h>
++#include <linux/if_ppp.h>
++#include <linux/ax25.h>
++#include <linux/ipx.h>
++#include <linux/netrom.h>
+ #if HAVE_RPC_XDR_H
+ # include <rpc/xdr.h>
+ #elif HAVE_TIRPC_RPC_XDR_H
+@@ -251,7 +256,7 @@ namespace __sanitizer {
+ unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
+ // has been removed from glibc 2.28.
+ #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
+@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif
+
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ int glob_nomatch = GLOB_NOMATCH;
+ int glob_altdirfunc = GLOB_ALTDIRFUNC;
+ #endif
+@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned struct_termios_sz = sizeof(struct termios);
+ unsigned struct_winsize_sz = sizeof(struct winsize);
+
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ unsigned struct_arpreq_sz = sizeof(struct arpreq);
+ unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
+ unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
+@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+ unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+ #if EV_VERSION > (0x010000)
+@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
+ unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
+ unsigned IOCTL_CYGETMON = CYGETMON;
+@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(glob_t);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
+@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
+
++#if !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(msghdr);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
+@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
++#endif
+
+ #ifndef __GLIBC_PREREQ
+ #define __GLIBC_PREREQ(x, y) 0
+@@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
+
+ CHECK_TYPE_SIZE(ether_addr);
+
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(ipc_perm);
+ # if SANITIZER_FREEBSD
+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
+@@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
+ #endif
+
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
+ #endif
+
+@@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
+ #endif
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
+@@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
+ #endif
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
+index de989b780..51a97b554 100644
+--- a/lib/tsan/rtl/tsan_platform_linux.cc
++++ b/lib/tsan/rtl/tsan_platform_linux.cc
+@@ -294,7 +294,7 @@ void InitializePlatform() {
+ // This is required to properly "close" the fds, because we do not see internal
+ // closes within glibc. The code is a pure hack.
+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ int cnt = 0;
+ struct __res_state *statp = (struct __res_state*)state;
+ for (int i = 0; i < MAXNS && cnt < nfd; i++) {
+--
+2.19.0
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-sys-ustat.patch b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-sys-ustat.patch
new file mode 100644
index 00000000000..d9e9a10d860
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-sys-ustat.patch
@@ -0,0 +1,58 @@
+From 521935db9de17ad08748fd050137ac83b7734835 Mon Sep 17 00:00:00 2001
+From: Craig Topper <craig.topper@intel.com>
+Date: Thu, 24 May 2018 17:59:47 +0000
+Subject: [PATCH] sanitizer: Use pre-computed size of struct ustat for Linux
+
+<sys/ustat.h> has been removed from glibc 2.28 by:
+
+commit cf2478d53ad7071e84c724a986b56fe17f4f4ca7
+Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
+Date: Sun Mar 18 11:28:59 2018 +0800
+
+Deprecate ustat syscall interface
+This patch uses pre-computed size of struct ustat for Linux to fix
+
+https://bugs.llvm.org/show_bug.cgi?id=37418
+
+Patch by H.J. Lu.
+
+Differential Revision: https://reviews.llvm.org/D47281
+
+git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@333213 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ .../sanitizer_platform_limits_posix.cc | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+index 94b8f3f627..936d818673 100644
+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -159,7 +159,6 @@ typedef struct user_fpregs elf_fpregset_t;
+ # include <sys/procfs.h>
+ #endif
+ #include <sys/user.h>
+-#include <sys/ustat.h>
+ #include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+@@ -253,7 +252,19 @@ namespace __sanitizer {
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+- unsigned struct_ustat_sz = sizeof(struct ustat);
++ // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
++ // has been removed from glibc 2.28.
++#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
++ || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
++ || defined(__x86_64__)
++#define SIZEOF_STRUCT_USTAT 32
++#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
++ || defined(__powerpc__) || defined(__s390__)
++#define SIZEOF_STRUCT_USTAT 20
++#else
++#error Unknown size of struct ustat
++#endif
++ unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix
index 0282591b6e2..4740180eb29 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix
@@ -16,7 +16,8 @@ stdenv.mkDerivation {
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
- ] ++ optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch;
+ ] ++ optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+ ++ optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch;
# 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
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch b/nixpkgs/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch
new file mode 100644
index 00000000000..764dddd966c
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch
@@ -0,0 +1,68 @@
+From 8412cba68835f8f4cc527d02194b181faa5944d4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Holger=20W=C3=BCnsche?= <holger.o.wuensche@t-online.de>
+Date: Tue, 21 Jan 2020 19:46:09 +0100
+Subject: [PATCH] [HIP] use GetProgramPath for executable discovery
+
+This change replaces the manual building of executable paths
+using llvm::sys::path::append with GetProgramPath.
+This enables adding other paths in case executables reside
+in different directories and makes the code easier to read.
+
+Differential Revision: https://reviews.llvm.org/D72903
+---
+ clang/lib/Driver/ToolChains/HIP.cpp | 18 ++++++------------
+ 1 file changed, 6 insertions(+), 12 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/HIP.cpp b/lib/Driver/ToolChains/HIP.cpp
+index 03acf45a9b3..75fd3226c75 100644
+--- a/lib/Driver/ToolChains/HIP.cpp
++++ b/lib/Driver/ToolChains/HIP.cpp
+@@ -98,9 +98,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpName));
+ CmdArgs.push_back(OutputFileName);
+- SmallString<128> ExecPath(C.getDriver().Dir);
+- llvm::sys::path::append(ExecPath, "llvm-link");
+- const char *Exec = Args.MakeArgString(ExecPath);
++ const char *Exec =
++ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -141,9 +140,8 @@ const char *AMDGCN::Linker::constructOptCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
+ OptArgs.push_back(OutputFileName);
+- SmallString<128> OptPath(C.getDriver().Dir);
+- llvm::sys::path::append(OptPath, "opt");
+- const char *OptExec = Args.MakeArgString(OptPath);
++ const char *OptExec =
++ Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, OptExec, OptArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -161,9 +159,7 @@ const char *AMDGCN::Linker::constructLlcCommand(
+ const char *LlcOutputFile =
+ C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName));
+ LlcArgs.push_back(LlcOutputFile);
+- SmallString<128> LlcPath(C.getDriver().Dir);
+- llvm::sys::path::append(LlcPath, "llc");
+- const char *Llc = Args.MakeArgString(LlcPath);
++ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Llc, LlcArgs, Inputs));
+ return LlcOutputFile;
+ }
+@@ -178,9 +174,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
+ ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined",
+ "-shared", "-o", Output.getFilename(),
+ InputFileName};
+- SmallString<128> LldPath(C.getDriver().Dir);
+- llvm::sys::path::append(LldPath, "lld");
+- const char *Lld = Args.MakeArgString(LldPath);
++ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Lld, LldArgs, Inputs));
+ }
+
+--
+2.23.1
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
index cc5dcfc160b..6e01f4259ee 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -22,7 +22,7 @@ let
nativeBuildInputs = [ cmake python3 ]
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
- buildInputs = [ libxml2 llvm ]
+ buildInputs = [ libxml2 llvm lld ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags = [
@@ -38,7 +38,11 @@ let
"-DLINK_POLLY_INTO_TOOLS=ON"
];
- patches = [ ./purity.patch ];
+ patches = [
+ ./purity.patch
+ # make clang -xhip use $PATH to find executables
+ ./HIP-use-PATH-7.patch
+ ];
postPatch = ''
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
index f5dbea58a7d..04e1610fb79 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
@@ -32,6 +32,7 @@ let
llvm-polly = callPackage ./llvm.nix { enablePolly = true; };
clang-unwrapped = callPackage ./clang {
+ inherit (tools) lld;
inherit clang-tools-extra_src;
};
clang-polly-unwrapped = callPackage ./clang {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch b/nixpkgs/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch
new file mode 100644
index 00000000000..f4be100d1ab
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch
@@ -0,0 +1,80 @@
+From d9f1b7d7571b252e0ba2359ae6cfa93a9903c0e7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Holger=20W=C3=BCnsche?= <holger.o.wuensche@t-online.de>
+Date: Tue, 21 Jan 2020 19:49:44 +0100
+Subject: [PATCH] [HIP] use GetProgramPath for executable discovery
+
+This change replaces the manual building of executable paths
+using llvm::sys::path::append with GetProgramPath.
+This enables adding other paths in case executables reside
+in different directories and makes the code easier to read.
+
+Differential Revision: https://reviews.llvm.org/D72903
+---
+ clang/lib/Driver/ToolChains/HIP.cpp | 23 ++++++++---------------
+ 1 file changed, 8 insertions(+), 15 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/HIP.cpp b/lang/lib/Driver/ToolChains/HIP.cpp
+index 868765cf88e..31f2d68ec6c 100644
+--- a/lib/Driver/ToolChains/HIP.cpp
++++ b/lib/Driver/ToolChains/HIP.cpp
+@@ -104,9 +104,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpName));
+ CmdArgs.push_back(OutputFileName);
+- SmallString<128> ExecPath(C.getDriver().Dir);
+- llvm::sys::path::append(ExecPath, "llvm-link");
+- const char *Exec = Args.MakeArgString(ExecPath);
++ const char *Exec =
++ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -147,9 +146,8 @@ const char *AMDGCN::Linker::constructOptCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
+ OptArgs.push_back(OutputFileName);
+- SmallString<128> OptPath(C.getDriver().Dir);
+- llvm::sys::path::append(OptPath, "opt");
+- const char *OptExec = Args.MakeArgString(OptPath);
++ const char *OptExec =
++ Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, OptExec, OptArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -167,9 +165,7 @@ const char *AMDGCN::Linker::constructLlcCommand(
+ const char *LlcOutputFile =
+ C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName));
+ LlcArgs.push_back(LlcOutputFile);
+- SmallString<128> LlcPath(C.getDriver().Dir);
+- llvm::sys::path::append(LlcPath, "llc");
+- const char *Llc = Args.MakeArgString(LlcPath);
++ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Llc, LlcArgs, Inputs));
+ return LlcOutputFile;
+ }
+@@ -184,9 +180,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
+ ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined",
+ "-shared", "-o", Output.getFilename(),
+ InputFileName};
+- SmallString<128> LldPath(C.getDriver().Dir);
+- llvm::sys::path::append(LldPath, "lld");
+- const char *Lld = Args.MakeArgString(LldPath);
++ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Lld, LldArgs, Inputs));
+ }
+
+@@ -218,9 +212,8 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
+ Args.MakeArgString(std::string("-outputs=").append(OutputFileName));
+ BundlerArgs.push_back(BundlerOutputArg);
+
+- SmallString<128> BundlerPath(C.getDriver().Dir);
+- llvm::sys::path::append(BundlerPath, "clang-offload-bundler");
+- const char *Bundler = Args.MakeArgString(BundlerPath);
++ const char *Bundler = Args.MakeArgString(
++ T.getToolChain().GetProgramPath("clang-offload-bundler"));
+ C.addCommand(llvm::make_unique<Command>(JA, T, Bundler, BundlerArgs, Inputs));
+ }
+
+--
+2.23.1
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
index 8601f6d0680..81a069e6c01 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -22,7 +22,7 @@ let
nativeBuildInputs = [ cmake python3 ]
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
- buildInputs = [ libxml2 llvm ]
+ buildInputs = [ libxml2 llvm lld ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags = [
@@ -50,6 +50,8 @@ let
./unwindlib.patch
# https://reviews.llvm.org/D51899
./compiler-rt-baremetal.patch
+ # make clang -xhip use $PATH to find executables
+ ./HIP-use-PATH-8.patch
];
postPatch = ''
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix
index 8b916e1cda7..d604dda5fe5 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix
@@ -32,6 +32,7 @@ let
llvm-polly = callPackage ./llvm.nix { enablePolly = true; };
clang-unwrapped = callPackage ./clang {
+ inherit (tools) lld;
inherit clang-tools-extra_src;
};
clang-polly-unwrapped = callPackage ./clang {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch b/nixpkgs/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch
new file mode 100644
index 00000000000..102d810ff68
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch
@@ -0,0 +1,80 @@
+From 7147e9774c74abcd1d6db24e24d0fd989c2b97dd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Holger=20W=C3=BCnsche?= <holger.o.wuensche@t-online.de>
+Date: Tue, 21 Jan 2020 19:52:04 +0100
+Subject: [PATCH] [HIP] use GetProgramPath for executable discovery
+
+This change replaces the manual building of executable paths
+using llvm::sys::path::append with GetProgramPath.
+This enables adding other paths in case executables reside
+in different directories and makes the code easier to read.
+
+Differential Revision: https://reviews.llvm.org/D72903
+---
+ clang/lib/Driver/ToolChains/HIP.cpp | 23 ++++++++---------------
+ 1 file changed, 8 insertions(+), 15 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/HIP.cpp b/lib/Driver/ToolChains/HIP.cpp
+index 2ec97e798fd..735c302debb 100644
+--- a/lib/Driver/ToolChains/HIP.cpp
++++ b/lib/Driver/ToolChains/HIP.cpp
+@@ -66,9 +66,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpName));
+ CmdArgs.push_back(OutputFileName);
+- SmallString<128> ExecPath(C.getDriver().Dir);
+- llvm::sys::path::append(ExecPath, "llvm-link");
+- const char *Exec = Args.MakeArgString(ExecPath);
++ const char *Exec =
++ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -114,9 +113,8 @@ const char *AMDGCN::Linker::constructOptCommand(
+ const char *OutputFileName =
+ C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
+ OptArgs.push_back(OutputFileName);
+- SmallString<128> OptPath(C.getDriver().Dir);
+- llvm::sys::path::append(OptPath, "opt");
+- const char *OptExec = Args.MakeArgString(OptPath);
++ const char *OptExec =
++ Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, OptExec, OptArgs, Inputs));
+ return OutputFileName;
+ }
+@@ -156,9 +154,7 @@ const char *AMDGCN::Linker::constructLlcCommand(
+ const char *LlcOutputFile =
+ C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName));
+ LlcArgs.push_back(LlcOutputFile);
+- SmallString<128> LlcPath(C.getDriver().Dir);
+- llvm::sys::path::append(LlcPath, "llc");
+- const char *Llc = Args.MakeArgString(LlcPath);
++ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Llc, LlcArgs, Inputs));
+ return LlcOutputFile;
+ }
+@@ -172,9 +168,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
+ // The output from ld.lld is an HSA code object file.
+ ArgStringList LldArgs{
+ "-flavor", "gnu", "-shared", "-o", Output.getFilename(), InputFileName};
+- SmallString<128> LldPath(C.getDriver().Dir);
+- llvm::sys::path::append(LldPath, "lld");
+- const char *Lld = Args.MakeArgString(LldPath);
++ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Lld, LldArgs, Inputs));
+ }
+
+@@ -206,9 +200,8 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
+ Args.MakeArgString(std::string("-outputs=").append(OutputFileName));
+ BundlerArgs.push_back(BundlerOutputArg);
+
+- SmallString<128> BundlerPath(C.getDriver().Dir);
+- llvm::sys::path::append(BundlerPath, "clang-offload-bundler");
+- const char *Bundler = Args.MakeArgString(BundlerPath);
++ const char *Bundler = Args.MakeArgString(
++ T.getToolChain().GetProgramPath("clang-offload-bundler"));
+ C.addCommand(llvm::make_unique<Command>(JA, T, Bundler, BundlerArgs, Inputs));
+ }
+
+--
+2.23.1
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
index 5f89c3dc3b7..d8df52df553 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -22,7 +22,7 @@ let
nativeBuildInputs = [ cmake python3 ]
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
- buildInputs = [ libxml2 llvm ]
+ buildInputs = [ libxml2 llvm lld ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags = [
@@ -43,6 +43,8 @@ let
./purity.patch
# https://reviews.llvm.org/D51899
./compiler-rt-baremetal.patch
+ # make clang -xhip use $PATH to find executables
+ ./HIP-use-PATH-9.patch
];
postPatch = ''
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/default.nix
index 38ab7794018..11e44b8bdfa 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/9/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/default.nix
@@ -32,6 +32,7 @@ let
llvm-polly = callPackage ./llvm.nix { enablePolly = true; };
clang-unwrapped = callPackage ./clang {
+ inherit (tools) lld;
inherit clang-tools-extra_src;
};
clang-polly-unwrapped = callPackage ./clang {