diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm')
48 files changed, 492 insertions, 374 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix index 72a2a733193..53f7941e336 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/bintools.nix @@ -11,9 +11,19 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' 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 ${llvm}/bin/llvm-ar $out/bin/${prefix}ar + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip + 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 deleted file mode 100644 index a74d10989ff..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/10/clang/clang-extension-handling.patch +++ /dev/null @@ -1,18 +0,0 @@ -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/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix index 10026ca4eb1..1788ac2d96f 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix @@ -8,7 +8,7 @@ let pname = "clang"; inherit version; - src = fetch "clang" "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"; + src = fetch "clang" "091bvcny2lh32zy8f3m9viayyhb2zannrndni7325rl85cwgr6pr"; unpackPhase = '' unpackFile $src @@ -27,6 +27,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++14" "-DCLANGD_BUILD_XPC=OFF" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" @@ -36,9 +37,6 @@ let ]; patches = [ - # 10.0.0 only, this should be present in 10.0.1 - ./clang-extension-handling.patch - ./purity.patch # https://reviews.llvm.org/D51899 ./compiler-rt-baremetal.patch diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix index 68f64ef4256..47bbe808ac2 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/compiler-rt.nix @@ -11,7 +11,7 @@ in stdenv.mkDerivation rec { pname = "compiler-rt"; inherit version; - src = fetch pname "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"; + src = fetch pname "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"; nativeBuildInputs = [ cmake python3 llvm ]; buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; @@ -57,7 +57,7 @@ stdenv.mkDerivation rec { # 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 = '' + postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + stdenv.lib.optionalString stdenv.isDarwin '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix index 4181ab29bd7..cd77eed9ac8 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/default.nix @@ -1,12 +1,12 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , 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"; - version = release_version; # differentiating these (variables) is important for rc's + release_version = "10.0.1"; + version = release_version; # differentiating these (variables) is important for RCs targetConfig = stdenv.targetPlatform.config; fetch = name: sha256: fetchurl { @@ -14,7 +14,7 @@ let inherit sha256; }; - clang-tools-extra_src = fetch "clang-tools-extra" "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc"; + clang-tools-extra_src = fetch "clang-tools-extra" "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh"; tools = stdenv.lib.makeExtensible (tools: let callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); @@ -36,20 +36,22 @@ let inherit clang-tools-extra_src; }; - llvm-manpages = lowPrio (tools.llvm.override { - enableManpages = true; - python3 = pkgs.python3; # don't use python-boot - }); + # disabled until recommonmark supports sphinx 3 + #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 - }); + # disabled until recommonmark supports sphinx 3 + # lldb-manpages = lowPrio (tools.lldb.override { + # enableManpages = true; + # python3 = pkgs.python3; # don't use python-boot + # }); libclang = tools.clang-unwrapped.lib; @@ -57,23 +59,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ - libstdcxxHook targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; @@ -100,14 +96,12 @@ let 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) '' @@ -127,7 +121,6 @@ let 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 @@ -145,7 +138,6 @@ let 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; @@ -161,7 +153,6 @@ let extraPackages = [ ]; extraBuildCommands = '' echo "-nostartfiles" >> $out/nix-support/cc-cflags - echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags ''; }; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix index ed76ce77a8b..651f1887553 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/default.nix @@ -5,7 +5,7 @@ stdenv.mkDerivation { pname = "libc++"; inherit version; - src = fetch "libcxx" "1isnj78diknh0nvd73mlq8p8g209f9bab2mbysq826bg2wzql3r7"; + src = fetch "libcxx" "0v78bfr6h2zifvdqnj2wlfk4pvxzrqn3hg1v6lqk3y12bx9p9xny"; postUnpack = '' unpackFile ${libcxxabi.src} @@ -39,12 +39,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/10/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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 index ab45f27d24f..00371b862ad 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/libc++abi.nix @@ -5,7 +5,7 @@ stdenv.mkDerivation { pname = "libc++abi"; inherit version; - src = fetch "libcxxabi" "1q8lrbh68a9v4lr88b8xsjpmwx5z96sa5wnkb92xx7ccm1ssq6z7"; + src = fetch "libcxxabi" "0yqs722y76cwvmfsq0lb917r9m3fci7bf5z3yzl71yz9n88ghzm9"; nativeBuildInputs = [ cmake ]; buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix b/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix index 4e55b28c243..b13bacb3638 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/libunwind.nix @@ -4,7 +4,7 @@ stdenv.mkDerivation rec { pname = "libunwind"; inherit version; - src = fetch pname "09n66dl9cc17d81qflj5h1l4garmhvzfi2lhcb7rx00l8z65xp09"; + src = fetch pname "09syx66idnm2pr46x2vmk0jn3iwdv0lkd04xy4zjbwmz3vn066bl"; nativeBuildInputs = [ cmake ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix index 6a0032de2ac..5d513462820 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/lld.nix @@ -10,7 +10,7 @@ stdenv.mkDerivation rec { pname = "lld"; inherit version; - src = fetch pname "026pwcbczcg0j5c9h7hxxrn3ki81ia9m9sfn0sy0bvzffv2xg85r"; + src = fetch pname "0ynzi35r4fckvp6842alpd43qr810j3728yfslc66fk2mbh4j52r"; nativeBuildInputs = [ cmake ]; buildInputs = [ llvm libxml2 ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix index 90716f67f83..47215caa53e 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/lldb.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation (rec { pname = "lldb"; inherit version; - src = fetch pname "0ddikvc0kbqlqvsypsm9nhfwmyw4prp4rv49f0bgacyh5ssgq7yx"; + src = fetch pname "051p5b04y6z3g730rmc2n2v71lipbw7k69riww3a6sl74myfiaq7"; patches = [ ./lldb-procfs.patch ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch b/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch deleted file mode 100644 index cf4b1eaacf7..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/10/llvm-extension-handling.patch +++ /dev/null @@ -1,146 +0,0 @@ -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.nix b/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix index dd0728b40c9..742beb87640 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/llvm.nix @@ -32,8 +32,8 @@ in stdenv.mkDerivation (rec { pname = "llvm"; inherit version; - src = fetch pname "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"; - polly_src = fetch "polly" "15sd3dq0w60jsb76pis09lkagj5iy43h9hg4kd9gx5l8cbnsdyrm"; + src = fetch pname "1wydhbp9kyjp5y0rc627imxgkgqiv3dfirbqil9dgpnbaw5y7n65"; + polly_src = fetch "polly" "0nm2d8niz47yjsa3r17v3p13b70igkd338ib8191znr1dfw0pyyj"; unpackPhase = '' unpackFile $src @@ -55,11 +55,6 @@ in stdenv.mkDerivation (rec { 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)" \ diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix index 624c99bc868..0927448d2b4 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/10/openmp.nix @@ -10,7 +10,7 @@ stdenv.mkDerivation rec { pname = "openmp"; inherit version; - src = fetch pname "1ymd13gj07x0b0vxziygm0p41vrq6nsgx837jqg9ll6h8ndg57rv"; + src = fetch pname "0i4bn84lkpm5w3qkpvwm5z6jdj8fynp7d3bcasa1xyq4is6757yi"; nativeBuildInputs = [ cmake perl ]; buildInputs = [ llvm ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix index 1016398992f..a2641e7ea49 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix @@ -27,6 +27,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix index 624034b5228..32d6dd3d479 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ../7/compiler-rt-glibc.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/default.nix index e7083a6ed13..5a992f4a350 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/5/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/5/default.nix @@ -1,4 +1,4 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -51,25 +51,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraTools = [ - libstdcxxHook - ]; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix index 88ad3c29c3e..f8185fc3ff4 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix @@ -37,12 +37,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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/6/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix index e2f7166354a..27d2106a3a0 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix @@ -27,6 +27,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix index 5ae8bb01f05..89f25cad2c5 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ../7/compiler-rt-glibc.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; @@ -55,7 +56,7 @@ stdenv.mkDerivation { # 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 = '' + postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + stdenv.lib.optionalString stdenv.isDarwin '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/default.nix index b544a4f6ba6..2316fbfc3fb 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/6/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/6/default.nix @@ -1,4 +1,4 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -51,25 +51,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraTools = [ - libstdcxxHook - ]; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix index 57f1431f471..a922bcfaf0e 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix @@ -37,12 +37,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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/7/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix index 72a2a733193..53f7941e336 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix @@ -11,9 +11,19 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' 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 ${llvm}/bin/llvm-ar $out/bin/${prefix}ar + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip + ln -s ${lld}/bin/lld $out/bin/${prefix}ld '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix index 18ea46ea39c..a1b83aa099e 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix @@ -27,6 +27,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-glibc.patch b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-glibc.patch new file mode 100644 index 00000000000..2d211795fc8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-glibc.patch @@ -0,0 +1,48 @@ +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index 54da635..c5dc1cd 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -1158,8 +1158,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid); + CHECK_SIZE_AND_OFFSET(ipc_perm, gid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); +-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) +-/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ ++#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) ++/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit ++ on many architectures. */ + CHECK_SIZE_AND_OFFSET(ipc_perm, mode); + #endif + +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h +index f89a113..f6f986f 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h +@@ -213,26 +213,13 @@ namespace __sanitizer { + u64 __unused1; + u64 __unused2; + #elif defined(__sparc__) +-#if defined(__arch64__) + unsigned mode; +- unsigned short __pad1; +-#else +- unsigned short __pad1; +- unsigned short mode; + unsigned short __pad2; +-#endif + unsigned short __seq; + unsigned long long __unused1; + unsigned long long __unused2; +-#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) +- unsigned int mode; +- unsigned short __seq; +- unsigned short __pad1; +- unsigned long __unused1; +- unsigned long __unused2; + #else +- unsigned short mode; +- unsigned short __pad1; ++ unsigned int mode; + unsigned short __seq; + unsigned short __pad2; + #if defined(__x86_64__) && !defined(_LP64) diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix index e9853c58ca5..97a5d73f304 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix @@ -46,6 +46,9 @@ stdenv.mkDerivation { outputs = [ "out" "dev" ]; patches = [ + # https://github.com/llvm/llvm-project/commit/947f9692440836dcb8d88b74b69dd379d85974ce + ./compiler-rt-glibc.patch + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory ] ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch @@ -56,7 +59,7 @@ stdenv.mkDerivation { # 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 = '' + postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + stdenv.lib.optionalString stdenv.isDarwin '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix index 0b71c3a28d2..b83c0d2ceed 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix @@ -1,4 +1,4 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , 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 @@ -58,25 +58,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraTools = [ - libstdcxxHook - ]; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; @@ -87,48 +79,77 @@ let lldb = callPackage ./lldb.nix {}; + # Below, is the LLVM bootstrapping logic. It handles building a + # fully LLVM toolchain from scratch. No GCC toolchain should be + # pulled in. As a consequence, it is very quick to build different + # targets provided by LLVM and we can also build for what GCC + # doesnโt support like LLVM. Probably we should move to some other + # file. + bintools = callPackage ./bintools.nix {}; lldClang = wrapCCWith rec { cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + }; + extraPackages = [ + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + 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.libcxx - # targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; extraBuildCommands = '' - echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $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.libcxx - # targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; extraBuildCommands = '' - echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $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 -target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + echo "-nostartfiles" >> $out/nix-support/cc-cflags ''; }; @@ -148,9 +169,16 @@ let libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; - libcxx = callPackage ./libc++ {}; + libcxx = callPackage ./libc++ ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; + })); - libcxxabi = callPackage ./libc++abi.nix {}; + libcxxabi = callPackage ./libc++abi.nix ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; + libunwind = libraries.libunwind; + })); openmp = callPackage ./openmp.nix {}; }); diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix index 96cb671fa43..83c05cf0e63 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix @@ -37,12 +37,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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/8/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix index 72a2a733193..53f7941e336 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix @@ -11,9 +11,19 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' 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 ${llvm}/bin/llvm-ar $out/bin/${prefix}ar + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip + ln -s ${lld}/bin/lld $out/bin/${prefix}ld '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix index 3b398628e56..3fb43c02d8c 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix @@ -28,6 +28,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" "-DCLANGD_BUILD_XPC=OFF" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix index 1f58cb98e3d..a907d408655 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix @@ -46,6 +46,7 @@ stdenv.mkDerivation { outputs = [ "out" "dev" ]; patches = [ + ../7/compiler-rt-glibc.patch ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch @@ -56,7 +57,7 @@ stdenv.mkDerivation { # 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 = '' + postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + stdenv.lib.optionalString stdenv.isDarwin '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix index d9383d042bb..984e7ab74b7 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/8/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix @@ -1,4 +1,4 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , 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 @@ -42,10 +42,11 @@ let enablePolly = true; }; - llvm-manpages = lowPrio (tools.llvm.override { - enableManpages = true; - python3 = pkgs.python3; # don't use python-boot - }); + # disabled until recommonmark supports sphinx 3 + #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; @@ -58,25 +59,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraTools = [ - libstdcxxHook - ]; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; @@ -103,14 +96,12 @@ let 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) '' @@ -130,7 +121,6 @@ let 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 @@ -148,7 +138,6 @@ let 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; @@ -164,7 +153,6 @@ let extraPackages = [ ]; extraBuildCommands = '' echo "-nostartfiles" >> $out/nix-support/cc-cflags - echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags ''; }; diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix index 24bca6aafcd..9c0c7951c79 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix @@ -43,12 +43,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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/9/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/9/bintools.nix index 72a2a733193..53f7941e336 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/9/bintools.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/9/bintools.nix @@ -11,9 +11,19 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' 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 ${llvm}/bin/llvm-ar $out/bin/${prefix}ar + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip + ln -s ${lld}/bin/lld $out/bin/${prefix}ld '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix index c938a01f897..9bc7a88e912 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix @@ -28,6 +28,7 @@ let cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" "-DCLANGD_BUILD_XPC=OFF" + "-DLLVM_ENABLE_RTTI=ON" ] ++ stdenv.lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/9/compiler-rt.nix index 3b92264ad69..394f66ff7f1 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/9/compiler-rt.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/9/compiler-rt.nix @@ -46,6 +46,7 @@ stdenv.mkDerivation rec { outputs = [ "out" "dev" ]; patches = [ + ../7/compiler-rt-glibc.patch ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; @@ -55,7 +56,7 @@ stdenv.mkDerivation rec { # 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 = '' + postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + stdenv.lib.optionalString stdenv.isDarwin '' diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/default.nix index 3b6db967b6a..816a4f3d230 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/9/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/9/default.nix @@ -1,4 +1,4 @@ -{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook +{ lowPrio, newScope, pkgs, stdenv, cmake , 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 @@ -42,10 +42,11 @@ let enablePolly = true; }; - llvm-manpages = lowPrio (tools.llvm.override { - enableManpages = true; - python3 = pkgs.python3; # don't use python-boot - }); + # disabled until recommonmark supports sphinx 3 + #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; @@ -58,25 +59,17 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraTools = [ - libstdcxxHook - ]; + libcxx = null; # libstdcxx is smuggled in with clang.gcc extraPackages = [ targetLlvmLibraries.compiler-rt ]; - extraBuildCommands = '' - echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags - echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags - echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags - echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags - '' + mkExtraBuildCommands cc; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; libcxx = targetLlvmLibraries.libcxx; extraPackages = [ - targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; @@ -103,14 +96,12 @@ let 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) '' @@ -130,7 +121,6 @@ let 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 @@ -148,7 +138,6 @@ let 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; @@ -164,7 +153,6 @@ let extraPackages = [ ]; extraBuildCommands = '' echo "-nostartfiles" >> $out/nix-support/cc-cflags - echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags ''; }; diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/libc++/default.nix index f3081d1f269..cec6de61ca9 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/9/libc++/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/9/libc++/default.nix @@ -39,12 +39,9 @@ stdenv.mkDerivation { enableParallelBuilding = true; - linkCxxAbi = stdenv.isLinux; - - setupHooks = [ - ../../../../../build-support/setup-hooks/role.bash - ./setup-hook.sh - ]; + passthru = { + isLLVM = true; + }; meta = { homepage = "https://libcxx.llvm.org/"; diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/9/libc++/setup-hook.sh deleted file mode 100644 index 6611259165a..00000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/9/libc++/setup-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -# 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/rocm/clang.nix b/nixpkgs/pkgs/development/compilers/llvm/rocm/clang.nix new file mode 100644 index 00000000000..86853a97c93 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/rocm/clang.nix @@ -0,0 +1,67 @@ +{ stdenv +, fetchFromGitHub +, cmake +, python +, llvm +, clang-tools-extra_src ? null +, rocm-runtime +, lld + +, version +, src +}: + +stdenv.mkDerivation rec { + inherit version src; + + pname = "clang"; + + nativeBuildInputs = [ cmake python ]; + + buildInputs = [ llvm rocm-runtime ]; + + hardeningDisable = [ "all" ]; + + cmakeFlags = [ + "-DLLVM_CMAKE_PATH=${llvm}/lib/cmake/llvm" + "-DLLVM_MAIN_SRC_DIR=${llvm.src}" + "-DCLANG_SOURCE_DIR=${src}" + "-DLLVM_ENABLE_RTTI=ON" + ]; + + VCSVersion = '' + #undef LLVM_REVISION + #undef LLVM_REPOSITORY + #undef CLANG_REVISION + #undef CLANG_REPOSITORY + ''; + + postUnpack = stdenv.lib.optionalString (!(isNull clang-tools-extra_src)) '' + ln -s ${clang-tools-extra_src} $sourceRoot/tools/extra + ''; + + # Rather than let cmake extract version information from LLVM or + # clang source control repositories, we generate the wanted + # `VCSVersion.inc` file ourselves and remove it from the + # depencencies of the `clangBasic` target. + preConfigure = '' + sed 's/ ''${version_inc}//' -i lib/Basic/CMakeLists.txt + sed 's|sys::path::parent_path(BundlerExecutable)|StringRef("${llvm}/bin")|' -i tools/clang-offload-bundler/ClangOffloadBundler.cpp + sed 's|\([[:space:]]*std::string Linker = \)getToolChain().GetProgramPath(getShortName())|\1"${lld}/bin/ld.lld"|' -i lib/Driver/ToolChains/AMDGPU.cpp + substituteInPlace lib/Driver/ToolChains/AMDGPU.h --replace ld.lld ${lld}/bin/ld.lld + sed 's|configure_file(AST/gen_ast_dump_json_test.py ''${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)||' -i test/CMakeLists.txt + ''; + + postConfigure = '' + mkdir -p lib/Basic + echo "$VCSVersion" > lib/Basic/VCSVersion.inc + ''; + + meta = with stdenv.lib; { + description = "ROCm fork of the clang C/C++/Objective-C/Objective-C++ LLVM compiler frontend"; + homepage = "https://llvm.org/"; + license = with licenses; [ ncsa ]; + maintainers = with maintainers; [ danieldk ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/rocm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/rocm/default.nix new file mode 100644 index 00000000000..e90818d8505 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/rocm/default.nix @@ -0,0 +1,41 @@ +{ stdenv, fetchFromGitHub, callPackage, wrapCCWith }: + +let + version = "3.5.1"; + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "llvm-project"; + rev = "rocm-${version}"; + sha256 = "03k2xp8wf4awf1zcjc2hb3kf9bqp567c3s569gp1q3q1zjg6r2ib"; + }; +in rec { + clang = wrapCCWith rec { + cc = clang-unwrapped; + extraBuildCommands = '' + clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags + echo "-Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags + rm $out/nix-support/add-hardening.sh + touch $out/nix-support/add-hardening.sh + ''; + }; + + clang-unwrapped = callPackage ./clang.nix { + inherit lld llvm version; + src = "${src}/clang"; + }; + + lld = callPackage ./lld.nix { + inherit llvm version; + src = "${src}/lld"; + }; + + llvm = callPackage ./llvm.nix { + inherit version; + src = "${src}/llvm"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/rocm/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/rocm/lld.nix new file mode 100644 index 00000000000..052bfd1c62d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/rocm/lld.nix @@ -0,0 +1,33 @@ +{ stdenv +, cmake +, libxml2 +, llvm + +, version +, src +}: + +stdenv.mkDerivation rec { + inherit version src; + + pname = "lld"; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libxml2 llvm ]; + + outputs = [ "out" "dev" ]; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = with stdenv.lib; { + description = "ROCm fork of the LLVM Linker"; + homepage = "https://github.com/RadeonOpenCompute/llvm-project"; + license = licenses.ncsa; + maintainers = with maintainers; [ danieldk ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/rocm/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/rocm/llvm-outputs.patch new file mode 100644 index 00000000000..40096fa3497 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/rocm/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/rocm/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/rocm/llvm.nix new file mode 100644 index 00000000000..909284a3e91 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/rocm/llvm.nix @@ -0,0 +1,97 @@ +{ stdenv +, fetchFromGitHub +, cmake +, python3 +, libxml2 +, libffi +, libbfd +, ncurses +, zlib +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? true + +, version +, src +}: + +let + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation rec { + inherit src version; + + pname = "rocm-llvm"; + + outputs = [ "out" "python" ] + ++ stdenv.lib.optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python3 ]; + + buildInputs = [ libxml2 libffi ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=OFF" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_ENABLE_DUMP=ON" + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + ] + ++ + stdenv.lib.optional + enableSharedLibraries + "-DLLVM_LINK_LLVM_DYLIB=ON" + ++ stdenv.lib.optionals enableManpages [ + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ]; + + postPatch = '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = '' + moveToOutput share/opt-viewer "$python" + '' + + stdenv.lib.optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + ''; + + passthru.src = src; + + meta = with stdenv.lib; { + description = "ROCm fork of the LLVM compiler infrastructure"; + homepage = "https://github.com/RadeonOpenCompute/llvm-project"; + license = with licenses; [ ncsa ]; + maintainers = with maintainers; [ danieldk ]; + platforms = platforms.linux; + }; +} |