llvmPackages_14: Copy the files from llvmPackages_git

+2576
+29
pkgs/development/compilers/llvm/14/bintools/default.nix
··· 1 + { runCommand, stdenv, llvm, lld, version }: 2 + 3 + let 4 + prefix = 5 + if stdenv.hostPlatform != stdenv.targetPlatform 6 + then "${stdenv.targetPlatform.config}-" 7 + else ""; 8 + in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' 9 + mkdir -p $out/bin 10 + for prog in ${lld}/bin/*; do 11 + ln -s $prog $out/bin/${prefix}$(basename $prog) 12 + done 13 + for prog in ${llvm}/bin/*; do 14 + ln -sf $prog $out/bin/${prefix}$(basename $prog) 15 + done 16 + 17 + ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar 18 + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as 19 + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp 20 + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm 21 + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy 22 + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump 23 + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib 24 + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf 25 + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size 26 + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip 27 + 28 + ln -s ${lld}/bin/lld $out/bin/${prefix}ld 29 + ''
+131
pkgs/development/compilers/llvm/14/clang/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , monorepoSrc, runCommand 3 + , substituteAll, cmake, libxml2, libllvm, version, python3 4 + , buildLlvmTools 5 + , fixDarwinDylibNames 6 + , enableManpages ? false 7 + }: 8 + 9 + let 10 + self = stdenv.mkDerivation (rec { 11 + pname = "clang"; 12 + inherit version; 13 + 14 + src = runCommand "${pname}-src-${version}" {} '' 15 + mkdir -p "$out" 16 + cp -r ${monorepoSrc}/cmake "$out" 17 + cp -r ${monorepoSrc}/${pname} "$out" 18 + ''; 19 + 20 + sourceRoot = "${src.name}/${pname}"; 21 + 22 + nativeBuildInputs = [ cmake python3 ] 23 + ++ lib.optional enableManpages python3.pkgs.sphinx 24 + ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 25 + 26 + buildInputs = [ libxml2 libllvm ]; 27 + 28 + cmakeFlags = [ 29 + "-DCMAKE_CXX_FLAGS=-std=c++14" 30 + "-DCLANGD_BUILD_XPC=OFF" 31 + "-DLLVM_ENABLE_RTTI=ON" 32 + ] ++ lib.optionals enableManpages [ 33 + "-DCLANG_INCLUDE_DOCS=ON" 34 + "-DLLVM_ENABLE_SPHINX=ON" 35 + "-DSPHINX_OUTPUT_MAN=ON" 36 + "-DSPHINX_OUTPUT_HTML=OFF" 37 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 38 + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 39 + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 40 + "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 41 + ]; 42 + 43 + patches = [ 44 + ./purity.patch 45 + # https://reviews.llvm.org/D51899 46 + ./gnu-install-dirs.patch 47 + (substituteAll { 48 + src = ../../clang-11-12-LLVMgold-path.patch; 49 + libllvmLibdir = "${libllvm.lib}/lib"; 50 + }) 51 + ]; 52 + 53 + postPatch = '' 54 + (cd tools && ln -s ../../clang-tools-extra extra) 55 + 56 + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ 57 + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ 58 + lib/Driver/ToolChains/*.cpp 59 + 60 + # Patch for standalone doc building 61 + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt 62 + '' + lib.optionalString stdenv.hostPlatform.isMusl '' 63 + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 64 + ''; 65 + 66 + outputs = [ "out" "lib" "dev" "python" ]; 67 + 68 + postInstall = '' 69 + ln -sv $out/bin/clang $out/bin/cpp 70 + 71 + # Move libclang to 'lib' output 72 + moveToOutput "lib/libclang.*" "$lib" 73 + moveToOutput "lib/libclang-cpp.*" "$lib" 74 + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 75 + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 76 + --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 77 + 78 + mkdir -p $python/bin $python/share/clang/ 79 + mv $out/bin/{git-clang-format,scan-view} $python/bin 80 + if [ -e $out/bin/set-xcode-analyzer ]; then 81 + mv $out/bin/set-xcode-analyzer $python/bin 82 + fi 83 + mv $out/share/clang/*.py $python/share/clang 84 + rm $out/bin/c-index-test 85 + 86 + mkdir -p $dev/bin 87 + cp bin/clang-tblgen $dev/bin 88 + ''; 89 + 90 + passthru = { 91 + isClang = true; 92 + inherit libllvm; 93 + }; 94 + 95 + meta = llvm_meta // { 96 + homepage = "https://clang.llvm.org/"; 97 + description = "A C language family frontend for LLVM"; 98 + longDescription = '' 99 + The Clang project provides a language front-end and tooling 100 + infrastructure for languages in the C language family (C, C++, Objective 101 + C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 102 + It aims to deliver amazingly fast compiles, extremely useful error and 103 + warning messages and to provide a platform for building great source 104 + level tools. The Clang Static Analyzer and clang-tidy are tools that 105 + automatically find bugs in your code, and are great examples of the sort 106 + of tools that can be built using the Clang frontend as a library to 107 + parse C/C++ code. 108 + ''; 109 + }; 110 + } // lib.optionalAttrs enableManpages { 111 + pname = "clang-manpages"; 112 + 113 + buildPhase = '' 114 + make docs-clang-man 115 + ''; 116 + 117 + installPhase = '' 118 + mkdir -p $out/share/man/man1 119 + # Manually install clang manpage 120 + cp docs/man/*.1 $out/share/man/man1/ 121 + ''; 122 + 123 + outputs = [ "out" ]; 124 + 125 + doCheck = false; 126 + 127 + meta = llvm_meta // { 128 + description = "man page for Clang ${version}"; 129 + }; 130 + }); 131 + in self
+235
pkgs/development/compilers/llvm/14/clang/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 7ea37850ad60..ac0f2d4f60b4 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.13.4) 6 + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 7 + project(Clang) 8 + 9 + + include(GNUInstallDirs) 10 + + 11 + set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") 12 + set(CMAKE_CXX_STANDARD_REQUIRED YES) 13 + set(CMAKE_CXX_EXTENSIONS NO) 14 + @@ -424,7 +426,7 @@ include_directories(BEFORE 15 + 16 + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 17 + install(DIRECTORY include/clang include/clang-c 18 + - DESTINATION include 19 + + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 20 + COMPONENT clang-headers 21 + FILES_MATCHING 22 + PATTERN "*.def" 23 + @@ -433,7 +435,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 24 + ) 25 + 26 + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang 27 + - DESTINATION include 28 + + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 29 + COMPONENT clang-headers 30 + FILES_MATCHING 31 + PATTERN "CMakeFiles" EXCLUDE 32 + @@ -453,7 +455,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 33 + 34 + add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh) 35 + install(PROGRAMS utils/bash-autocomplete.sh 36 + - DESTINATION share/clang 37 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 38 + COMPONENT bash-autocomplete) 39 + if(NOT LLVM_ENABLE_IDE) 40 + add_llvm_install_targets(install-bash-autocomplete 41 + diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake 42 + index 5752f4277444..5bf08dbf5e83 100644 43 + --- a/cmake/modules/AddClang.cmake 44 + +++ b/cmake/modules/AddClang.cmake 45 + @@ -118,9 +118,9 @@ macro(add_clang_library name) 46 + install(TARGETS ${lib} 47 + COMPONENT ${lib} 48 + ${export_to_clangtargets} 49 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 50 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 51 + - RUNTIME DESTINATION bin) 52 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} 53 + + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} 54 + + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 55 + 56 + if (NOT LLVM_ENABLE_IDE) 57 + add_llvm_install_targets(install-${lib} 58 + @@ -159,7 +159,7 @@ macro(add_clang_tool name) 59 + get_target_export_arg(${name} Clang export_to_clangtargets) 60 + install(TARGETS ${name} 61 + ${export_to_clangtargets} 62 + - RUNTIME DESTINATION bin 63 + + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 64 + COMPONENT ${name}) 65 + 66 + if(NOT LLVM_ENABLE_IDE) 67 + @@ -174,7 +174,7 @@ endmacro() 68 + macro(add_clang_symlink name dest) 69 + add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) 70 + # Always generate install targets 71 + - llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) 72 + + llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) 73 + endmacro() 74 + 75 + function(clang_target_link_libraries target type) 76 + diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt 77 + index 078988980c52..14b58614b40a 100644 78 + --- a/lib/Headers/CMakeLists.txt 79 + +++ b/lib/Headers/CMakeLists.txt 80 + @@ -234,7 +234,7 @@ set_target_properties(clang-resource-headers PROPERTIES 81 + FOLDER "Misc" 82 + RUNTIME_OUTPUT_DIRECTORY "${output_dir}") 83 + 84 + -set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) 85 + +set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) 86 + 87 + install( 88 + FILES ${files} ${generated_files} 89 + diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt 90 + index 99c6081db2d6..0887102febb3 100644 91 + --- a/tools/c-index-test/CMakeLists.txt 92 + +++ b/tools/c-index-test/CMakeLists.txt 93 + @@ -49,7 +49,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 94 + set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH 95 + "@executable_path/../../lib") 96 + else() 97 + - set(INSTALL_DESTINATION bin) 98 + + set(INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR}) 99 + endif() 100 + 101 + install(TARGETS c-index-test 102 + diff --git a/tools/clang-format/CMakeLists.txt b/tools/clang-format/CMakeLists.txt 103 + index 35ecdb11253c..d77d75de0094 100644 104 + --- a/tools/clang-format/CMakeLists.txt 105 + +++ b/tools/clang-format/CMakeLists.txt 106 + @@ -21,20 +21,20 @@ if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) 107 + endif() 108 + 109 + install(PROGRAMS clang-format-bbedit.applescript 110 + - DESTINATION share/clang 111 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 112 + COMPONENT clang-format) 113 + install(PROGRAMS clang-format-diff.py 114 + - DESTINATION share/clang 115 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 116 + COMPONENT clang-format) 117 + install(PROGRAMS clang-format-sublime.py 118 + - DESTINATION share/clang 119 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 120 + COMPONENT clang-format) 121 + install(PROGRAMS clang-format.el 122 + - DESTINATION share/clang 123 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 124 + COMPONENT clang-format) 125 + install(PROGRAMS clang-format.py 126 + - DESTINATION share/clang 127 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 128 + COMPONENT clang-format) 129 + install(PROGRAMS git-clang-format 130 + - DESTINATION bin 131 + + DESTINATION ${CMAKE_INSTALL_BINDIR} 132 + COMPONENT clang-format) 133 + diff --git a/tools/clang-rename/CMakeLists.txt b/tools/clang-rename/CMakeLists.txt 134 + index cda8e29ec5b1..0134d8ccd70b 100644 135 + --- a/tools/clang-rename/CMakeLists.txt 136 + +++ b/tools/clang-rename/CMakeLists.txt 137 + @@ -19,8 +19,8 @@ clang_target_link_libraries(clang-rename 138 + ) 139 + 140 + install(PROGRAMS clang-rename.py 141 + - DESTINATION share/clang 142 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 143 + COMPONENT clang-rename) 144 + install(PROGRAMS clang-rename.el 145 + - DESTINATION share/clang 146 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang 147 + COMPONENT clang-rename) 148 + diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt 149 + index bf88dca0a34b..7a10181e7738 100644 150 + --- a/tools/libclang/CMakeLists.txt 151 + +++ b/tools/libclang/CMakeLists.txt 152 + @@ -186,7 +186,7 @@ endif() 153 + if(INTERNAL_INSTALL_PREFIX) 154 + set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include") 155 + else() 156 + - set(LIBCLANG_HEADERS_INSTALL_DESTINATION include) 157 + + set(LIBCLANG_HEADERS_INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 158 + endif() 159 + 160 + install(DIRECTORY ../../include/clang-c 161 + @@ -216,7 +216,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) 162 + COMPONENT 163 + libclang-python-bindings 164 + DESTINATION 165 + - "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") 166 + + "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") 167 + endforeach() 168 + if(NOT LLVM_ENABLE_IDE) 169 + add_custom_target(libclang-python-bindings) 170 + diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt 171 + index 74334e53c9b1..ebaae33e4324 100644 172 + --- a/tools/scan-build/CMakeLists.txt 173 + +++ b/tools/scan-build/CMakeLists.txt 174 + @@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD) 175 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) 176 + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) 177 + install(PROGRAMS bin/${BinFile} 178 + - DESTINATION bin 179 + + DESTINATION ${CMAKE_INSTALL_BINDIR} 180 + COMPONENT scan-build) 181 + endforeach() 182 + 183 + @@ -61,7 +61,7 @@ if(CLANG_INSTALL_SCANBUILD) 184 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}) 185 + list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}) 186 + install(PROGRAMS libexec/${LibexecFile} 187 + - DESTINATION libexec 188 + + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR} 189 + COMPONENT scan-build) 190 + endforeach() 191 + 192 + @@ -89,7 +89,7 @@ if(CLANG_INSTALL_SCANBUILD) 193 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}) 194 + list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}) 195 + install(FILES share/scan-build/${ShareFile} 196 + - DESTINATION share/scan-build 197 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-build 198 + COMPONENT scan-build) 199 + endforeach() 200 + 201 + diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt 202 + index eccc6b83195b..ff72d9cf0666 100644 203 + --- a/tools/scan-view/CMakeLists.txt 204 + +++ b/tools/scan-view/CMakeLists.txt 205 + @@ -20,7 +20,7 @@ if(CLANG_INSTALL_SCANVIEW) 206 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) 207 + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) 208 + install(PROGRAMS bin/${BinFile} 209 + - DESTINATION bin 210 + + DESTINATION ${CMAKE_INSTALL_BINDIR} 211 + COMPONENT scan-view) 212 + endforeach() 213 + 214 + @@ -34,7 +34,7 @@ if(CLANG_INSTALL_SCANVIEW) 215 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}) 216 + list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile}) 217 + install(FILES share/${ShareFile} 218 + - DESTINATION share/scan-view 219 + + DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-view 220 + COMPONENT scan-view) 221 + endforeach() 222 + 223 + diff --git a/utils/hmaptool/CMakeLists.txt b/utils/hmaptool/CMakeLists.txt 224 + index 62f2de0cb15c..6aa66825b6ec 100644 225 + --- a/utils/hmaptool/CMakeLists.txt 226 + +++ b/utils/hmaptool/CMakeLists.txt 227 + @@ -10,7 +10,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HM 228 + 229 + list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL}) 230 + install(PROGRAMS ${CLANG_HMAPTOOL} 231 + - DESTINATION bin 232 + + DESTINATION ${CMAKE_INSTALL_BINDIR} 233 + COMPONENT hmaptool) 234 + 235 + add_custom_target(hmaptool ALL DEPENDS ${Depends})
+28
pkgs/development/compilers/llvm/14/clang/purity.patch
··· 1 + From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 2 + From: Will Dietz <w@wdtz.org> 3 + Date: Thu, 18 May 2017 11:56:12 -0500 4 + Subject: [PATCH] "purity" patch for 5.0 5 + 6 + --- 7 + lib/Driver/ToolChains/Gnu.cpp | 7 ------- 8 + 1 file changed, 7 deletions(-) 9 + 10 + diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp 11 + index fe3c0191bb..c6a482bece 100644 12 + --- a/lib/Driver/ToolChains/Gnu.cpp 13 + +++ b/lib/Driver/ToolChains/Gnu.cpp 14 + @@ -487,12 +487,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, 15 + if (!IsStatic) { 16 + if (Args.hasArg(options::OPT_rdynamic)) 17 + CmdArgs.push_back("-export-dynamic"); 18 + - 19 + - if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) { 20 + - CmdArgs.push_back("-dynamic-linker"); 21 + - CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) + 22 + - ToolChain.getDynamicLinker(Args))); 23 + - } 24 + } 25 + 26 + CmdArgs.push_back("-o"); 27 + -- 28 + 2.11.0
+21
pkgs/development/compilers/llvm/14/compiler-rt/X86-support-extension.patch
··· 1 + diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt 2 + index 3a66dd9c3fb..7efc85d9f9f 100644 3 + --- a/lib/builtins/CMakeLists.txt 4 + +++ b/lib/builtins/CMakeLists.txt 5 + @@ -345,4 +345,8 @@ if (NOT MSVC) 6 + 7 + + set(i486_SOURCES ${i386_SOURCES}) 8 + + set(i586_SOURCES ${i386_SOURCES}) 9 + + set(i686_SOURCES ${i386_SOURCES}) 10 + + 11 + if (WIN32) 12 + set(i386_SOURCES 13 + ${i386_SOURCES} 14 + @@ -608,6 +612,7 @@ else () 15 + endif() 16 + 17 + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) 18 + + message("arch: ${arch}") 19 + if (CAN_TARGET_${arch}) 20 + # For ARM archs, exclude any VFP builtins if VFP is not supported 21 + if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
+32
pkgs/development/compilers/llvm/14/compiler-rt/armv7l.patch
··· 1 + diff -ur compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake 2 + --- compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake 2020-03-24 00:01:02.000000000 +0900 3 + +++ compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:42:00.883450706 +0900 4 + @@ -24,7 +24,7 @@ 5 + 6 + 7 + set(ARM64 aarch64) 8 + -set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) 9 + +set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) 10 + set(HEXAGON hexagon) 11 + set(X86 i386) 12 + set(X86_64 x86_64) 13 + diff -ur compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt 14 + --- compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt 2020-03-24 00:01:02.000000000 +0900 15 + +++ compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:44:49.468579650 +0900 16 + @@ -474,6 +474,7 @@ 17 + set(armv7_SOURCES ${arm_SOURCES}) 18 + set(armv7s_SOURCES ${arm_SOURCES}) 19 + set(armv7k_SOURCES ${arm_SOURCES}) 20 + +set(armv7l_SOURCES ${arm_SOURCES}) 21 + set(arm64_SOURCES ${aarch64_SOURCES}) 22 + 23 + # macho_embedded archs 24 + @@ -595,7 +596,7 @@ 25 + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) 26 + if (CAN_TARGET_${arch}) 27 + # For ARM archs, exclude any VFP builtins if VFP is not supported 28 + - if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") 29 + + if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") 30 + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") 31 + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) 32 + if(NOT COMPILER_RT_HAS_${arch}_VFP)
+33
pkgs/development/compilers/llvm/14/compiler-rt/codesign.patch
··· 1 + From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 2 + From: Will Dietz <w@wdtz.org> 3 + Date: Tue, 19 Sep 2017 13:13:06 -0500 4 + Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that 5 + needs it 6 + 7 + --- 8 + cmake/Modules/AddCompilerRT.cmake | 8 ------ 9 + test/asan/CMakeLists.txt | 52 --------------------------------------- 10 + test/tsan/CMakeLists.txt | 47 ----------------------------------- 11 + 3 files changed, 107 deletions(-) 12 + 13 + diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake 14 + index bc69ec95c419..9f100fdcec2f 100644 15 + --- a/cmake/Modules/AddCompilerRT.cmake 16 + +++ b/cmake/Modules/AddCompilerRT.cmake 17 + @@ -366,14 +366,6 @@ function(add_compiler_rt_runtime name type) 18 + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") 19 + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") 20 + endif() 21 + - if(APPLE) 22 + - # Ad-hoc sign the dylibs 23 + - add_custom_command(TARGET ${libname} 24 + - POST_BUILD 25 + - COMMAND codesign --sign - $<TARGET_FILE:${libname}> 26 + - WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR} 27 + - ) 28 + - endif() 29 + endif() 30 + 31 + set(parent_target_arg) 32 + 2.14.1 33 +
+71
pkgs/development/compilers/llvm/14/compiler-rt/darwin-targetconditionals.patch
··· 1 + diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp 2 + --- a/lib/sanitizer_common/sanitizer_mac.cpp 3 + +++ b/lib/sanitizer_common/sanitizer_mac.cpp 4 + @@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) { 5 + // Offset example: 6 + // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4 7 + constexpr u16 GetOSMajorKernelOffset() { 8 + - if (TARGET_OS_OSX) return 4; 9 + - if (TARGET_OS_IOS || TARGET_OS_TV) return 6; 10 + - if (TARGET_OS_WATCH) return 13; 11 + +#if TARGET_OS_OSX 12 + + return 4; 13 + +#endif 14 + +#if TARGET_OS_IOS || TARGET_OS_TV 15 + + return 6; 16 + +#endif 17 + +#if TARGET_OS_WATCH 18 + + return 13; 19 + +#endif 20 + } 21 + 22 + using VersStr = char[64]; 23 + @@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) { 24 + u16 os_major = kernel_major - offset; 25 + 26 + const char *format = "%d.0"; 27 + - if (TARGET_OS_OSX) { 28 + - if (os_major >= 16) { // macOS 11+ 29 + - os_major -= 5; 30 + - } else { // macOS 10.15 and below 31 + - format = "10.%d"; 32 + - } 33 + +#if TARGET_OS_OSX 34 + + if (os_major >= 16) { // macOS 11+ 35 + + os_major -= 5; 36 + + } else { // macOS 10.15 and below 37 + + format = "10.%d"; 38 + } 39 + +#endif 40 + return internal_snprintf(vers, sizeof(VersStr), format, os_major); 41 + } 42 + 43 + @@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) { 44 + // Aligned versions example: 45 + // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6 46 + static void MapToMacos(u16 *major, u16 *minor) { 47 + - if (TARGET_OS_OSX) 48 + - return; 49 + - 50 + - if (TARGET_OS_IOS || TARGET_OS_TV) 51 + +#if !TARGET_OS_OSX 52 + +#if TARGET_OS_IOS || TARGET_OS_TV 53 + *major += 2; 54 + - else if (TARGET_OS_WATCH) 55 + +#elif TARGET_OS_WATCH 56 + *major += 9; 57 + - else 58 + +#else 59 + UNREACHABLE("unsupported platform"); 60 + +#endif 61 + 62 + if (*major >= 16) { // macOS 11+ 63 + *major -= 5; 64 + @@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) { 65 + *minor = *major; 66 + *major = 10; 67 + } 68 + +#endif 69 + } 70 + 71 + static MacosVersion GetMacosAlignedVersionInternal() {
+126
pkgs/development/compilers/llvm/14/compiler-rt/default.nix
··· 1 + { lib, stdenv, llvm_meta, version 2 + , monorepoSrc, runCommand 3 + , cmake, python3, libllvm, libcxxabi 4 + }: 5 + 6 + let 7 + 8 + useLLVM = stdenv.hostPlatform.useLLVM or false; 9 + bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 10 + haveLibc = stdenv.cc.libc != null; 11 + inherit (stdenv.hostPlatform) isMusl; 12 + 13 + baseName = "compiler-rt"; 14 + 15 + src = runCommand "${baseName}-src-${version}" {} '' 16 + mkdir -p "$out" 17 + cp -r ${monorepoSrc}/cmake "$out" 18 + cp -r ${monorepoSrc}/${baseName} "$out" 19 + ''; 20 + in 21 + 22 + stdenv.mkDerivation { 23 + pname = baseName + lib.optionalString (haveLibc) "-libc"; 24 + inherit version; 25 + 26 + inherit src; 27 + sourceRoot = "${src.name}/${baseName}"; 28 + 29 + nativeBuildInputs = [ cmake python3 libllvm.dev ]; 30 + buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 31 + 32 + NIX_CFLAGS_COMPILE = [ 33 + "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" 34 + ]; 35 + 36 + cmakeFlags = [ 37 + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" 38 + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" 39 + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" 40 + ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [ 41 + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" 42 + "-DCOMPILER_RT_BUILD_XRAY=OFF" 43 + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 44 + "-DCOMPILER_RT_BUILD_PROFILE=OFF" 45 + "-DCOMPILER_RT_BUILD_MEMPROF=OFF" 46 + "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary 47 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 48 + "-DCMAKE_C_COMPILER_WORKS=ON" 49 + "-DCMAKE_CXX_COMPILER_WORKS=ON" 50 + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 51 + "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 52 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 53 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 54 + ] ++ lib.optionals (useLLVM) [ 55 + "-DCOMPILER_RT_BUILD_BUILTINS=ON" 56 + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 57 + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 58 + ] ++ lib.optionals (bareMetal) [ 59 + "-DCOMPILER_RT_OS_DIR=baremetal" 60 + ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ 61 + "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" 62 + "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}" 63 + "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}" 64 + ]; 65 + 66 + outputs = [ "out" "dev" ]; 67 + 68 + patches = [ 69 + ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory 70 + ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config 71 + ./gnu-install-dirs.patch 72 + # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 73 + # extra `/`. 74 + ./normalize-var.patch 75 + ] # Prevent a compilation error on darwin 76 + ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 77 + ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 78 + 79 + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 80 + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra 81 + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd 82 + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by 83 + # a flag and turn the flag off during the stdenv build. 84 + postPatch = lib.optionalString (!stdenv.isDarwin) '' 85 + substituteInPlace cmake/builtin-config-ix.cmake \ 86 + --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 87 + '' + lib.optionalString stdenv.isDarwin '' 88 + substituteInPlace cmake/builtin-config-ix.cmake \ 89 + --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 90 + substituteInPlace cmake/config-ix.cmake \ 91 + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 92 + '' + lib.optionalString (useLLVM) '' 93 + substituteInPlace lib/builtins/int_util.c \ 94 + --replace "#include <stdlib.h>" "" 95 + substituteInPlace lib/builtins/clear_cache.c \ 96 + --replace "#include <assert.h>" "" 97 + substituteInPlace lib/builtins/cpu_model.c \ 98 + --replace "#include <assert.h>" "" 99 + ''; 100 + 101 + # Hack around weird upsream RPATH bug 102 + postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' 103 + ln -s "$out/lib"/*/* "$out/lib" 104 + '' + lib.optionalString (useLLVM) '' 105 + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o 106 + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o 107 + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 108 + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 109 + ''; 110 + 111 + meta = llvm_meta // { 112 + homepage = "https://compiler-rt.llvm.org/"; 113 + description = "Compiler runtime libraries"; 114 + longDescription = '' 115 + The compiler-rt project provides highly tuned implementations of the 116 + low-level code generator support routines like "__fixunsdfdi" and other 117 + calls generated when a target doesn't have a short sequence of native 118 + instructions to implement a core IR operation. It also provides 119 + implementations of run-time libraries for dynamic testing tools such as 120 + AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer. 121 + ''; 122 + # "All of the code in the compiler-rt project is dual licensed under the MIT 123 + # license and the UIUC License (a BSD-like license)": 124 + license = with lib.licenses; [ mit ncsa ]; 125 + }; 126 + }
+55
pkgs/development/compilers/llvm/14/compiler-rt/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index c5003b5efa1d..4fffb9721284 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -5,6 +5,8 @@ 6 + 7 + cmake_minimum_required(VERSION 3.13.4) 8 + 9 + +include(GNUInstallDirs) 10 + + 11 + # Check if compiler-rt is built as a standalone project. 12 + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD) 13 + project(CompilerRT C CXX ASM) 14 + diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake 15 + index 1ada0ab30ba0..b4be6c4a3c73 100644 16 + --- a/cmake/base-config-ix.cmake 17 + +++ b/cmake/base-config-ix.cmake 18 + @@ -66,7 +66,7 @@ if (LLVM_TREE_AVAILABLE) 19 + else() 20 + # Take output dir and install path from the user. 21 + set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH 22 + - "Path where built compiler-rt libraries should be stored.") 23 + + "Path where built compiler-rt build artifacts should be stored.") 24 + set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH 25 + "Path where built compiler-rt executables should be stored.") 26 + set(COMPILER_RT_INSTALL_PATH "" CACHE PATH 27 + @@ -98,23 +98,23 @@ endif() 28 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 29 + set(COMPILER_RT_OUTPUT_LIBRARY_DIR 30 + ${COMPILER_RT_OUTPUT_DIR}/lib) 31 + - extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib) 32 + + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}") 33 + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH 34 + "Path where built compiler-rt libraries should be installed.") 35 + else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 36 + set(COMPILER_RT_OUTPUT_LIBRARY_DIR 37 + ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) 38 + - extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}") 39 + + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}/${COMPILER_RT_OS_DIR}") 40 + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH 41 + "Path where built compiler-rt libraries should be installed.") 42 + endif() 43 + -extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" bin) 44 + +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_BINDIR}") 45 + set(COMPILER_RT_INSTALL_BINARY_DIR "${default_install_path}" CACHE PATH 46 + "Path where built compiler-rt executables should be installed.") 47 + -extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" include) 48 + +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_INCLUDEDIR}") 49 + set(COMPILER_RT_INSTALL_INCLUDE_DIR "${default_install_path}" CACHE PATH 50 + "Path where compiler-rt headers should be installed.") 51 + -extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" share) 52 + +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_DATADIR}") 53 + set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH 54 + "Path where compiler-rt data files should be installed.") 55 +
+16
pkgs/development/compilers/llvm/14/compiler-rt/normalize-var.patch
··· 1 + diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake 2 + index f1f46fb9599c..6f19e69507ba 100644 3 + --- a/cmake/Modules/CompilerRTUtils.cmake 4 + +++ b/cmake/Modules/CompilerRTUtils.cmake 5 + @@ -302,8 +302,9 @@ macro(load_llvm_config) 6 + # Get some LLVM variables from LLVMConfig. 7 + include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") 8 + 9 + - set(LLVM_LIBRARY_OUTPUT_INTDIR 10 + - ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) 11 + + get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR 12 + + ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX} 13 + + REALPATH) 14 + endif() 15 + endmacro() 16 +
+278
pkgs/development/compilers/llvm/14/default.nix
··· 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 3 + , libxml2, python3, isl, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith 4 + , buildLlvmTools # tools, but from the previous stage, for cross 5 + , targetLlvmLibraries # libraries, but from the next stage, for cross 6 + # This is the default binutils, but with *this* version of LLD rather 7 + # than the default LLVM verion's, if LLD is the choice. We use these for 8 + # the `useLLVM` bootstrapping below. 9 + , bootBintoolsNoLibc ? 10 + if stdenv.targetPlatform.linker == "lld" 11 + then null 12 + else pkgs.bintoolsNoLibc 13 + , bootBintools ? 14 + if stdenv.targetPlatform.linker == "lld" 15 + then null 16 + else pkgs.bintools 17 + , darwin 18 + }: 19 + 20 + let 21 + release_version = "14.0.0"; 22 + candidate = ""; # empty or "rcN" 23 + dash-candidate = lib.optionalString (candidate != "") "-${candidate}"; 24 + rev = "fb1582f6c54422995c6fb61ba4c55126b357f64e"; # When using a Git commit 25 + rev-version = "unstable-2022-01-07"; # When using a Git commit 26 + version = if rev != "" then rev-version else "${release_version}${dash-candidate}"; 27 + targetConfig = stdenv.targetPlatform.config; 28 + 29 + monorepoSrc = fetchFromGitHub { 30 + owner = "llvm"; 31 + repo = "llvm-project"; 32 + rev = if rev != "" then rev else "llvmorg-${version}"; 33 + sha256 = "1pkgdsscvf59i22ix763lp2z3sg0v2z2ywh0n07k3ki7q1qpqbhk"; 34 + }; 35 + 36 + llvm_meta = { 37 + license = lib.licenses.ncsa; 38 + maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ]; 39 + platforms = lib.platforms.all; 40 + }; 41 + 42 + tools = lib.makeExtensible (tools: let 43 + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc buildLlvmTools; }); 44 + mkExtraBuildCommands0 = cc: '' 45 + rsrc="$out/resource-root" 46 + mkdir "$rsrc" 47 + ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc" 48 + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags 49 + ''; 50 + mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' 51 + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" 52 + ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share" 53 + ''; 54 + 55 + bintoolsNoLibc' = 56 + if bootBintoolsNoLibc == null 57 + then tools.bintoolsNoLibc 58 + else bootBintoolsNoLibc; 59 + bintools' = 60 + if bootBintools == null 61 + then tools.bintools 62 + else bootBintools; 63 + 64 + in { 65 + 66 + libllvm = callPackage ./llvm { 67 + inherit llvm_meta; 68 + }; 69 + 70 + # `llvm` historically had the binaries. When choosing an output explicitly, 71 + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 72 + llvm = tools.libllvm.out // { outputSpecified = false; }; 73 + 74 + libclang = callPackage ./clang { 75 + inherit llvm_meta; 76 + }; 77 + 78 + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; 79 + 80 + llvm-manpages = lowPrio (tools.libllvm.override { 81 + enableManpages = true; 82 + python3 = pkgs.python3; # don't use python-boot 83 + }); 84 + 85 + clang-manpages = lowPrio (tools.libclang.override { 86 + enableManpages = true; 87 + python3 = pkgs.python3; # don't use python-boot 88 + }); 89 + 90 + # TODO: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins' 91 + # lldb-manpages = lowPrio (tools.lldb.override { 92 + # enableManpages = true; 93 + # python3 = pkgs.python3; # don't use python-boot 94 + # }); 95 + 96 + # pick clang appropriate for package set we are targeting 97 + clang = 98 + /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM 99 + else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang 100 + else tools.libcxxClang; 101 + 102 + libstdcxxClang = wrapCCWith rec { 103 + cc = tools.clang-unwrapped; 104 + # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper. 105 + libcxx = null; 106 + extraPackages = [ 107 + targetLlvmLibraries.compiler-rt 108 + ]; 109 + extraBuildCommands = mkExtraBuildCommands cc; 110 + }; 111 + 112 + libcxxClang = wrapCCWith rec { 113 + cc = tools.clang-unwrapped; 114 + libcxx = targetLlvmLibraries.libcxx; 115 + extraPackages = [ 116 + targetLlvmLibraries.libcxxabi 117 + targetLlvmLibraries.compiler-rt 118 + ]; 119 + extraBuildCommands = mkExtraBuildCommands cc; 120 + }; 121 + 122 + lld = callPackage ./lld { 123 + inherit llvm_meta; 124 + }; 125 + 126 + lldb = callPackage ./lldb { 127 + inherit llvm_meta; 128 + inherit (darwin) libobjc bootstrap_cmds; 129 + inherit (darwin.apple_sdk.libs) xpc; 130 + inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; 131 + }; 132 + 133 + # Below, is the LLVM bootstrapping logic. It handles building a 134 + # fully LLVM toolchain from scratch. No GCC toolchain should be 135 + # pulled in. As a consequence, it is very quick to build different 136 + # targets provided by LLVM and we can also build for what GCC 137 + # doesn’t support like LLVM. Probably we should move to some other 138 + # file. 139 + 140 + bintools-unwrapped = callPackage ./bintools {}; 141 + 142 + bintoolsNoLibc = wrapBintoolsWith { 143 + bintools = tools.bintools-unwrapped; 144 + libc = preLibcCrossHeaders; 145 + }; 146 + 147 + bintools = wrapBintoolsWith { 148 + bintools = tools.bintools-unwrapped; 149 + }; 150 + 151 + clangUseLLVM = wrapCCWith rec { 152 + cc = tools.clang-unwrapped; 153 + libcxx = targetLlvmLibraries.libcxx; 154 + bintools = bintools'; 155 + extraPackages = [ 156 + targetLlvmLibraries.libcxxabi 157 + targetLlvmLibraries.compiler-rt 158 + ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ 159 + targetLlvmLibraries.libunwind 160 + ]; 161 + extraBuildCommands = '' 162 + echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags 163 + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 164 + '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 165 + echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 166 + '' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' 167 + echo "-lunwind" >> $out/nix-support/cc-ldflags 168 + '' + lib.optionalString stdenv.targetPlatform.isWasm '' 169 + echo "-fno-exceptions" >> $out/nix-support/cc-cflags 170 + '' + mkExtraBuildCommands cc; 171 + }; 172 + 173 + clangNoLibcxx = wrapCCWith rec { 174 + cc = tools.clang-unwrapped; 175 + libcxx = null; 176 + bintools = bintools'; 177 + extraPackages = [ 178 + targetLlvmLibraries.compiler-rt 179 + ]; 180 + extraBuildCommands = '' 181 + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags 182 + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 183 + echo "-nostdlib++" >> $out/nix-support/cc-cflags 184 + '' + mkExtraBuildCommands cc; 185 + }; 186 + 187 + clangNoLibc = wrapCCWith rec { 188 + cc = tools.clang-unwrapped; 189 + libcxx = null; 190 + bintools = bintoolsNoLibc'; 191 + extraPackages = [ 192 + targetLlvmLibraries.compiler-rt 193 + ]; 194 + extraBuildCommands = '' 195 + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags 196 + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 197 + '' + mkExtraBuildCommands cc; 198 + }; 199 + 200 + clangNoCompilerRt = wrapCCWith rec { 201 + cc = tools.clang-unwrapped; 202 + libcxx = null; 203 + bintools = bintoolsNoLibc'; 204 + extraPackages = [ ]; 205 + extraBuildCommands = '' 206 + echo "-nostartfiles" >> $out/nix-support/cc-cflags 207 + '' + mkExtraBuildCommands0 cc; 208 + }; 209 + 210 + clangNoCompilerRtWithLibc = wrapCCWith rec { 211 + cc = tools.clang-unwrapped; 212 + libcxx = null; 213 + bintools = bintools'; 214 + extraPackages = [ ]; 215 + extraBuildCommands = mkExtraBuildCommands0 cc; 216 + }; 217 + 218 + }); 219 + 220 + libraries = lib.makeExtensible (libraries: let 221 + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc; }); 222 + in { 223 + 224 + compiler-rt-libc = callPackage ./compiler-rt { 225 + inherit llvm_meta; 226 + stdenv = if stdenv.hostPlatform.useLLVM or false 227 + then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc 228 + else stdenv; 229 + }; 230 + 231 + compiler-rt-no-libc = callPackage ./compiler-rt { 232 + inherit llvm_meta; 233 + stdenv = if stdenv.hostPlatform.useLLVM or false 234 + then overrideCC stdenv buildLlvmTools.clangNoCompilerRt 235 + else stdenv; 236 + }; 237 + 238 + # N.B. condition is safe because without useLLVM both are the same. 239 + compiler-rt = if stdenv.hostPlatform.isAndroid 240 + then libraries.compiler-rt-libc 241 + else libraries.compiler-rt-no-libc; 242 + 243 + stdenv = overrideCC stdenv buildLlvmTools.clang; 244 + 245 + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; 246 + 247 + libcxx = callPackage ./libcxx { 248 + inherit llvm_meta; 249 + stdenv = if stdenv.hostPlatform.useLLVM or false 250 + then overrideCC stdenv buildLlvmTools.clangNoLibcxx 251 + else stdenv; 252 + }; 253 + 254 + libcxxabi = let 255 + stdenv_ = if stdenv.hostPlatform.useLLVM or false 256 + then overrideCC stdenv buildLlvmTools.clangNoLibcxx 257 + else stdenv; 258 + cxx-headers = callPackage ./libcxx { 259 + inherit llvm_meta; 260 + stdenv = stdenv_; 261 + headersOnly = true; 262 + }; 263 + in callPackage ./libcxxabi { 264 + stdenv = stdenv_; 265 + inherit llvm_meta cxx-headers; 266 + }; 267 + 268 + libunwind = callPackage ./libunwind { 269 + inherit llvm_meta; 270 + stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; 271 + }; 272 + 273 + openmp = callPackage ./openmp { 274 + inherit llvm_meta; 275 + }; 276 + }); 277 + 278 + in { inherit tools libraries release_version; } // libraries // tools
+89
pkgs/development/compilers/llvm/14/libcxx/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , monorepoSrc, runCommand 3 + , cmake, python3, fixDarwinDylibNames, version 4 + , libcxxabi 5 + , enableShared ? !stdenv.hostPlatform.isStatic 6 + 7 + # If headersOnly is true, the resulting package would only include the headers. 8 + # Use this to break the circular dependency between libcxx and libcxxabi. 9 + # 10 + # Some context: 11 + # https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb 12 + , headersOnly ? false 13 + }: 14 + 15 + let 16 + basename = "libcxx"; 17 + in 18 + 19 + stdenv.mkDerivation rec { 20 + pname = basename + lib.optionalString headersOnly "-headers"; 21 + inherit version; 22 + 23 + src = runCommand "${pname}-src-${version}" {} '' 24 + mkdir -p "$out" 25 + cp -r ${monorepoSrc}/cmake "$out" 26 + cp -r ${monorepoSrc}/${basename} "$out" 27 + mkdir -p "$out/libcxxabi" 28 + cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi" 29 + mkdir -p "$out/llvm" 30 + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 31 + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" 32 + ''; 33 + 34 + sourceRoot = "${src.name}/${basename}"; 35 + 36 + outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev"; 37 + 38 + patches = [ 39 + ./gnu-install-dirs.patch 40 + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 41 + ../../libcxx-0001-musl-hacks.patch 42 + ]; 43 + 44 + preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' 45 + patchShebangs utils/cat_files.py 46 + ''; 47 + 48 + nativeBuildInputs = [ cmake python3 ] 49 + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 50 + 51 + buildInputs = lib.optionals (!headersOnly) [ libcxxabi ]; 52 + 53 + cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ] 54 + ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 55 + ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 56 + ++ lib.optionals stdenv.hostPlatform.isWasm [ 57 + "-DLIBCXX_ENABLE_THREADS=OFF" 58 + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 59 + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" 60 + ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; 61 + 62 + buildFlags = lib.optional headersOnly "generate-cxx-headers"; 63 + installTargets = lib.optional headersOnly "install-cxx-headers"; 64 + 65 + # At this point, cxxabi headers would be installed in the dev output, which 66 + # prevents moveToOutput from doing its job later in the build process. 67 + postInstall = lib.optionalString (!headersOnly) '' 68 + mv "$dev/include/c++/v1/"* "$out/include/c++/v1/" 69 + pushd "$dev" 70 + rmdir -p include/c++/v1 71 + popd 72 + ''; 73 + 74 + passthru = { 75 + isLLVM = true; 76 + }; 77 + 78 + meta = llvm_meta // { 79 + homepage = "https://libcxx.llvm.org/"; 80 + description = "C++ standard library"; 81 + longDescription = '' 82 + libc++ is an implementation of the C++ standard library, targeting C++11, 83 + C++14 and above. 84 + ''; 85 + # "All of the code in libc++ is dual licensed under the MIT license and the 86 + # UIUC License (a BSD-like license)": 87 + license = with lib.licenses; [ mit ncsa ]; 88 + }; 89 + }
+85
pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index b0569a4a54ca..7d665f5a3258 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -10,6 +10,8 @@ endif() 6 + #=============================================================================== 7 + cmake_minimum_required(VERSION 3.13.4) 8 + 9 + +include(GNUInstallDirs) 10 + + 11 + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") 12 + 13 + # Add path for custom modules 14 + @@ -415,13 +417,13 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 15 + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 16 + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 17 + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") 18 + - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 19 + + set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH 20 + "Path where built libc++ libraries should be installed.") 21 + - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH 22 + + set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 23 + "Path where built libc++ runtime libraries should be installed.") 24 + - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH 25 + + set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH 26 + "Path where target-agnostic libc++ headers should be installed.") 27 + - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH 28 + + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH 29 + "Path where target-specific libc++ headers should be installed.") 30 + if(LIBCXX_LIBDIR_SUBDIR) 31 + string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) 32 + @@ -431,11 +433,11 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR) 33 + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 34 + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 35 + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") 36 + - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 37 + + set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 38 + "Path where built libc++ libraries should be installed.") 39 + - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH 40 + + set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}/c++/v1" CACHE PATH 41 + "Path where built libc++ runtime libraries should be installed.") 42 + - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH 43 + + set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH 44 + "Path where target-agnostic libc++ headers should be installed.") 45 + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH 46 + "Path where target-specific libc++ headers should be installed.") 47 + @@ -443,11 +445,11 @@ else() 48 + set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) 49 + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") 50 + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") 51 + - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 52 + + set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 53 + "Path where built libc++ libraries should be installed.") 54 + - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH 55 + + set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 56 + "Path where built libc++ runtime libraries should be installed.") 57 + - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH 58 + + set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH 59 + "Path where target-agnostic libc++ headers should be installed.") 60 + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH 61 + "Path where target-specific libc++ headers should be installed.") 62 + diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake 63 + index 5a8a4a270a1a..d69405ddeeac 100644 64 + --- a/cmake/Modules/HandleLibCXXABI.cmake 65 + +++ b/cmake/Modules/HandleLibCXXABI.cmake 66 + @@ -1,8 +1,9 @@ 67 + - 68 + #=============================================================================== 69 + # Add an ABI library if appropriate 70 + #=============================================================================== 71 + 72 + +include(GNUInstallDirs) 73 + + 74 + # 75 + # _setup_abi: Set up the build to use an ABI library 76 + # 77 + @@ -63,7 +64,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) 78 + 79 + if (LIBCXX_INSTALL_HEADERS) 80 + install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" 81 + - DESTINATION include/c++/v1/${dstdir} 82 + + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}" 83 + COMPONENT cxx-headers 84 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ 85 + )
+86
pkgs/development/compilers/llvm/14/libcxxabi/default.nix
··· 1 + { lib, stdenv, llvm_meta, cmake, python3 2 + , monorepoSrc, runCommand 3 + , cxx-headers, libunwind, version 4 + , enableShared ? !stdenv.hostPlatform.isStatic 5 + }: 6 + 7 + stdenv.mkDerivation rec { 8 + pname = "libcxxabi"; 9 + inherit version; 10 + 11 + src = runCommand "${pname}-src-${version}" {} '' 12 + mkdir -p "$out" 13 + cp -r ${monorepoSrc}/cmake "$out" 14 + cp -r ${monorepoSrc}/${pname} "$out" 15 + mkdir -p "$out/libcxx/src" 16 + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" 17 + cp -r ${monorepoSrc}/libcxx/include "$out/libcxx" 18 + cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src" 19 + mkdir -p "$out/llvm" 20 + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 21 + ''; 22 + 23 + sourceRoot = "${src.name}/${pname}"; 24 + 25 + outputs = [ "out" "dev" ]; 26 + 27 + postUnpack = lib.optionalString stdenv.isDarwin '' 28 + export TRIPLE=x86_64-apple-darwin 29 + '' + lib.optionalString stdenv.hostPlatform.isWasm '' 30 + patch -p1 -d llvm -i ${./wasm.patch} 31 + ''; 32 + 33 + patches = [ 34 + ./gnu-install-dirs.patch 35 + ]; 36 + 37 + nativeBuildInputs = [ cmake python3 ]; 38 + buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; 39 + 40 + cmakeFlags = [ 41 + "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" 42 + ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 43 + "-DLLVM_ENABLE_LIBCXX=ON" 44 + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 45 + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 46 + "-DLIBCXXABI_ENABLE_THREADS=OFF" 47 + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" 48 + ] ++ lib.optionals (!enableShared) [ 49 + "-DLIBCXXABI_ENABLE_SHARED=OFF" 50 + ]; 51 + 52 + installPhase = if stdenv.isDarwin 53 + then '' 54 + for file in lib/*.dylib; do 55 + # this should be done in CMake, but having trouble figuring out 56 + # the magic combination of necessary CMake variables 57 + # if you fancy a try, take a look at 58 + # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling 59 + install_name_tool -id $out/$file $file 60 + done 61 + make install 62 + install -d 755 $out/include 63 + install -m 644 ../include/*.h $out/include 64 + '' 65 + else '' 66 + install -d -m 755 $out/include $out/lib 67 + install -m 644 lib/libc++abi.a $out/lib 68 + install -m 644 ../include/cxxabi.h $out/include 69 + '' + lib.optionalString enableShared '' 70 + install -m 644 lib/libc++abi.so.1.0 $out/lib 71 + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so 72 + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 73 + ''; 74 + 75 + meta = llvm_meta // { 76 + homepage = "https://libcxxabi.llvm.org/"; 77 + description = "Provides C++ standard library support"; 78 + longDescription = '' 79 + libc++abi is a new implementation of low level support for a standard C++ library. 80 + ''; 81 + # "All of the code in libc++abi is dual licensed under the MIT license and 82 + # the UIUC License (a BSD-like license)": 83 + license = with lib.licenses; [ mit ncsa ]; 84 + maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; 85 + }; 86 + }
+46
pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 858f5d5cfd7f..16c67d7062be 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -10,6 +10,8 @@ endif() 6 + 7 + cmake_minimum_required(VERSION 3.13.4) 8 + 9 + +include(GNUInstallDirs) 10 + + 11 + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") 12 + 13 + # Add path for custom modules 14 + @@ -213,9 +215,9 @@ set(CMAKE_MODULE_PATH 15 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 16 + set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) 17 + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 18 + - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 19 + + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 20 + "Path where built libc++abi libraries should be installed.") 21 + - set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH 22 + + set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 23 + "Path where built libc++abi runtime libraries should be installed.") 24 + if(LIBCXX_LIBDIR_SUBDIR) 25 + string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) 26 + @@ -224,16 +226,16 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 27 + elseif(LLVM_LIBRARY_OUTPUT_INTDIR) 28 + set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) 29 + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 30 + - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 31 + + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 32 + "Path where built libc++abi libraries should be installed.") 33 + - set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH 34 + + set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 35 + "Path where built libc++abi runtime libraries should be installed.") 36 + else() 37 + set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) 38 + set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) 39 + - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 40 + + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 41 + "Path where built libc++abi libraries should be installed.") 42 + - set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH 43 + + set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 44 + "Path where built libc++abi runtime libraries should be installed.") 45 + endif() 46 +
+16
pkgs/development/compilers/llvm/14/libcxxabi/wasm.patch
··· 1 + diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake 2 + index 15497d405e0..33f7f18193a 100644 3 + --- a/cmake/modules/HandleLLVMOptions.cmake 4 + +++ b/cmake/modules/HandleLLVMOptions.cmake 5 + @@ -127,7 +127,10 @@ else(WIN32) 6 + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) 7 + endif() 8 + else(FUCHSIA OR UNIX) 9 + - MESSAGE(SEND_ERROR "Unable to determine platform") 10 + + if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi") 11 + + else() 12 + + MESSAGE(SEND_ERROR "Unable to determine platform") 13 + + endif() 14 + endif(FUCHSIA OR UNIX) 15 + endif(WIN32) 16 +
+47
pkgs/development/compilers/llvm/14/libunwind/default.nix
··· 1 + { lib, stdenv, llvm_meta, version 2 + , monorepoSrc, runCommand 3 + , cmake 4 + , enableShared ? !stdenv.hostPlatform.isStatic 5 + }: 6 + 7 + stdenv.mkDerivation rec { 8 + pname = "libunwind"; 9 + inherit version; 10 + 11 + # I am not so comfortable giving libc++ and friends the whole monorepo as 12 + # requested, so I filter it to what is needed. 13 + src = runCommand "${pname}-src-${version}" {} '' 14 + mkdir -p "$out" 15 + cp -r ${monorepoSrc}/cmake "$out" 16 + cp -r ${monorepoSrc}/${pname} "$out" 17 + mkdir -p "$out/libcxx" 18 + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" 19 + cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx" 20 + mkdir -p "$out/llvm" 21 + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 22 + ''; 23 + 24 + sourceRoot = "${src.name}/${pname}"; 25 + 26 + patches = [ 27 + ./gnu-install-dirs.patch 28 + ]; 29 + 30 + outputs = [ "out" "dev" ]; 31 + 32 + nativeBuildInputs = [ cmake ]; 33 + 34 + cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; 35 + 36 + meta = llvm_meta // { 37 + # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst 38 + homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library"; 39 + description = "LLVM's unwinder library"; 40 + longDescription = '' 41 + The unwind library provides a family of _Unwind_* functions implementing 42 + the language-neutral stack unwinding portion of the Itanium C++ ABI (Level 43 + I). It is a dependency of the C++ ABI library, and sometimes is a 44 + dependency of other runtimes. 45 + ''; 46 + }; 47 + }
+65
pkgs/development/compilers/llvm/14/libunwind/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index e3cc66dd2226..1299b596ce0d 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -8,6 +8,8 @@ endif() 6 + 7 + cmake_minimum_required(VERSION 3.13.4) 8 + 9 + +include(GNUInstallDirs) 10 + + 11 + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") 12 + 13 + # Add path for custom modules 14 + @@ -139,25 +141,27 @@ set(CMAKE_MODULE_PATH 15 + 16 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 17 + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 18 + - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 19 + + set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH 20 + + "Path where built libunwind headers should be installed.") 21 + + set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 22 + "Path where built libunwind libraries should be installed.") 23 + - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH 24 + + set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 25 + "Path where built libunwind runtime libraries should be installed.") 26 + if(LIBCXX_LIBDIR_SUBDIR) 27 + string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) 28 + string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) 29 + endif() 30 + -elseif(LLVM_LIBRARY_OUTPUT_INTDIR) 31 + - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 32 + - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH 33 + - "Path where built libunwind libraries should be installed.") 34 + - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH 35 + - "Path where built libunwind runtime libraries should be installed.") 36 + else() 37 + - set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) 38 + - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH 39 + + if(LLVM_LIBRARY_OUTPUT_INTDIR) 40 + + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 41 + + else() 42 + + set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) 43 + + endif() 44 + + set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH 45 + + "Path where built libunwind headers should be installed.") 46 + + set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH 47 + "Path where built libunwind libraries should be installed.") 48 + - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH 49 + + set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 50 + "Path where built libunwind runtime libraries should be installed.") 51 + endif() 52 + 53 + diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt 54 + index c3bb1dd0f69f..adf1766c44cb 100644 55 + --- a/include/CMakeLists.txt 56 + +++ b/include/CMakeLists.txt 57 + @@ -14,7 +14,7 @@ if(LIBUNWIND_INSTALL_HEADERS) 58 + foreach(file ${files}) 59 + get_filename_component(dir ${file} DIRECTORY) 60 + install(FILES ${file} 61 + - DESTINATION "include/${dir}" 62 + + DESTINATION "${LIBUNWIND_INSTALL_INCLUDE_DIR}/${dir}" 63 + COMPONENT unwind-headers 64 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ 65 + )
+55
pkgs/development/compilers/llvm/14/lld/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , buildLlvmTools 3 + , monorepoSrc, runCommand 4 + , cmake 5 + , libxml2 6 + , libllvm 7 + , version 8 + }: 9 + 10 + stdenv.mkDerivation rec { 11 + pname = "lld"; 12 + inherit version; 13 + 14 + # Blank llvm dir just so relative path works 15 + src = runCommand "${pname}-src-${version}" {} '' 16 + mkdir -p "$out" 17 + cp -r ${monorepoSrc}/cmake "$out" 18 + cp -r ${monorepoSrc}/${pname} "$out" 19 + mkdir -p "$out/libunwind" 20 + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" 21 + mkdir -p "$out/llvm" 22 + ''; 23 + 24 + sourceRoot = "${src.name}/${pname}"; 25 + 26 + patches = [ 27 + ./gnu-install-dirs.patch 28 + # On Darwin the llvm-config is perhaps not working fine as the 29 + # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as 30 + # the include path is not correct. 31 + ./fix-root-src-dir.patch 32 + ]; 33 + 34 + nativeBuildInputs = [ cmake ]; 35 + buildInputs = [ libllvm libxml2 ]; 36 + 37 + cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 38 + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 39 + ]; 40 + 41 + outputs = [ "out" "lib" "dev" ]; 42 + 43 + meta = llvm_meta // { 44 + homepage = "https://lld.llvm.org/"; 45 + description = "The LLVM linker"; 46 + longDescription = '' 47 + LLD is a linker from the LLVM project that is a drop-in replacement for 48 + system linkers and runs much faster than them. It also provides features 49 + that are useful for toolchain developers. 50 + The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and 51 + WebAssembly in descending order of completeness. Internally, LLD consists 52 + of several different linkers. 53 + ''; 54 + }; 55 + }
+13
pkgs/development/compilers/llvm/14/lld/fix-root-src-dir.patch
··· 1 + diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt 2 + index e1a29b884d17..9d542f8fbfc1 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -64,7 +64,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 6 + 7 + set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") 8 + set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") 9 + - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") 10 + + set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") 11 + 12 + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 13 + NO_DEFAULT_PATH)
+22
pkgs/development/compilers/llvm/14/lld/gnu-install-dirs.patch
··· 1 + diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake 2 + index dd2898ce6236..ebbea040ff54 100644 3 + --- a/cmake/modules/AddLLD.cmake 4 + +++ b/cmake/modules/AddLLD.cmake 5 + @@ -18,8 +18,8 @@ macro(add_lld_library name) 6 + install(TARGETS ${name} 7 + COMPONENT ${name} 8 + ${export_to_lldtargets} 9 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 10 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 11 + + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 12 + + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 13 + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") 14 + 15 + if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES) 16 + @@ -62,5 +62,5 @@ endmacro() 17 + macro(add_lld_symlink name dest) 18 + add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) 19 + # Always generate install targets 20 + - llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) 21 + + llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) 22 + endmacro()
+144
pkgs/development/compilers/llvm/14/lldb/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , runCommand 3 + , monorepoSrc 4 + , cmake 5 + , zlib 6 + , ncurses 7 + , swig 8 + , which 9 + , libedit 10 + , libxml2 11 + , libllvm 12 + , libclang 13 + , python3 14 + , version 15 + , libobjc 16 + , xpc 17 + , Foundation 18 + , bootstrap_cmds 19 + , Carbon 20 + , Cocoa 21 + , lit 22 + , makeWrapper 23 + , enableManpages ? false 24 + }: 25 + 26 + stdenv.mkDerivation (rec { 27 + pname = "lldb"; 28 + inherit version; 29 + 30 + src = runCommand "${pname}-src-${version}" {} '' 31 + mkdir -p "$out" 32 + cp -r ${monorepoSrc}/cmake "$out" 33 + cp -r ${monorepoSrc}/${pname} "$out" 34 + ''; 35 + 36 + sourceRoot = "${src.name}/${pname}"; 37 + 38 + patches = [ 39 + ./procfs.patch 40 + (runCommand "resource-dir.patch" { 41 + clangLibDir = "${libclang.lib}/lib"; 42 + } '' 43 + substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir 44 + '') 45 + ./gnu-install-dirs.patch 46 + ]; 47 + 48 + outputs = [ "out" "lib" "dev" ]; 49 + 50 + nativeBuildInputs = [ 51 + cmake python3 which swig lit makeWrapper 52 + ] ++ lib.optionals enableManpages [ 53 + python3.pkgs.sphinx python3.pkgs.recommonmark 54 + ]; 55 + 56 + buildInputs = [ 57 + ncurses 58 + zlib 59 + libedit 60 + libxml2 61 + libllvm 62 + ] ++ lib.optionals stdenv.isDarwin [ 63 + libobjc 64 + xpc 65 + Foundation 66 + bootstrap_cmds 67 + Carbon 68 + Cocoa 69 + ]; 70 + 71 + hardeningDisable = [ "format" ]; 72 + 73 + cmakeFlags = [ 74 + "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" 75 + "-DLLVM_ENABLE_RTTI=OFF" 76 + "-DClang_DIR=${libclang.dev}/lib/cmake" 77 + "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" 78 + ] ++ lib.optionals stdenv.isDarwin [ 79 + "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" 80 + ] ++ lib.optionals (!stdenv.isDarwin) [ 81 + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic 82 + ] ++ lib.optionals enableManpages [ 83 + "-DLLVM_ENABLE_SPHINX=ON" 84 + "-DSPHINX_OUTPUT_MAN=ON" 85 + "-DSPHINX_OUTPUT_HTML=OFF" 86 + ] ++ lib.optionals doCheck [ 87 + "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" 88 + "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" 89 + ]; 90 + 91 + doCheck = false; 92 + 93 + installCheckPhase = '' 94 + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then 95 + return 1; 96 + fi 97 + ''; 98 + 99 + postInstall = '' 100 + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ 101 + 102 + # Editor support 103 + # vscode: 104 + install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json 105 + mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin 106 + ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin 107 + ''; 108 + 109 + meta = llvm_meta // { 110 + homepage = "https://lldb.llvm.org/"; 111 + description = "A next-generation high-performance debugger"; 112 + longDescription = '' 113 + LLDB is a next generation, high-performance debugger. It is built as a set 114 + of reusable components which highly leverage existing libraries in the 115 + larger LLVM Project, such as the Clang expression parser and LLVM 116 + disassembler. 117 + ''; 118 + }; 119 + } // lib.optionalAttrs enableManpages { 120 + pname = "lldb-manpages"; 121 + 122 + buildPhase = '' 123 + make docs-lldb-man 124 + ''; 125 + 126 + propagatedBuildInputs = []; 127 + 128 + # manually install lldb man page 129 + installPhase = '' 130 + mkdir -p $out/share/man/man1 131 + install docs/man/lldb.1 -t $out/share/man/man1/ 132 + ''; 133 + 134 + postPatch = null; 135 + postInstall = null; 136 + 137 + outputs = [ "out" ]; 138 + 139 + doCheck = false; 140 + 141 + meta = llvm_meta // { 142 + description = "man pages for LLDB ${version}"; 143 + }; 144 + })
+36
pkgs/development/compilers/llvm/14/lldb/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 79d451965ed4..78188978d6de 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -12,6 +12,8 @@ set(CMAKE_MODULE_PATH 6 + # If we are not building as part of LLVM, build LLDB as a standalone project, 7 + # using LLVM as an external library. 8 + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 9 + + include(GNUInstallDirs) 10 + + 11 + project(lldb) 12 + include(LLDBStandalone) 13 + 14 + diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake 15 + index 3291a7c808e1..b27d27ce6a87 100644 16 + --- a/cmake/modules/AddLLDB.cmake 17 + +++ b/cmake/modules/AddLLDB.cmake 18 + @@ -109,7 +109,7 @@ function(add_lldb_library name) 19 + endif() 20 + 21 + if(PARAM_SHARED) 22 + - set(install_dest lib${LLVM_LIBDIR_SUFFIX}) 23 + + set(install_dest ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 24 + if(PARAM_INSTALL_PREFIX) 25 + set(install_dest ${PARAM_INSTALL_PREFIX}) 26 + endif() 27 + diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt 28 + index 7d48491ec89a..c04543585588 100644 29 + --- a/tools/intel-features/CMakeLists.txt 30 + +++ b/tools/intel-features/CMakeLists.txt 31 + @@ -30,4 +30,4 @@ add_lldb_library(lldbIntelFeatures SHARED 32 + ) 33 + 34 + install(TARGETS lldbIntelFeatures 35 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}) 36 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+31
pkgs/development/compilers/llvm/14/lldb/procfs.patch
··· 1 + --- a/source/Plugins/Process/Linux/Procfs.h 2 + +++ b/source/Plugins/Process/Linux/Procfs.h 3 + @@ -11,21 +11,12 @@ 4 + // sys/procfs.h on Android/Linux for all supported architectures. 5 + 6 + #include <sys/ptrace.h> 7 + +#include <asm/ptrace.h> 8 + 9 + -#ifdef __ANDROID__ 10 + -#if defined(__arm64__) || defined(__aarch64__) 11 + -typedef unsigned long elf_greg_t; 12 + -typedef elf_greg_t 13 + - elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))]; 14 + -typedef struct user_fpsimd_state elf_fpregset_t; 15 + -#ifndef NT_FPREGSET 16 + -#define NT_FPREGSET NT_PRFPREG 17 + -#endif // NT_FPREGSET 18 + -#elif defined(__mips__) 19 + -#ifndef NT_FPREGSET 20 + -#define NT_FPREGSET NT_PRFPREG 21 + -#endif // NT_FPREGSET 22 + -#endif 23 + -#else // __ANDROID__ 24 + +#if !defined(__GLIBC__) && defined(__powerpc__) 25 + +#define pt_regs musl_pt_regs 26 + +#include <sys/procfs.h> 27 + +#undef pt_regs 28 + +#else 29 + #include <sys/procfs.h> 30 + -#endif // __ANDROID__ 31 + +#endif
+13
pkgs/development/compilers/llvm/14/lldb/resource-dir.patch
··· 1 + diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake 2 + index 37364341ff8b..7f74c1a3e257 100644 3 + --- a/cmake/modules/LLDBConfig.cmake 4 + +++ b/cmake/modules/LLDBConfig.cmake 5 + @@ -257,7 +257,7 @@ if (NOT TARGET clang-resource-headers) 6 + # Iterate over the possible places where the external resource directory 7 + # could be and pick the first that exists. 8 + foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}" 9 + - "${LLVM_BUILD_LIBRARY_DIR}" 10 + + "${LLVM_BUILD_LIBRARY_DIR}" "@clangLibDir@" 11 + "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") 12 + # Build the resource directory path by appending 'clang/<version number>'. 13 + set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
+254
pkgs/development/compilers/llvm/14/llvm/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , pkgsBuildBuild 3 + , monorepoSrc 4 + , runCommand 5 + , fetchpatch 6 + , cmake 7 + , python3 8 + , libffi 9 + , libbfd 10 + , libpfm 11 + , libxml2 12 + , ncurses 13 + , version 14 + , release_version 15 + , zlib 16 + , which 17 + , buildLlvmTools 18 + , debugVersion ? false 19 + , enableManpages ? false 20 + , enableSharedLibraries ? !stdenv.hostPlatform.isStatic 21 + , enablePFM ? !(stdenv.isDarwin 22 + || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 23 + || stdenv.isAarch32 # broken for the armv7l builder 24 + ) 25 + , enablePolly ? false 26 + } @args: 27 + 28 + let 29 + inherit (lib) optional optionals optionalString; 30 + 31 + # Used when creating a version-suffixed symlink of libLLVM.dylib 32 + shortVersion = with lib; 33 + concatStringsSep "." (take 1 (splitString "." release_version)); 34 + 35 + in stdenv.mkDerivation (rec { 36 + pname = "llvm"; 37 + inherit version; 38 + 39 + src = runCommand "${pname}-src-${version}" {} ('' 40 + mkdir -p "$out" 41 + cp -r ${monorepoSrc}/cmake "$out" 42 + cp -r ${monorepoSrc}/${pname} "$out" 43 + cp -r ${monorepoSrc}/third-party "$out" 44 + '' + lib.optionalString enablePolly '' 45 + cp -r ${monorepoSrc}/polly "$out/llvm/tools" 46 + ''); 47 + 48 + sourceRoot = "${src.name}/${pname}"; 49 + 50 + outputs = [ "out" "lib" "dev" "python" ]; 51 + 52 + nativeBuildInputs = [ cmake python3 ] 53 + ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; 54 + 55 + buildInputs = [ libxml2 libffi ] 56 + ++ optional enablePFM libpfm; # exegesis 57 + 58 + propagatedBuildInputs = [ ncurses zlib ]; 59 + 60 + checkInputs = [ which ]; 61 + 62 + patches = [ 63 + ./gnu-install-dirs.patch 64 + ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch; 65 + 66 + postPatch = optionalString stdenv.isDarwin '' 67 + substituteInPlace cmake/modules/AddLLVM.cmake \ 68 + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ 69 + --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" 70 + '' + '' 71 + # FileSystem permissions tests fail with various special bits 72 + substituteInPlace unittests/Support/CMakeLists.txt \ 73 + --replace "Path.cpp" "" 74 + rm unittests/Support/Path.cpp 75 + substituteInPlace unittests/IR/CMakeLists.txt \ 76 + --replace "PassBuilderCallbacksTest.cpp" "" 77 + rm unittests/IR/PassBuilderCallbacksTest.cpp 78 + rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test 79 + '' + optionalString stdenv.hostPlatform.isMusl '' 80 + patch -p1 -i ${../../TLI-musl.patch} 81 + substituteInPlace unittests/Support/CMakeLists.txt \ 82 + --replace "add_subdirectory(DynamicLibrary)" "" 83 + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp 84 + # valgrind unhappy with musl or glibc, but fails w/musl only 85 + rm test/CodeGen/AArch64/wineh4.mir 86 + '' + optionalString stdenv.hostPlatform.isAarch32 '' 87 + # skip failing X86 test cases on 32-bit ARM 88 + rm test/DebugInfo/X86/convert-debugloc.ll 89 + rm test/DebugInfo/X86/convert-inlined.ll 90 + rm test/DebugInfo/X86/convert-linked.ll 91 + rm test/tools/dsymutil/X86/op-convert.test 92 + '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' 93 + # Seems to require certain floating point hardware (NEON?) 94 + rm test/ExecutionEngine/frem.ll 95 + '' + '' 96 + patchShebangs test/BugPoint/compile-custom.ll.py 97 + ''; 98 + 99 + # hacky fix: created binaries need to be run before installation 100 + preBuild = '' 101 + mkdir -p $out/ 102 + ln -sv $PWD/lib $out 103 + ''; 104 + 105 + # E.g. mesa.drivers use the build-id as a cache key (see #93946): 106 + LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; 107 + 108 + cmakeFlags = with stdenv; let 109 + # These flags influence llvm-config's BuildVariables.inc in addition to the 110 + # general build. We need to make sure these are also passed via 111 + # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native 112 + # will return different results from the cross llvm-config. 113 + # 114 + # Some flags don't need to be repassed because LLVM already does so (like 115 + # CMAKE_BUILD_TYPE), others are irrelevant to the result. 116 + flagsForLlvmConfig = [ 117 + "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/" 118 + "-DLLVM_ENABLE_RTTI=ON" 119 + ] ++ optionals enableSharedLibraries [ 120 + "-DLLVM_LINK_LLVM_DYLIB=ON" 121 + ]; 122 + in flagsForLlvmConfig ++ [ 123 + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" 124 + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc 125 + "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" 126 + "-DLLVM_ENABLE_FFI=ON" 127 + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" 128 + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" 129 + "-DLLVM_ENABLE_DUMP=ON" 130 + ] ++ optionals stdenv.hostPlatform.isStatic [ 131 + # Disables building of shared libs, -fPIC is still injected by cc-wrapper 132 + "-DLLVM_ENABLE_PIC=OFF" 133 + "-DLLVM_BUILD_STATIC=ON" 134 + # libxml2 needs to be disabled because the LLVM build system ignores its .la 135 + # file and doesn't link zlib as well. 136 + # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812 137 + "-DLLVM_ENABLE_LIBXML2=OFF" 138 + ] ++ optionals enableManpages [ 139 + "-DLLVM_BUILD_DOCS=ON" 140 + "-DLLVM_ENABLE_SPHINX=ON" 141 + "-DSPHINX_OUTPUT_MAN=ON" 142 + "-DSPHINX_OUTPUT_HTML=OFF" 143 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 144 + ] ++ optionals (!isDarwin) [ 145 + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" 146 + ] ++ optionals isDarwin [ 147 + "-DLLVM_ENABLE_LIBCXX=ON" 148 + "-DCAN_TARGET_i386=false" 149 + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 150 + "-DCMAKE_CROSSCOMPILING=True" 151 + "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen" 152 + ( 153 + let 154 + nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc; 155 + nativeBintools = nativeCC.bintools.bintools; 156 + nativeToolchainFlags = [ 157 + "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc" 158 + "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++" 159 + "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar" 160 + "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" 161 + "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" 162 + ]; 163 + # We need to repass the custom GNUInstallDirs values, otherwise CMake 164 + # will choose them for us, leading to wrong results in llvm-config-native 165 + nativeInstallFlags = [ 166 + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" 167 + "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin" 168 + "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include" 169 + "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib" 170 + "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec" 171 + ]; 172 + in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=" 173 + + lib.concatStringsSep ";" (lib.concatLists [ 174 + flagsForLlvmConfig 175 + nativeToolchainFlags 176 + nativeInstallFlags 177 + ]) 178 + ) 179 + ]; 180 + 181 + postBuild = '' 182 + rm -fR $out 183 + ''; 184 + 185 + preCheck = '' 186 + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib 187 + ''; 188 + 189 + postInstall = '' 190 + mkdir -p $python/share 191 + mv $out/share/opt-viewer $python/share/opt-viewer 192 + moveToOutput "bin/llvm-config*" "$dev" 193 + substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ 194 + --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \ 195 + --replace "$out/bin/llvm-config" "$dev/bin/llvm-config" 196 + substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ 197 + --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")' 198 + '' 199 + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' 200 + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib 201 + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib 202 + '' 203 + + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' 204 + cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native 205 + ''; 206 + 207 + doCheck = stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl) 208 + && (stdenv.hostPlatform == stdenv.buildPlatform); 209 + 210 + checkTarget = "check-all"; 211 + 212 + requiredSystemFeatures = [ "big-parallel" ]; 213 + meta = llvm_meta // { 214 + homepage = "https://llvm.org/"; 215 + description = "A collection of modular and reusable compiler and toolchain technologies"; 216 + longDescription = '' 217 + The LLVM Project is a collection of modular and reusable compiler and 218 + toolchain technologies. Despite its name, LLVM has little to do with 219 + traditional virtual machines. The name "LLVM" itself is not an acronym; it 220 + is the full name of the project. 221 + LLVM began as a research project at the University of Illinois, with the 222 + goal of providing a modern, SSA-based compilation strategy capable of 223 + supporting both static and dynamic compilation of arbitrary programming 224 + languages. Since then, LLVM has grown to be an umbrella project consisting 225 + of a number of subprojects, many of which are being used in production by 226 + a wide variety of commercial and open source projects as well as being 227 + widely used in academic research. Code in the LLVM project is licensed 228 + under the "Apache 2.0 License with LLVM exceptions". 229 + ''; 230 + }; 231 + } // lib.optionalAttrs enableManpages { 232 + pname = "llvm-manpages"; 233 + 234 + buildPhase = '' 235 + make docs-llvm-man 236 + ''; 237 + 238 + propagatedBuildInputs = []; 239 + 240 + installPhase = '' 241 + make -C docs install 242 + ''; 243 + 244 + postPatch = null; 245 + postInstall = null; 246 + 247 + outputs = [ "out" ]; 248 + 249 + doCheck = false; 250 + 251 + meta = llvm_meta // { 252 + description = "man pages for LLVM ${version}"; 253 + }; 254 + })
+102
pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs-polly.patch
··· 1 + diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt 2 + index ca7c04c565bb..6a6155806ffa 100644 3 + --- a/tools/polly/CMakeLists.txt 4 + +++ b/tools/polly/CMakeLists.txt 5 + @@ -3,6 +3,8 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR) 6 + project(Polly) 7 + cmake_minimum_required(VERSION 3.13.4) 8 + 9 + + include(GNUInstallDirs) 10 + + 11 + # Where is LLVM installed? 12 + find_package(LLVM CONFIG REQUIRED) 13 + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) 14 + @@ -122,13 +124,13 @@ include_directories( 15 + 16 + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 17 + install(DIRECTORY include/ 18 + - DESTINATION include 19 + + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 20 + FILES_MATCHING 21 + PATTERN "*.h" 22 + ) 23 + 24 + install(DIRECTORY ${POLLY_BINARY_DIR}/include/ 25 + - DESTINATION include 26 + + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 27 + FILES_MATCHING 28 + PATTERN "*.h" 29 + PATTERN "CMakeFiles" EXCLUDE 30 + diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt 31 + index 7cc129ba2e90..137be25e4b80 100644 32 + --- a/tools/polly/cmake/CMakeLists.txt 33 + +++ b/tools/polly/cmake/CMakeLists.txt 34 + @@ -79,18 +79,18 @@ file(GENERATE 35 + 36 + # Generate PollyConfig.cmake for the install tree. 37 + unset(POLLY_EXPORTS) 38 + -set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 39 + +set(POLLY_INSTALL_PREFIX "") 40 + set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") 41 + -set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}") 42 + -set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}") 43 + +set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}") 44 + +set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 45 + if (POLLY_BUNDLED_ISL) 46 + set(POLLY_CONFIG_INCLUDE_DIRS 47 + - "${POLLY_INSTALL_PREFIX}/include" 48 + - "${POLLY_INSTALL_PREFIX}/include/polly" 49 + + "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}" 50 + + "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly" 51 + ) 52 + else() 53 + set(POLLY_CONFIG_INCLUDE_DIRS 54 + - "${POLLY_INSTALL_PREFIX}/include" 55 + + "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}" 56 + ${ISL_INCLUDE_DIRS} 57 + ) 58 + endif() 59 + @@ -100,12 +100,12 @@ endif() 60 + foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS) 61 + get_target_property(tgt_type ${tgt} TYPE) 62 + if (tgt_type STREQUAL "EXECUTABLE") 63 + - set(tgt_prefix "bin/") 64 + + set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/") 65 + else() 66 + - set(tgt_prefix "lib/") 67 + + set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/") 68 + endif() 69 + 70 + - set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>") 71 + + set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>") 72 + file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path}) 73 + 74 + if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY") 75 + diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake 76 + index 518a09b45a42..bd9d6f5542ad 100644 77 + --- a/tools/polly/cmake/polly_macros.cmake 78 + +++ b/tools/polly/cmake/polly_macros.cmake 79 + @@ -44,8 +44,8 @@ macro(add_polly_library name) 80 + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly") 81 + install(TARGETS ${name} 82 + EXPORT LLVMExports 83 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 84 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) 85 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} 86 + + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 87 + endif() 88 + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) 89 + endmacro(add_polly_library) 90 + diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt 91 + index e3a5683fccdc..293b482eb28a 100644 92 + --- a/tools/polly/lib/External/CMakeLists.txt 93 + +++ b/tools/polly/lib/External/CMakeLists.txt 94 + @@ -290,7 +290,7 @@ if (POLLY_BUNDLED_ISL) 95 + install(DIRECTORY 96 + ${ISL_SOURCE_DIR}/include/ 97 + ${ISL_BINARY_DIR}/include/ 98 + - DESTINATION include/polly 99 + + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly 100 + FILES_MATCHING 101 + PATTERN "*.h" 102 + PATTERN "CMakeFiles" EXCLUDE
+220
pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index fec956091cd5..5a766f5c5d7c 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -303,6 +303,9 @@ set(LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING 6 + "Path for examples subdirectory (enabled by LLVM_BUILD_EXAMPLES=ON) (defaults to 'examples')") 7 + mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR) 8 + 9 + +set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING 10 + + "Path for CMake subdirectory (defaults to lib/cmake/llvm)" ) 11 + + 12 + # They are used as destination of target generators. 13 + set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) 14 + set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) 15 + diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake 16 + index fed1fec7d72e..4baed19b9e98 100644 17 + --- a/cmake/modules/AddLLVM.cmake 18 + +++ b/cmake/modules/AddLLVM.cmake 19 + @@ -838,8 +838,8 @@ macro(add_llvm_library name) 20 + get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) 21 + install(TARGETS ${name} 22 + ${export_to_llvmexports} 23 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} 24 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} 25 + + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} 26 + + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} 27 + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) 28 + 29 + if (NOT LLVM_ENABLE_IDE) 30 + @@ -1056,7 +1056,7 @@ function(process_llvm_pass_plugins) 31 + "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})") 32 + install(FILES 33 + ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake 34 + - DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} 35 + + DESTINATION ${LLVM_INSTALL_CMAKE_DIR} 36 + COMPONENT cmake-exports) 37 + 38 + set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def") 39 + @@ -1902,7 +1902,7 @@ function(llvm_install_library_symlink name dest type) 40 + set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX}) 41 + set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}) 42 + 43 + - set(output_dir lib${LLVM_LIBDIR_SUFFIX}) 44 + + set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 45 + if(WIN32 AND "${type}" STREQUAL "SHARED") 46 + set(output_dir bin) 47 + endif() 48 + @@ -1913,7 +1913,7 @@ function(llvm_install_library_symlink name dest type) 49 + 50 + endfunction() 51 + 52 + -function(llvm_install_symlink name dest) 53 + +function(llvm_install_symlink name dest output_dir) 54 + cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN}) 55 + foreach(path ${CMAKE_MODULE_PATH}) 56 + if(EXISTS ${path}/LLVMInstallSymlink.cmake) 57 + @@ -1936,7 +1936,7 @@ function(llvm_install_symlink name dest) 58 + set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX}) 59 + 60 + install(SCRIPT ${INSTALL_SYMLINK} 61 + - CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})" 62 + + CODE "install_symlink(${full_name} ${full_dest} ${output_dir})" 63 + COMPONENT ${component}) 64 + 65 + if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE) 66 + @@ -2019,7 +2019,8 @@ function(add_llvm_tool_symlink link_name target) 67 + endif() 68 + 69 + if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS) 70 + - llvm_install_symlink(${link_name} ${target}) 71 + + GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR) 72 + + llvm_install_symlink(${link_name} ${target} ${output_dir}) 73 + endif() 74 + endif() 75 + endfunction() 76 + @@ -2148,9 +2149,9 @@ function(llvm_setup_rpath name) 77 + # Since BUILD_SHARED_LIBS is only recommended for use by developers, 78 + # hardcode the rpath to build/install lib dir first in this mode. 79 + # FIXME: update this when there is better solution. 80 + - set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 81 + + set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 82 + elseif(UNIX) 83 + - set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 84 + + set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 85 + if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") 86 + set_property(TARGET ${name} APPEND_STRING PROPERTY 87 + LINK_FLAGS " -Wl,-z,origin ") 88 + diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake 89 + index 891c9e6d618c..8d963f3b0069 100644 90 + --- a/cmake/modules/AddOCaml.cmake 91 + +++ b/cmake/modules/AddOCaml.cmake 92 + @@ -147,9 +147,9 @@ function(add_ocaml_library name) 93 + endforeach() 94 + 95 + if( APPLE ) 96 + - set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}") 97 + + set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 98 + elseif( UNIX ) 99 + - set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}") 100 + + set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 101 + endif() 102 + list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}") 103 + 104 + diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt 105 + index cea0c1df0a14..eedcd9450312 100644 106 + --- a/cmake/modules/CMakeLists.txt 107 + +++ b/cmake/modules/CMakeLists.txt 108 + @@ -2,7 +2,7 @@ include(ExtendPath) 109 + include(LLVMDistributionSupport) 110 + include(FindPrefixFromConfig) 111 + 112 + -set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) 113 + +set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')") 114 + set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") 115 + 116 + # First for users who use an installed LLVM, create the LLVMExports.cmake file. 117 + @@ -122,7 +122,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS 118 + ) 119 + list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) 120 + 121 + -extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "lib\${LLVM_LIBDIR_SUFFIX}") 122 + +extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}") 123 + set(LLVM_CONFIG_LIBRARY_DIRS 124 + "${LLVM_CONFIG_LIBRARY_DIR}" 125 + # FIXME: Should there be other entries here? 126 + diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake 127 + index b5c35f706cb7..9261ab797de6 100644 128 + --- a/cmake/modules/LLVMInstallSymlink.cmake 129 + +++ b/cmake/modules/LLVMInstallSymlink.cmake 130 + @@ -6,7 +6,7 @@ include(GNUInstallDirs) 131 + 132 + function(install_symlink name target outdir) 133 + set(DESTDIR $ENV{DESTDIR}) 134 + - set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}") 135 + + set(bindir "${DESTDIR}${outdir}/") 136 + 137 + message(STATUS "Creating ${name}") 138 + 139 + diff --git a/docs/CMake.rst b/docs/CMake.rst 140 + index 044ec8a4d39d..504d0eac3ade 100644 141 + --- a/docs/CMake.rst 142 + +++ b/docs/CMake.rst 143 + @@ -224,7 +224,7 @@ description is in `LLVM-related variables`_ below. 144 + **LLVM_LIBDIR_SUFFIX**:STRING 145 + Extra suffix to append to the directory where libraries are to be 146 + installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` 147 + - to install libraries to ``/usr/lib64``. 148 + + to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``. 149 + 150 + **LLVM_PARALLEL_{COMPILE,LINK}_JOBS**:STRING 151 + Building the llvm toolchain can use a lot of resources, particularly 152 + @@ -910,9 +910,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``). 153 + 154 + This file is available in two different locations. 155 + 156 + -* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where 157 + - ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM. 158 + - On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``. 159 + +* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where 160 + + ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are 161 + + installed as part of an installed version of LLVM. This is typically 162 + + ``cmake/llvm/`` within the lib directory. On Linux, this is typically 163 + + ``/usr/lib/cmake/llvm/LLVMConfig.cmake``. 164 + 165 + * ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where 166 + ``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only 167 + diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt 168 + index b46319f24fc8..2feabd1954e4 100644 169 + --- a/include/llvm/CMakeLists.txt 170 + +++ b/include/llvm/CMakeLists.txt 171 + @@ -5,5 +5,5 @@ add_subdirectory(Frontend) 172 + # If we're doing an out-of-tree build, copy a module map for generated 173 + # header files into the build area. 174 + if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") 175 + - configure_file(module.modulemap.build module.modulemap COPYONLY) 176 + + configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY) 177 + endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") 178 + diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in 179 + index abbb8a450da6..70c497be12f5 100644 180 + --- a/tools/llvm-config/BuildVariables.inc.in 181 + +++ b/tools/llvm-config/BuildVariables.inc.in 182 + @@ -23,7 +23,10 @@ 183 + #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@" 184 + #define LLVM_BUILDMODE "@LLVM_BUILDMODE@" 185 + #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@" 186 + +#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@" 187 + +#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@" 188 + #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@" 189 + +#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@" 190 + #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@" 191 + #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@" 192 + #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@" 193 + diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp 194 + index 8ed88f33ead4..5e7184bab90d 100644 195 + --- a/tools/llvm-config/llvm-config.cpp 196 + +++ b/tools/llvm-config/llvm-config.cpp 197 + @@ -363,12 +363,20 @@ int main(int argc, char **argv) { 198 + ActiveIncludeDir = std::string(Path.str()); 199 + } 200 + { 201 + - SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR); 202 + + SmallString<256> Path(LLVM_INSTALL_BINDIR); 203 + sys::fs::make_absolute(ActivePrefix, Path); 204 + ActiveBinDir = std::string(Path.str()); 205 + } 206 + - ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; 207 + - ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; 208 + + { 209 + + SmallString<256> Path(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX); 210 + + sys::fs::make_absolute(ActivePrefix, Path); 211 + + ActiveLibDir = std::string(Path.str()); 212 + + } 213 + + { 214 + + SmallString<256> Path(LLVM_INSTALL_CMAKEDIR); 215 + + sys::fs::make_absolute(ActivePrefix, Path); 216 + + ActiveCMakeDir = std::string(Path.str()); 217 + + } 218 + ActiveIncludeOption = "-I" + ActiveIncludeDir; 219 + } 220 +
+54
pkgs/development/compilers/llvm/14/openmp/default.nix
··· 1 + { lib 2 + , stdenv 3 + , llvm_meta 4 + , monorepoSrc 5 + , runCommand 6 + , cmake 7 + , llvm 8 + , clang-unwrapped 9 + , perl 10 + , pkg-config 11 + , version 12 + }: 13 + 14 + stdenv.mkDerivation rec { 15 + pname = "openmp"; 16 + inherit version; 17 + 18 + src = runCommand "${pname}-src-${version}" {} '' 19 + mkdir -p "$out" 20 + cp -r ${monorepoSrc}/cmake "$out" 21 + cp -r ${monorepoSrc}/${pname} "$out" 22 + ''; 23 + 24 + sourceRoot = "${src.name}/${pname}"; 25 + 26 + patches = [ 27 + ./gnu-install-dirs.patch 28 + ./fix-find-tool.patch 29 + ]; 30 + 31 + outputs = [ "out" "dev" ]; 32 + 33 + nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped ]; 34 + buildInputs = [ llvm ]; 35 + 36 + cmakeFlags = [ 37 + "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails 38 + ]; 39 + 40 + meta = llvm_meta // { 41 + homepage = "https://openmp.llvm.org/"; 42 + description = "Support for the OpenMP language"; 43 + longDescription = '' 44 + The OpenMP subproject of LLVM contains the components required to build an 45 + executable OpenMP program that are outside the compiler itself. 46 + Contains the code for the runtime library against which code compiled by 47 + "clang -fopenmp" must be linked before it can run and the library that 48 + supports offload to target devices. 49 + ''; 50 + # "All of the code is dual licensed under the MIT license and the UIUC 51 + # License (a BSD-like license)": 52 + license = with lib.licenses; [ mit ncsa ]; 53 + }; 54 + }
+54
pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch
··· 1 + diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt 2 + index 242df638f80d..a4654e96371f 100644 3 + --- a/libomptarget/DeviceRTL/CMakeLists.txt 4 + +++ b/libomptarget/DeviceRTL/CMakeLists.txt 5 + @@ -25,16 +25,16 @@ endif() 6 + 7 + if (LLVM_DIR) 8 + # Builds that use pre-installed LLVM have LLVM_DIR set. 9 + - find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 10 + + find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) 11 + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} 12 + - NO_DEFAULT_PATH) 13 + - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 14 + + REQUIRED) 15 + + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) 16 + libomptarget_say("Building DeviceRTL. Using clang: ${CLANG_TOOL}") 17 + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) 18 + # LLVM in-tree builds may use CMake target names to discover the tools. 19 + - set(CLANG_TOOL $<TARGET_FILE:clang>) 20 + - set(LINK_TOOL $<TARGET_FILE:llvm-link>) 21 + - set(OPT_TOOL $<TARGET_FILE:opt>) 22 + + set(CLANG_TOOL $<TARGET_FILE:clang> REQUIRED) 23 + + set(LINK_TOOL $<TARGET_FILE:llvm-link> REQUIRED) 24 + + set(OPT_TOOL $<TARGET_FILE:opt> REQUIRED) 25 + libomptarget_say("Building DeviceRTL. Using clang from in-tree build") 26 + else() 27 + libomptarget_say("Not building DeviceRTL. No appropriate clang found") 28 + diff --git a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt 29 + index 3f4c02671aeb..be9f4677d7b5 100644 30 + --- a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt 31 + +++ b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt 32 + @@ -38,16 +38,16 @@ endif() 33 + 34 + if (LLVM_DIR) 35 + # Builds that use pre-installed LLVM have LLVM_DIR set. 36 + - find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 37 + + find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) 38 + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} 39 + - NO_DEFAULT_PATH) 40 + - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 41 + + REQUIRED) 42 + + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) 43 + libomptarget_say("Building AMDGCN device RTL. Using clang: ${CLANG_TOOL}") 44 + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) 45 + # LLVM in-tree builds may use CMake target names to discover the tools. 46 + - set(CLANG_TOOL $<TARGET_FILE:clang>) 47 + - set(LINK_TOOL $<TARGET_FILE:llvm-link>) 48 + - set(OPT_TOOL $<TARGET_FILE:opt>) 49 + + set(CLANG_TOOL $<TARGET_FILE:clang> REQUIRED) 50 + + set(LINK_TOOL $<TARGET_FILE:llvm-link> REQUIRED) 51 + + set(OPT_TOOL $<TARGET_FILE:opt> REQUIRED) 52 + libomptarget_say("Building AMDGCN device RTL. Using clang from in-tree build") 53 + else() 54 + libomptarget_say("Not building AMDGCN device RTL. No appropriate clang found")
+89
pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 7f11a05f5622..fb90f8f6a49b 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -8,6 +8,8 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S 6 + set(OPENMP_STANDALONE_BUILD TRUE) 7 + project(openmp C CXX) 8 + 9 + + include(GNUInstallDirs) 10 + + 11 + # CMAKE_BUILD_TYPE was not set, default to Release. 12 + if (NOT CMAKE_BUILD_TYPE) 13 + set(CMAKE_BUILD_TYPE Release) 14 + @@ -19,7 +21,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S 15 + set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING 16 + "Suffix of lib installation directory, e.g. 64 => lib64") 17 + # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. 18 + - set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") 19 + + set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") 20 + 21 + # Group test settings. 22 + set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING 23 + @@ -30,7 +32,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S 24 + else() 25 + set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) 26 + # If building in tree, we honor the same install suffix LLVM uses. 27 + - set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}") 28 + + set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 29 + 30 + if (NOT MSVC) 31 + set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) 32 + index 0e1ce2afd154..8b3810f83713 100644 33 + --- a/libomptarget/plugins/amdgpu/CMakeLists.txt 34 + +++ b/libomptarget/plugins/amdgpu/CMakeLists.txt 35 + @@ -80,7 +80,7 @@ add_library(omptarget.rtl.amdgpu SHARED 36 + 37 + # Install plugin under the lib destination folder. 38 + # When we build for debug, OPENMP_LIBDIR_SUFFIX get set to -debug 39 + -install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "lib${OPENMP_LIBDIR_SUFFIX}") 40 + +install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") 41 + set_property(TARGET omptarget.rtl.amdgpu PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) 42 + 43 + if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 44 + diff --git a/libomptarget/plugins/ve/CMakeLists.txt b/libomptarget/plugins/ve/CMakeLists.txt 45 + index 16ce0891ca23..db30ee9c769f 100644 46 + --- a/libomptarget/plugins/ve/CMakeLists.txt 47 + +++ b/libomptarget/plugins/ve/CMakeLists.txt 48 + @@ -32,7 +32,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND}) 49 + 50 + # Install plugin under the lib destination folder. 51 + install(TARGETS "omptarget.rtl.${tmachine_libname}" 52 + - LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) 53 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}) 54 + 55 + target_link_libraries( 56 + "omptarget.rtl.${tmachine_libname}" 57 + diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt 58 + index e4f4e6e1e73f..1164b3b22b0e 100644 59 + --- a/runtime/src/CMakeLists.txt 60 + +++ b/runtime/src/CMakeLists.txt 61 + @@ -346,13 +346,13 @@ add_dependencies(libomp-micro-tests libomp-test-deps) 62 + # We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib 63 + # We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include 64 + if(${OPENMP_STANDALONE_BUILD}) 65 + - set(LIBOMP_HEADERS_INSTALL_PATH include) 66 + + set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") 67 + else() 68 + string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) 69 + set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") 70 + endif() 71 + if(WIN32) 72 + - install(TARGETS omp RUNTIME DESTINATION bin) 73 + + install(TARGETS omp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 74 + install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") 75 + # Create aliases (regular copies) of the library for backwards compatibility 76 + set(LIBOMP_ALIASES "libiomp5md") 77 + diff --git a/tools/multiplex/CMakeLists.txt b/tools/multiplex/CMakeLists.txt 78 + index 64317c112176..4002784da736 100644 79 + --- a/tools/multiplex/CMakeLists.txt 80 + +++ b/tools/multiplex/CMakeLists.txt 81 + @@ -4,7 +4,7 @@ if(LIBOMP_OMPT_SUPPORT) 82 + add_library(ompt-multiplex INTERFACE) 83 + target_include_directories(ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 84 + 85 + - install(FILES ompt-multiplex.h DESTINATION include) 86 + + install(FILES ompt-multiplex.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 87 + 88 + add_subdirectory(tests) 89 + endif()