llvmPackages_16: init

+2525
+37
pkgs/development/compilers/llvm/16/bintools/default.nix
··· 1 + { lib, runCommand, stdenv, llvm, lld, version }: 2 + 3 + let 4 + prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-"; 5 + in runCommand "llvm-binutils-${version}" { 6 + preferLocalBuild = true; 7 + passthru = { 8 + isLLVM = true; 9 + }; 10 + } '' 11 + mkdir -p $out/bin 12 + for prog in ${lld}/bin/*; do 13 + ln -s $prog $out/bin/${prefix}$(basename $prog) 14 + done 15 + for prog in ${llvm}/bin/*; do 16 + ln -sf $prog $out/bin/${prefix}$(basename $prog) 17 + done 18 + 19 + ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar 20 + ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}dlltool 21 + ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ranlib 22 + ln -s ${llvm}/bin/llvm-cxxfilt $out/bin/${prefix}c++filt 23 + ln -s ${llvm}/bin/llvm-debuginfod $out/bin/${prefix}debuginfod 24 + ln -s ${llvm}/bin/llvm-debuginfod-find $out/bin/${prefix}debuginfod-find 25 + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp 26 + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm 27 + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy 28 + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}strip 29 + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump 30 + ln -s ${llvm}/bin/llvm-rc $out/bin/${prefix}windres 31 + ln -s ${llvm}/bin/llvm-readobj $out/bin/${prefix}readelf 32 + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size 33 + ln -s ${llvm}/bin/llvm-strings $out/bin/${prefix}strings 34 + ln -s ${llvm}/bin/llvm-symbolizer $out/bin/${prefix}addr2line 35 + 36 + ln -s ${lld}/bin/lld $out/bin/${prefix}ld 37 + ''
+128
pkgs/development/compilers/llvm/16/clang/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , monorepoSrc, runCommand 3 + , substituteAll, cmake, ninja, 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 + cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 + ''; 20 + 21 + sourceRoot = "${src.name}/${pname}"; 22 + 23 + nativeBuildInputs = [ cmake ninja python3 ] 24 + ++ lib.optional enableManpages python3.pkgs.sphinx 25 + ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 26 + 27 + buildInputs = [ libxml2 libllvm ]; 28 + 29 + cmakeFlags = [ 30 + "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 31 + "-DCLANGD_BUILD_XPC=OFF" 32 + "-DLLVM_ENABLE_RTTI=ON" 33 + ] ++ lib.optionals enableManpages [ 34 + "-DCLANG_INCLUDE_DOCS=ON" 35 + "-DLLVM_ENABLE_SPHINX=ON" 36 + "-DSPHINX_OUTPUT_MAN=ON" 37 + "-DSPHINX_OUTPUT_HTML=OFF" 38 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 39 + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 40 + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 41 + "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 42 + ]; 43 + 44 + patches = [ 45 + ./purity.patch 46 + # https://reviews.llvm.org/D51899 47 + ./gnu-install-dirs.patch 48 + ../../common/clang/add-nostdlibinc-flag.patch 49 + # FIMXE: do we need this patch? 50 + # (substituteAll { 51 + # src = ../../clang-11-12-LLVMgold-path.patch; 52 + # libllvmLibdir = "${libllvm.lib}/lib"; 53 + # }) 54 + ]; 55 + 56 + postPatch = '' 57 + (cd tools && ln -s ../../clang-tools-extra extra) 58 + '' + lib.optionalString stdenv.hostPlatform.isMusl '' 59 + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 60 + ''; 61 + 62 + outputs = [ "out" "lib" "dev" "python" ]; 63 + 64 + postInstall = '' 65 + ln -sv $out/bin/clang $out/bin/cpp 66 + 67 + # Move libclang to 'lib' output 68 + moveToOutput "lib/libclang.*" "$lib" 69 + moveToOutput "lib/libclang-cpp.*" "$lib" 70 + substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 71 + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 72 + --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 73 + 74 + mkdir -p $python/bin $python/share/clang/ 75 + mv $out/bin/{git-clang-format,scan-view} $python/bin 76 + if [ -e $out/bin/set-xcode-analyzer ]; then 77 + mv $out/bin/set-xcode-analyzer $python/bin 78 + fi 79 + mv $out/share/clang/*.py $python/share/clang 80 + rm $out/bin/c-index-test 81 + patchShebangs $python/bin 82 + 83 + mkdir -p $dev/bin 84 + cp bin/clang-tblgen $dev/bin 85 + ''; 86 + 87 + passthru = { 88 + inherit libllvm; 89 + isClang = true; 90 + hardeningUnsupportedFlags = [ "fortify3" ]; 91 + }; 92 + 93 + meta = llvm_meta // { 94 + homepage = "https://clang.llvm.org/"; 95 + description = "A C language family frontend for LLVM"; 96 + longDescription = '' 97 + The Clang project provides a language front-end and tooling 98 + infrastructure for languages in the C language family (C, C++, Objective 99 + C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 100 + It aims to deliver amazingly fast compiles, extremely useful error and 101 + warning messages and to provide a platform for building great source 102 + level tools. The Clang Static Analyzer and clang-tidy are tools that 103 + automatically find bugs in your code, and are great examples of the sort 104 + of tools that can be built using the Clang frontend as a library to 105 + parse C/C++ code. 106 + ''; 107 + mainProgram = "clang"; 108 + }; 109 + } // lib.optionalAttrs enableManpages { 110 + pname = "clang-manpages"; 111 + 112 + ninjaFlags = [ "docs-clang-man" ]; 113 + 114 + installPhase = '' 115 + mkdir -p $out/share/man/man1 116 + # Manually install clang manpage 117 + cp docs/man/*.1 $out/share/man/man1/ 118 + ''; 119 + 120 + outputs = [ "out" ]; 121 + 122 + doCheck = false; 123 + 124 + meta = llvm_meta // { 125 + description = "man page for Clang ${version}"; 126 + }; 127 + }); 128 + in self
+109
pkgs/development/compilers/llvm/16/clang/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 090cfa352078..624b7c9f3400 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -38,12 +38,26 @@ if(CLANG_BUILT_STANDALONE) 6 + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") 7 + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") 8 + 9 + - # Turn into CACHE PATHs for overwritting 10 + - set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") 11 + - set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") 12 + - set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") 13 + - set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") 14 + - set(LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE PATH "Path to llvm/lib") 15 + + # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets 16 + + # LLVM_CONFIG. 17 + + if (NOT LLVM_CONFIG_FOUND) 18 + + # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config 19 + + # path is removed. 20 + + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) 21 + + set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") 22 + + # N.B. this is just a default value, the CACHE PATHs below can be overriden. 23 + + set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") 24 + + set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") 25 + + set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") 26 + + else() 27 + + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") 28 + + endif() 29 + + 30 + + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") 31 + + set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") 32 + + set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") 33 + + set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") 34 + + set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib") 35 + 36 + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 37 + NO_DEFAULT_PATH) 38 + diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake 39 + index 75b0080f6715..c895b884cd27 100644 40 + --- a/cmake/modules/AddClang.cmake 41 + +++ b/cmake/modules/AddClang.cmake 42 + @@ -119,8 +119,8 @@ macro(add_clang_library name) 43 + install(TARGETS ${lib} 44 + COMPONENT ${lib} 45 + ${export_to_clangtargets} 46 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 47 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 48 + + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 49 + + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 50 + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") 51 + 52 + if (NOT LLVM_ENABLE_IDE) 53 + diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt 54 + index bb9a11eabbef..e2de91c65fbb 100644 55 + --- a/lib/Headers/CMakeLists.txt 56 + +++ b/lib/Headers/CMakeLists.txt 57 + @@ -437,7 +437,7 @@ add_header_target("openmp-resource-headers" ${openmp_wrapper_files}) 58 + add_header_target("windows-resource-headers" ${windows_only_files}) 59 + add_header_target("utility-resource-headers" ${utility_files}) 60 + 61 + -set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include) 62 + +set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include) 63 + 64 + ############################################################# 65 + # Install rules for the catch-all clang-resource-headers target 66 + diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt 67 + index 4f23065a2472..6a0f55991e24 100644 68 + --- a/tools/libclang/CMakeLists.txt 69 + +++ b/tools/libclang/CMakeLists.txt 70 + @@ -234,7 +234,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) 71 + COMPONENT 72 + libclang-python-bindings 73 + DESTINATION 74 + - "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") 75 + + "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") 76 + endforeach() 77 + if(NOT LLVM_ENABLE_IDE) 78 + add_custom_target(libclang-python-bindings) 79 + diff --git a/tools/scan-build-py/CMakeLists.txt b/tools/scan-build-py/CMakeLists.txt 80 + index 3aca22c0b0a8..3115353e3fe3 100644 81 + --- a/tools/scan-build-py/CMakeLists.txt 82 + +++ b/tools/scan-build-py/CMakeLists.txt 83 + @@ -88,7 +88,7 @@ foreach(lib ${LibScanbuild}) 84 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib}) 85 + list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib}) 86 + install(FILES lib/libscanbuild/${lib} 87 + - DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild 88 + + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild" 89 + COMPONENT scan-build-py) 90 + endforeach() 91 + 92 + @@ -106,7 +106,7 @@ foreach(resource ${LibScanbuildResources}) 93 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource}) 94 + list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource}) 95 + install(FILES lib/libscanbuild/resources/${resource} 96 + - DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources 97 + + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild/resources" 98 + COMPONENT scan-build-py) 99 + endforeach() 100 + 101 + @@ -122,7 +122,7 @@ foreach(lib ${LibEar}) 102 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib}) 103 + list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib}) 104 + install(FILES lib/libear/${lib} 105 + - DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear 106 + + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libear" 107 + COMPONENT scan-build-py) 108 + endforeach() 109 +
+29
pkgs/development/compilers/llvm/16/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,13 +487,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, 15 + } else { 16 + if (Args.hasArg(options::OPT_rdynamic)) 17 + CmdArgs.push_back("-export-dynamic"); 18 + 19 + - if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE && 20 + - !Args.hasArg(options::OPT_r)) { 21 + - CmdArgs.push_back("-dynamic-linker"); 22 + - CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) + 23 + - ToolChain.getDynamicLinker(Args))); 24 + - } 25 + } 26 + 27 + CmdArgs.push_back("-o"); 28 + -- 29 + 2.11.0
+21
pkgs/development/compilers/llvm/16/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 + @@ -348,4 +348,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 + @@ -723,6 +723,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)$")
+71
pkgs/development/compilers/llvm/16/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() {
+140
pkgs/development/compilers/llvm/16/compiler-rt/default.nix
··· 1 + { lib, stdenv, llvm_meta, version 2 + , monorepoSrc, runCommand 3 + , cmake, ninja, python3, xcbuild, libllvm, libcxxabi, libxcrypt 4 + , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD 5 + }: 6 + 7 + let 8 + 9 + useLLVM = stdenv.hostPlatform.useLLVM or false; 10 + bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 11 + haveLibc = stdenv.cc.libc != null; 12 + inherit (stdenv.hostPlatform) isMusl isGnu; 13 + 14 + baseName = "compiler-rt"; 15 + 16 + src = runCommand "${baseName}-src-${version}" {} '' 17 + mkdir -p "$out" 18 + cp -r ${monorepoSrc}/cmake "$out" 19 + cp -r ${monorepoSrc}/${baseName} "$out" 20 + ''; 21 + in 22 + 23 + stdenv.mkDerivation { 24 + pname = baseName + lib.optionalString (haveLibc) "-libc"; 25 + inherit version; 26 + 27 + inherit src; 28 + sourceRoot = "${src.name}/${baseName}"; 29 + 30 + nativeBuildInputs = [ cmake ninja python3 libllvm.dev ] 31 + ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 32 + buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 33 + 34 + env.NIX_CFLAGS_COMPILE = toString [ 35 + "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" 36 + ]; 37 + 38 + cmakeFlags = [ 39 + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" 40 + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" 41 + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" 42 + ] ++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [ 43 + "-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include" 44 + ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [ 45 + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" 46 + "-DCOMPILER_RT_BUILD_XRAY=OFF" 47 + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 48 + "-DCOMPILER_RT_BUILD_MEMPROF=OFF" 49 + "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary 50 + ] ++ lib.optionals (useLLVM || bareMetal) [ 51 + "-DCOMPILER_RT_BUILD_PROFILE=OFF" 52 + ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [ 53 + "-DCMAKE_C_COMPILER_WORKS=ON" 54 + "-DCMAKE_CXX_COMPILER_WORKS=ON" 55 + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 56 + "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 57 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 58 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 59 + ] ++ lib.optionals (useLLVM) [ 60 + "-DCOMPILER_RT_BUILD_BUILTINS=ON" 61 + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 62 + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 63 + ] ++ lib.optionals (bareMetal) [ 64 + "-DCOMPILER_RT_OS_DIR=baremetal" 65 + ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ 66 + "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" 67 + "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}" 68 + "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}" 69 + 70 + # `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin: 71 + # https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153 72 + "-DCOMPILER_RT_ENABLE_IOS=OFF" 73 + ]; 74 + 75 + outputs = [ "out" "dev" ]; 76 + 77 + patches = [ 78 + ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config 79 + ./gnu-install-dirs.patch 80 + # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 81 + # extra `/`. 82 + ./normalize-var.patch 83 + # Prevent a compilation error on darwin 84 + ./darwin-targetconditionals.patch 85 + # See: https://github.com/NixOS/nixpkgs/pull/186575 86 + ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 87 + # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 88 + # ../../common/compiler-rt/armv7l-15.patch 89 + ]; 90 + 91 + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 92 + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra 93 + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd 94 + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by 95 + # a flag and turn the flag off during the stdenv build. 96 + postPatch = lib.optionalString (!stdenv.isDarwin) '' 97 + substituteInPlace cmake/builtin-config-ix.cmake \ 98 + --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' 99 + '' + lib.optionalString stdenv.isDarwin '' 100 + substituteInPlace cmake/builtin-config-ix.cmake \ 101 + --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' 102 + substituteInPlace cmake/config-ix.cmake \ 103 + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 104 + '' + lib.optionalString (useLLVM) '' 105 + substituteInPlace lib/builtins/int_util.c \ 106 + --replace "#include <stdlib.h>" "" 107 + substituteInPlace lib/builtins/clear_cache.c \ 108 + --replace "#include <assert.h>" "" 109 + substituteInPlace lib/builtins/cpu_model.c \ 110 + --replace "#include <assert.h>" "" 111 + ''; 112 + 113 + # Hack around weird upsream RPATH bug 114 + postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' 115 + ln -s "$out/lib"/*/* "$out/lib" 116 + '' + lib.optionalString (useLLVM) '' 117 + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o 118 + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o 119 + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 120 + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 121 + '' + lib.optionalString doFakeLibgcc '' 122 + ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a 123 + ''; 124 + 125 + meta = llvm_meta // { 126 + homepage = "https://compiler-rt.llvm.org/"; 127 + description = "Compiler runtime libraries"; 128 + longDescription = '' 129 + The compiler-rt project provides highly tuned implementations of the 130 + low-level code generator support routines like "__fixunsdfdi" and other 131 + calls generated when a target doesn't have a short sequence of native 132 + instructions to implement a core IR operation. It also provides 133 + implementations of run-time libraries for dynamic testing tools such as 134 + AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer. 135 + ''; 136 + # "All of the code in the compiler-rt project is dual licensed under the MIT 137 + # license and the UIUC License (a BSD-like license)": 138 + license = with lib.licenses; [ mit ncsa ]; 139 + }; 140 + }
+20
pkgs/development/compilers/llvm/16/compiler-rt/gnu-install-dirs.patch
··· 1 + diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake 2 + index 8a6219568b3f..30ee68a47ccf 100644 3 + --- a/cmake/base-config-ix.cmake 4 + +++ b/cmake/base-config-ix.cmake 5 + @@ -100,13 +100,13 @@ endif() 6 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 7 + set(COMPILER_RT_OUTPUT_LIBRARY_DIR 8 + ${COMPILER_RT_OUTPUT_DIR}/lib) 9 + - extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib) 10 + + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}") 11 + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH 12 + "Path where built compiler-rt libraries should be installed.") 13 + else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 14 + set(COMPILER_RT_OUTPUT_LIBRARY_DIR 15 + ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) 16 + - extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}") 17 + + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}/${COMPILER_RT_OS_DIR}") 18 + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH 19 + "Path where built compiler-rt libraries should be installed.") 20 + endif()
+16
pkgs/development/compilers/llvm/16/compiler-rt/normalize-var.patch
··· 1 + diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake 2 + index 4c85551d7766..297d7a47c54b 100644 3 + --- a/cmake/Modules/CompilerRTUtils.cmake 4 + +++ b/cmake/Modules/CompilerRTUtils.cmake 5 + @@ -328,8 +328,9 @@ macro(load_llvm_config) 6 + endif() 7 + endif() 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 + 15 + set(LLVM_MAIN_SRC_DIR "${LLVM_MAIN_SRC_DIR_DEFAULT}" CACHE PATH "Path to LLVM source tree") 16 + message(STATUS "LLVM_MAIN_SRC_DIR: \"${LLVM_MAIN_SRC_DIR}\"")
+366
pkgs/development/compilers/llvm/16/default.nix
··· 1 + { lowPrio, newScope, pkgs, lib, stdenv, stdenvNoCC, cmake, ninja 2 + , gccForLibs, preLibcCrossHeaders 3 + , libxml2, python3, 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 + , targetLlvm 7 + # This is the default binutils, but with *this* version of LLD rather 8 + # than the default LLVM verion's, if LLD is the choice. We use these for 9 + # the `useLLVM` bootstrapping below. 10 + , bootBintoolsNoLibc ? 11 + if stdenv.targetPlatform.linker == "lld" 12 + then null 13 + else pkgs.bintoolsNoLibc 14 + , bootBintools ? 15 + if stdenv.targetPlatform.linker == "lld" 16 + then null 17 + else pkgs.bintools 18 + , darwin 19 + # LLVM release information; specify one of these but not both: 20 + , gitRelease ? null 21 + # i.e.: 22 + # { 23 + # version = /* i.e. "15.0.0" */; 24 + # rev = /* commit SHA */; 25 + # rev-version = /* human readable version; i.e. "unstable-2022-26-07" */; 26 + # sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */; 27 + # } 28 + , officialRelease ? { version = "16.0.1"; sha256 = "sha256-Vr978ZY0i0NkdE/uuwcTccshfAT61KIN6KNq0TdwBNE="; } 29 + # i.e.: 30 + # { 31 + # version = /* i.e. "15.0.0" */; 32 + # candidate = /* optional; if specified, should be: "rcN" */ 33 + # sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */; 34 + # } 35 + # By default, we'll try to fetch a release from `github:llvm/llvm-project` 36 + # corresponding to the `gitRelease` or `officialRelease` specified. 37 + # 38 + # You can provide your own LLVM source by specifying this arg but then it's up 39 + # to you to make sure that the LLVM repo given matches the release configuration 40 + # specified. 41 + , monorepoSrc ? null 42 + }: 43 + 44 + assert let 45 + int = a: if a then 1 else 0; 46 + xor = a: b: ((builtins.bitXor (int a) (int b)) == 1); 47 + in 48 + lib.assertMsg 49 + (xor 50 + (gitRelease != null) 51 + (officialRelease != null)) 52 + ("must specify `gitRelease` or `officialRelease`" + 53 + (lib.optionalString (gitRelease != null) " — not both")); 54 + let 55 + monorepoSrc' = monorepoSrc; 56 + in let 57 + releaseInfo = if gitRelease != null then rec { 58 + original = gitRelease; 59 + release_version = original.version; 60 + version = gitRelease.rev-version; 61 + } else rec { 62 + original = officialRelease; 63 + release_version = original.version; 64 + version = if original ? candidate then 65 + "${release_version}-${original.candidate}" 66 + else 67 + release_version; 68 + }; 69 + 70 + monorepoSrc = if monorepoSrc' != null then 71 + monorepoSrc' 72 + else let 73 + sha256 = releaseInfo.original.sha256; 74 + rev = if gitRelease != null then 75 + gitRelease.rev 76 + else 77 + "llvmorg-${releaseInfo.version}"; 78 + in fetchFromGitHub { 79 + owner = "llvm"; 80 + repo = "llvm-project"; 81 + inherit rev sha256; 82 + }; 83 + 84 + inherit (releaseInfo) release_version version; 85 + 86 + llvm_meta = { 87 + license = lib.licenses.ncsa; 88 + maintainers = lib.teams.llvm.members; 89 + 90 + # See llvm/cmake/config-ix.cmake. 91 + platforms = 92 + lib.platforms.aarch64 ++ 93 + lib.platforms.arm ++ 94 + lib.platforms.m68k ++ 95 + lib.platforms.mips ++ 96 + lib.platforms.power ++ 97 + lib.platforms.riscv ++ 98 + lib.platforms.s390x ++ 99 + lib.platforms.wasi ++ 100 + lib.platforms.x86; 101 + }; 102 + 103 + tools = lib.makeExtensible (tools: let 104 + callPackage = newScope (tools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc buildLlvmTools; }); 105 + major = lib.versions.major release_version; 106 + mkExtraBuildCommands0 = cc: '' 107 + rsrc="$out/resource-root" 108 + mkdir "$rsrc" 109 + ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc" 110 + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags 111 + ''; 112 + mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' 113 + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" 114 + ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share" 115 + ''; 116 + 117 + bintoolsNoLibc' = 118 + if bootBintoolsNoLibc == null 119 + then tools.bintoolsNoLibc 120 + else bootBintoolsNoLibc; 121 + bintools' = 122 + if bootBintools == null 123 + then tools.bintools 124 + else bootBintools; 125 + 126 + in { 127 + 128 + libllvm = callPackage ./llvm { 129 + inherit llvm_meta; 130 + }; 131 + 132 + # `llvm` historically had the binaries. When choosing an output explicitly, 133 + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 134 + llvm = tools.libllvm; 135 + 136 + libclang = callPackage ./clang { 137 + inherit llvm_meta; 138 + }; 139 + 140 + clang-unwrapped = tools.libclang; 141 + 142 + llvm-manpages = lowPrio (tools.libllvm.override { 143 + enableManpages = true; 144 + python3 = pkgs.python3; # don't use python-boot 145 + }); 146 + 147 + clang-manpages = lowPrio (tools.libclang.override { 148 + enableManpages = true; 149 + python3 = pkgs.python3; # don't use python-boot 150 + }); 151 + 152 + lldb-manpages = lowPrio (tools.lldb.override { 153 + enableManpages = true; 154 + python3 = pkgs.python3; # don't use python-boot 155 + }); 156 + 157 + # pick clang appropriate for package set we are targeting 158 + clang = 159 + /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM 160 + else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang 161 + else tools.libcxxClang; 162 + 163 + libstdcxxClang = wrapCCWith rec { 164 + cc = tools.clang-unwrapped; 165 + # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper. 166 + libcxx = null; 167 + extraPackages = [ 168 + targetLlvmLibraries.compiler-rt 169 + ]; 170 + extraBuildCommands = mkExtraBuildCommands cc; 171 + }; 172 + 173 + libcxxClang = wrapCCWith rec { 174 + cc = tools.clang-unwrapped; 175 + libcxx = targetLlvmLibraries.libcxx; 176 + extraPackages = [ 177 + libcxx.cxxabi 178 + targetLlvmLibraries.compiler-rt 179 + ]; 180 + extraBuildCommands = mkExtraBuildCommands cc; 181 + }; 182 + 183 + lld = callPackage ./lld { 184 + inherit llvm_meta; 185 + }; 186 + 187 + lldb = callPackage ./lldb { 188 + inherit llvm_meta; 189 + inherit (darwin) libobjc bootstrap_cmds; 190 + inherit (darwin.apple_sdk.libs) xpc; 191 + inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; 192 + }; 193 + 194 + # Below, is the LLVM bootstrapping logic. It handles building a 195 + # fully LLVM toolchain from scratch. No GCC toolchain should be 196 + # pulled in. As a consequence, it is very quick to build different 197 + # targets provided by LLVM and we can also build for what GCC 198 + # doesn’t support like LLVM. Probably we should move to some other 199 + # file. 200 + 201 + bintools-unwrapped = callPackage ./bintools {}; 202 + 203 + bintoolsNoLibc = wrapBintoolsWith { 204 + bintools = tools.bintools-unwrapped; 205 + libc = preLibcCrossHeaders; 206 + }; 207 + 208 + bintools = wrapBintoolsWith { 209 + bintools = tools.bintools-unwrapped; 210 + }; 211 + 212 + clangUseLLVM = wrapCCWith rec { 213 + cc = tools.clang-unwrapped; 214 + libcxx = targetLlvmLibraries.libcxx; 215 + bintools = bintools'; 216 + extraPackages = [ 217 + libcxx.cxxabi 218 + targetLlvmLibraries.compiler-rt 219 + ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ 220 + targetLlvmLibraries.libunwind 221 + ]; 222 + extraBuildCommands = mkExtraBuildCommands cc; 223 + nixSupport.cc-cflags = 224 + [ "-rtlib=compiler-rt" 225 + "-Wno-unused-command-line-argument" 226 + "-B${targetLlvmLibraries.compiler-rt}/lib" 227 + ] 228 + ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" 229 + ++ lib.optional 230 + (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) 231 + "-lunwind" 232 + ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; 233 + }; 234 + 235 + clangNoLibcxx = wrapCCWith rec { 236 + cc = tools.clang-unwrapped; 237 + libcxx = null; 238 + bintools = bintools'; 239 + extraPackages = [ 240 + targetLlvmLibraries.compiler-rt 241 + ]; 242 + extraBuildCommands = mkExtraBuildCommands cc; 243 + nixSupport.cc-cflags = [ 244 + "-rtlib=compiler-rt" 245 + "-B${targetLlvmLibraries.compiler-rt}/lib" 246 + "-nostdlib++" 247 + ]; 248 + }; 249 + 250 + clangNoLibc = wrapCCWith rec { 251 + cc = tools.clang-unwrapped; 252 + libcxx = null; 253 + bintools = bintoolsNoLibc'; 254 + extraPackages = [ 255 + targetLlvmLibraries.compiler-rt 256 + ]; 257 + extraBuildCommands = mkExtraBuildCommands cc; 258 + nixSupport.cc-cflags = [ 259 + "-rtlib=compiler-rt" 260 + "-B${targetLlvmLibraries.compiler-rt}/lib" 261 + ]; 262 + }; 263 + 264 + clangNoCompilerRt = wrapCCWith rec { 265 + cc = tools.clang-unwrapped; 266 + libcxx = null; 267 + bintools = bintoolsNoLibc'; 268 + extraPackages = [ ]; 269 + extraBuildCommands = mkExtraBuildCommands0 cc; 270 + nixSupport.cc-cflags = [ "-nostartfiles" ]; 271 + }; 272 + 273 + clangNoCompilerRtWithLibc = wrapCCWith rec { 274 + cc = tools.clang-unwrapped; 275 + libcxx = null; 276 + bintools = bintools'; 277 + extraPackages = [ ]; 278 + extraBuildCommands = mkExtraBuildCommands0 cc; 279 + }; 280 + 281 + }); 282 + 283 + libraries = lib.makeExtensible (libraries: let 284 + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc; }); 285 + in { 286 + 287 + compiler-rt-libc = callPackage ./compiler-rt { 288 + inherit llvm_meta; 289 + stdenv = if stdenv.hostPlatform.useLLVM or false 290 + then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc 291 + else stdenv; 292 + }; 293 + 294 + compiler-rt-no-libc = callPackage ./compiler-rt { 295 + inherit llvm_meta; 296 + stdenv = if stdenv.hostPlatform.useLLVM or false 297 + then overrideCC stdenv buildLlvmTools.clangNoCompilerRt 298 + else stdenv; 299 + }; 300 + 301 + # N.B. condition is safe because without useLLVM both are the same. 302 + compiler-rt = if stdenv.hostPlatform.isAndroid 303 + then libraries.compiler-rt-libc 304 + else libraries.compiler-rt-no-libc; 305 + 306 + stdenv = overrideCC stdenv buildLlvmTools.clang; 307 + 308 + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; 309 + 310 + libcxxabi = let 311 + # CMake will "require" a compiler capable of compiling C++ programs 312 + # cxx-header's build does not actually use one so it doesn't really matter 313 + # what stdenv we use here, as long as CMake is happy. 314 + cxx-headers = callPackage ./libcxx { 315 + inherit llvm_meta; 316 + # Note that if we use the regular stdenv here we'll get cycle errors 317 + # when attempting to use this compiler in the stdenv. 318 + # 319 + # The final stdenv pulls `cxx-headers` from the package set where 320 + # hostPlatform *is* the target platform which means that `stdenv` at 321 + # that point attempts to use this toolchain. 322 + # 323 + # So, we use `stdenv_` (the stdenv containing `clang` from this package 324 + # set, defined below) to sidestep this issue. 325 + # 326 + # Because we only use `cxx-headers` in `libcxxabi` (which depends on the 327 + # clang stdenv _anyways_), this is okay. 328 + stdenv = stdenv_; 329 + headersOnly = true; 330 + }; 331 + 332 + # `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it 333 + # *does* need a relatively modern C++ compiler (see: 334 + # https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support). 335 + # 336 + # So, we use the clang from this LLVM package set, like libc++ 337 + # "boostrapping builds" do: 338 + # https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build 339 + # 340 + # We cannot use `clangNoLibcxx` because that contains `compiler-rt` which, 341 + # on macOS, depends on `libcxxabi`, thus forming a cycle. 342 + stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc; 343 + in callPackage ./libcxxabi { 344 + stdenv = stdenv_; 345 + inherit llvm_meta cxx-headers; 346 + }; 347 + 348 + # Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler, 349 + # so: we use the clang from this LLVM package set instead of the regular 350 + # stdenv's compiler. 351 + libcxx = callPackage ./libcxx { 352 + inherit llvm_meta; 353 + stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; 354 + }; 355 + 356 + libunwind = callPackage ./libunwind { 357 + inherit llvm_meta; 358 + stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; 359 + }; 360 + 361 + openmp = callPackage ./openmp { 362 + inherit llvm_meta targetLlvm; 363 + }; 364 + }); 365 + 366 + in { inherit tools libraries release_version; } // libraries // tools
+110
pkgs/development/compilers/llvm/16/libcxx/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , monorepoSrc, runCommand 3 + , cmake, ninja, python3, fixDarwinDylibNames, version 4 + , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 5 + , libcxxabi, libcxxrt 6 + , enableShared ? !stdenv.hostPlatform.isStatic 7 + 8 + # If headersOnly is true, the resulting package would only include the headers. 9 + # Use this to break the circular dependency between libcxx and libcxxabi. 10 + # 11 + # Some context: 12 + # https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb 13 + , headersOnly ? false 14 + }: 15 + 16 + let 17 + basename = "libcxx"; 18 + in 19 + 20 + assert stdenv.isDarwin -> cxxabi.libName == "c++abi"; 21 + 22 + stdenv.mkDerivation rec { 23 + pname = basename + lib.optionalString headersOnly "-headers"; 24 + inherit version; 25 + 26 + src = runCommand "${pname}-src-${version}" {} '' 27 + mkdir -p "$out" 28 + cp -r ${monorepoSrc}/cmake "$out" 29 + cp -r ${monorepoSrc}/${basename} "$out" 30 + mkdir -p "$out/libcxxabi" 31 + cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi" 32 + mkdir -p "$out/llvm" 33 + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 34 + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" 35 + cp -r ${monorepoSrc}/third-party "$out" 36 + cp -r ${monorepoSrc}/runtimes "$out" 37 + ''; 38 + 39 + sourceRoot = "${src.name}/runtimes"; 40 + 41 + outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev"; 42 + 43 + prePatch = '' 44 + cd ../${basename} 45 + chmod -R u+w . 46 + ''; 47 + 48 + patches = [ 49 + ./gnu-install-dirs.patch 50 + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 51 + ../../libcxx-0001-musl-hacks.patch 52 + ]; 53 + 54 + postPatch = '' 55 + cd ../runtimes 56 + ''; 57 + 58 + preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' 59 + patchShebangs utils/cat_files.py 60 + ''; 61 + 62 + nativeBuildInputs = [ cmake ninja python3 ] 63 + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 64 + 65 + buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; 66 + 67 + cmakeFlags = let 68 + # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string 69 + libcxx_cxx_abi_opt = { 70 + "c++abi" = "system-libcxxabi"; 71 + "cxxrt" = "libcxxrt"; 72 + }.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})"); 73 + in [ 74 + "-DLLVM_ENABLE_RUNTIMES=libcxx" 75 + "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" 76 + ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" 77 + ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 78 + ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 79 + ++ lib.optionals stdenv.hostPlatform.isWasm [ 80 + "-DLIBCXX_ENABLE_THREADS=OFF" 81 + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 82 + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" 83 + ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" 84 + # If we're only building the headers we don't actually *need* a functioning 85 + # C/C++ compiler: 86 + ++ lib.optionals (headersOnly) [ 87 + "-DCMAKE_C_COMPILER_WORKS=ON" 88 + "-DCMAKE_CXX_COMPILER_WORKS=ON" 89 + ]; 90 + 91 + ninjaFlags = lib.optional headersOnly "generate-cxx-headers"; 92 + installTargets = lib.optional headersOnly "install-cxx-headers"; 93 + 94 + passthru = { 95 + isLLVM = true; 96 + inherit cxxabi; 97 + }; 98 + 99 + meta = llvm_meta // { 100 + homepage = "https://libcxx.llvm.org/"; 101 + description = "C++ standard library"; 102 + longDescription = '' 103 + libc++ is an implementation of the C++ standard library, targeting C++11, 104 + C++14 and above. 105 + ''; 106 + # "All of the code in libc++ is dual licensed under the MIT license and the 107 + # UIUC License (a BSD-like license)": 108 + license = with lib.licenses; [ mit ncsa ]; 109 + }; 110 + }
+22
pkgs/development/compilers/llvm/16/libcxx/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 74eff2002fc9..c935d10878bb 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -419,7 +419,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 6 + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 7 + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 8 + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") 9 + - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 10 + + set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 11 + "Path where built libc++ libraries should be installed.") 12 + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH 13 + "Path where target-specific libc++ headers should be installed.") 14 + @@ -436,7 +436,7 @@ else() 15 + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") 16 + endif() 17 + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") 18 + - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 19 + + set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 20 + "Path where built libc++ libraries should be installed.") 21 + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH 22 + "Path where target-specific libc++ headers should be installed.")
+108
pkgs/development/compilers/llvm/16/libcxxabi/default.nix
··· 1 + { lib, stdenv, llvm_meta, cmake, ninja, python3 2 + , monorepoSrc, runCommand, fetchpatch 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 + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" 22 + cp -r ${monorepoSrc}/runtimes "$out" 23 + ''; 24 + 25 + sourceRoot = "${src.name}/runtimes"; 26 + 27 + outputs = [ "out" "dev" ]; 28 + 29 + postUnpack = lib.optionalString stdenv.isDarwin '' 30 + export TRIPLE=x86_64-apple-darwin 31 + '' + lib.optionalString stdenv.hostPlatform.isWasm '' 32 + patch -p1 -d llvm -i ${./wasm.patch} 33 + ''; 34 + 35 + prePatch = '' 36 + cd ../${pname} 37 + chmod -R u+w . 38 + ''; 39 + 40 + patches = [ 41 + ./gnu-install-dirs.patch 42 + 43 + # https://reviews.llvm.org/D132298, Allow building libcxxabi alone 44 + (fetchpatch { 45 + url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch"; 46 + sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a"; 47 + stripLen = 1; 48 + }) 49 + ]; 50 + 51 + postPatch = '' 52 + cd ../runtimes 53 + ''; 54 + 55 + nativeBuildInputs = [ cmake ninja python3 ]; 56 + buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; 57 + 58 + cmakeFlags = [ 59 + "-DLLVM_ENABLE_RUNTIMES=libcxxabi" 60 + "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" 61 + 62 + # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached 63 + # (we specify the headers it should use explicitly above). 64 + # 65 + # CMake however checks for this anyways; this flag tells it not to. See: 66 + # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243 67 + "-DCMAKE_CXX_COMPILER_WORKS=ON" 68 + ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 69 + "-DLLVM_ENABLE_LIBCXX=ON" 70 + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 71 + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 72 + "-DLIBCXXABI_ENABLE_THREADS=OFF" 73 + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" 74 + ] ++ lib.optionals (!enableShared) [ 75 + "-DLIBCXXABI_ENABLE_SHARED=OFF" 76 + ]; 77 + 78 + preInstall = lib.optionalString stdenv.isDarwin '' 79 + for file in lib/*.dylib; do 80 + # this should be done in CMake, but having trouble figuring out 81 + # the magic combination of necessary CMake variables 82 + # if you fancy a try, take a look at 83 + # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling 84 + install_name_tool -id $out/$file $file 85 + done 86 + ''; 87 + 88 + postInstall = '' 89 + mkdir -p "$dev/include" 90 + install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include" 91 + ''; 92 + 93 + passthru = { 94 + libName = "c++abi"; 95 + }; 96 + 97 + meta = llvm_meta // { 98 + homepage = "https://libcxxabi.llvm.org/"; 99 + description = "Provides C++ standard library support"; 100 + longDescription = '' 101 + libc++abi is a new implementation of low level support for a standard C++ library. 102 + ''; 103 + # "All of the code in libc++abi is dual licensed under the MIT license and 104 + # the UIUC License (a BSD-like license)": 105 + license = with lib.licenses; [ mit ncsa ]; 106 + maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; 107 + }; 108 + }
+22
pkgs/development/compilers/llvm/16/libcxxabi/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index b8326d08d23a..a1e36f713161 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 6 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 7 + set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) 8 + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 9 + - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 10 + + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 11 + "Path where built libc++abi libraries should be installed.") 12 + if(LIBCXX_LIBDIR_SUBDIR) 13 + string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) 14 + @@ -201,7 +201,7 @@ else() 15 + set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) 16 + set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) 17 + endif() 18 + - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 19 + + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH 20 + "Path where built libc++abi libraries should be installed.") 21 + endif() 22 +
+16
pkgs/development/compilers/llvm/16/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 +
+62
pkgs/development/compilers/llvm/16/libunwind/default.nix
··· 1 + { lib, stdenv, llvm_meta, version 2 + , monorepoSrc, runCommand 3 + , cmake 4 + , ninja 5 + , python3 6 + , enableShared ? !stdenv.hostPlatform.isStatic 7 + }: 8 + 9 + stdenv.mkDerivation rec { 10 + pname = "libunwind"; 11 + inherit version; 12 + 13 + # I am not so comfortable giving libc++ and friends the whole monorepo as 14 + # requested, so I filter it to what is needed. 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/libcxx" 20 + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" 21 + cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx" 22 + mkdir -p "$out/llvm" 23 + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 24 + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" 25 + cp -r ${monorepoSrc}/runtimes "$out" 26 + ''; 27 + 28 + sourceRoot = "${src.name}/runtimes"; 29 + 30 + prePatch = '' 31 + cd ../${pname} 32 + chmod -R u+w . 33 + ''; 34 + 35 + patches = [ 36 + ./gnu-install-dirs.patch 37 + ]; 38 + 39 + postPatch = '' 40 + cd ../runtimes 41 + ''; 42 + 43 + outputs = [ "out" "dev" ]; 44 + 45 + nativeBuildInputs = [ cmake ninja python3 ]; 46 + 47 + cmakeFlags = [ 48 + "-DLLVM_ENABLE_RUNTIMES=libunwind" 49 + ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; 50 + 51 + meta = llvm_meta // { 52 + # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst 53 + homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library"; 54 + description = "LLVM's unwinder library"; 55 + longDescription = '' 56 + The unwind library provides a family of _Unwind_* functions implementing 57 + the language-neutral stack unwinding portion of the Itanium C++ ABI (Level 58 + I). It is a dependency of the C++ ABI library, and sometimes is a 59 + dependency of other runtimes. 60 + ''; 61 + }; 62 + }
+22
pkgs/development/compilers/llvm/16/libunwind/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 5a06805f05f1..86a50329e6a8 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -117,7 +117,7 @@ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 6 + 7 + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 8 + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 9 + - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 10 + + set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 11 + "Path where built libunwind libraries should be installed.") 12 + if(LIBCXX_LIBDIR_SUBDIR) 13 + string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) 14 + @@ -129,7 +129,7 @@ else() 15 + else() 16 + set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) 17 + endif() 18 + - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH 19 + + set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH 20 + "Path where built libunwind libraries should be installed.") 21 + endif() 22 +
+57
pkgs/development/compilers/llvm/16/lld/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , buildLlvmTools 3 + , monorepoSrc, runCommand 4 + , cmake 5 + , ninja 6 + , libxml2 7 + , libllvm 8 + , version 9 + }: 10 + 11 + stdenv.mkDerivation rec { 12 + pname = "lld"; 13 + inherit version; 14 + 15 + # Blank llvm dir just so relative path works 16 + src = runCommand "${pname}-src-${version}" {} '' 17 + mkdir -p "$out" 18 + cp -r ${monorepoSrc}/cmake "$out" 19 + cp -r ${monorepoSrc}/${pname} "$out" 20 + mkdir -p "$out/libunwind" 21 + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" 22 + mkdir -p "$out/llvm" 23 + ''; 24 + 25 + sourceRoot = "${src.name}/${pname}"; 26 + 27 + patches = [ 28 + ./gnu-install-dirs.patch 29 + ]; 30 + 31 + nativeBuildInputs = [ cmake ninja ]; 32 + buildInputs = [ libllvm libxml2 ]; 33 + 34 + cmakeFlags = [ 35 + "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" 36 + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 37 + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 38 + ]; 39 + 40 + # Musl's default stack size is too small for lld to be able to link Firefox. 41 + LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; 42 + 43 + outputs = [ "out" "lib" "dev" ]; 44 + 45 + meta = llvm_meta // { 46 + homepage = "https://lld.llvm.org/"; 47 + description = "The LLVM linker (unwrapped)"; 48 + longDescription = '' 49 + LLD is a linker from the LLVM project that is a drop-in replacement for 50 + system linkers and runs much faster than them. It also provides features 51 + that are useful for toolchain developers. 52 + The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and 53 + WebAssembly in descending order of completeness. Internally, LLD consists 54 + of several different linkers. 55 + ''; 56 + }; 57 + }
+46
pkgs/development/compilers/llvm/16/lld/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 3d6225646fe6..9b5d0b15af13 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -33,10 +33,22 @@ if(LLD_BUILT_STANDALONE) 6 + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") 7 + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") 8 + 9 + - # Turn into CACHE PATHs for overwriting 10 + - set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") 11 + - set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") 12 + - set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") 13 + + # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets 14 + + # LLVM_CONFIG. 15 + + if (NOT LLVM_CONFIG_FOUND) 16 + + # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config 17 + + # path is removed. 18 + + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) 19 + + set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") 20 + + # N.B. this is just a default value, the CACHE PATHs below can be overridden. 21 + + set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") 22 + + else() 23 + + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") 24 + + endif() 25 + + 26 + + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") 27 + + set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") 28 + + set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") 29 + 30 + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 31 + NO_DEFAULT_PATH) 32 + diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake 33 + index d3924f7243d4..42a7cd62281c 100644 34 + --- a/cmake/modules/AddLLD.cmake 35 + +++ b/cmake/modules/AddLLD.cmake 36 + @@ -18,8 +18,8 @@ macro(add_lld_library name) 37 + install(TARGETS ${name} 38 + COMPONENT ${name} 39 + ${export_to_lldtargets} 40 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 41 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 42 + + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 43 + + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" 44 + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") 45 + 46 + if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+12
pkgs/development/compilers/llvm/16/lldb/cpu_subtype_arm64e_replacement.patch
··· 1 + diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 2 + --- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm 3 + +++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 4 + @@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, 5 + len = sizeof(is_64_bit_capable); 6 + ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0); 7 + 8 + - if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) { 9 + + if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers 10 + // The arm64e architecture is a preview. Pretend the host architecture 11 + // is arm64. 12 + cpusubtype = CPU_SUBTYPE_ARM64_ALL;
+186
pkgs/development/compilers/llvm/16/lldb/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , runCommand 3 + , monorepoSrc 4 + , cmake 5 + , ninja 6 + , zlib 7 + , ncurses 8 + , swig 9 + , which 10 + , libedit 11 + , libxml2 12 + , libllvm 13 + , libclang 14 + , python3 15 + , version 16 + , libobjc 17 + , xpc 18 + , Foundation 19 + , bootstrap_cmds 20 + , Carbon 21 + , Cocoa 22 + , lit 23 + , makeWrapper 24 + , darwin 25 + , enableManpages ? false 26 + , lua5_3 27 + }: 28 + 29 + # TODO: we build the python bindings but don't expose them as a python package 30 + # TODO: expose the vscode extension? 31 + 32 + stdenv.mkDerivation (rec { 33 + pname = "lldb"; 34 + inherit version; 35 + 36 + src = runCommand "${pname}-src-${version}" {} '' 37 + mkdir -p "$out" 38 + cp -r ${monorepoSrc}/cmake "$out" 39 + cp -r ${monorepoSrc}/${pname} "$out" 40 + ''; 41 + 42 + sourceRoot = "${src.name}/${pname}"; 43 + 44 + patches = [ 45 + # FIXME: do we need this? ./procfs.patch 46 + (runCommand "resource-dir.patch" { 47 + clangLibDir = "${libclang.lib}/lib"; 48 + } '' 49 + substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir 50 + '') 51 + ./gnu-install-dirs.patch 52 + ] 53 + # This is a stopgap solution if/until the macOS SDK used for x86_64 is 54 + # updated. 55 + # 56 + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` 57 + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use 58 + # of this preprocessor symbol in `lldb` with its expansion. 59 + # 60 + # See here for some context: 61 + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 62 + ++ lib.optional ( 63 + stdenv.targetPlatform.isDarwin 64 + && !stdenv.targetPlatform.isAarch64 65 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") 66 + ) ./cpu_subtype_arm64e_replacement.patch; 67 + 68 + outputs = [ "out" "lib" "dev" ]; 69 + 70 + nativeBuildInputs = [ 71 + cmake ninja python3 which swig lit makeWrapper lua5_3 72 + ] ++ lib.optionals enableManpages [ 73 + python3.pkgs.sphinx python3.pkgs.recommonmark 74 + ]; 75 + 76 + buildInputs = [ 77 + ncurses 78 + zlib 79 + libedit 80 + libxml2 81 + libllvm 82 + ] ++ lib.optionals stdenv.isDarwin [ 83 + libobjc 84 + xpc 85 + Foundation 86 + bootstrap_cmds 87 + Carbon 88 + Cocoa 89 + ] 90 + # The older libSystem used on x86_64 macOS is missing the 91 + # `<bsm/audit_session.h>` header which `lldb` uses. 92 + # 93 + # We copy this header over from macOS 10.12 SDK. 94 + # 95 + # See here for context: 96 + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 97 + ++ lib.optional ( 98 + stdenv.targetPlatform.isDarwin 99 + && !stdenv.targetPlatform.isAarch64 100 + ) ( 101 + runCommand "bsm-audit-session-header" { } '' 102 + install -Dm444 \ 103 + "${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \ 104 + "$out/include/bsm/audit_session.h" 105 + '' 106 + ); 107 + 108 + hardeningDisable = [ "format" ]; 109 + 110 + cmakeFlags = [ 111 + "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" 112 + "-DLLVM_ENABLE_RTTI=OFF" 113 + "-DClang_DIR=${libclang.dev}/lib/cmake" 114 + "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" 115 + ] ++ lib.optionals stdenv.isDarwin [ 116 + "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" 117 + ] ++ lib.optionals (!stdenv.isDarwin) [ 118 + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic 119 + ] ++ lib.optionals enableManpages [ 120 + "-DLLVM_ENABLE_SPHINX=ON" 121 + "-DSPHINX_OUTPUT_MAN=ON" 122 + "-DSPHINX_OUTPUT_HTML=OFF" 123 + 124 + # docs reference `automodapi` but it's not added to the extensions list when 125 + # only building the manpages: 126 + # https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54 127 + # 128 + # so, we just ignore the resulting errors 129 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 130 + ] ++ lib.optionals doCheck [ 131 + "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" 132 + "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" 133 + ]; 134 + 135 + doCheck = false; 136 + 137 + installCheckPhase = '' 138 + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then 139 + return 1; 140 + fi 141 + ''; 142 + 143 + postInstall = '' 144 + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ 145 + 146 + # Editor support 147 + # vscode: 148 + install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json 149 + mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin 150 + ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin 151 + ''; 152 + 153 + meta = llvm_meta // { 154 + homepage = "https://lldb.llvm.org/"; 155 + description = "A next-generation high-performance debugger"; 156 + longDescription = '' 157 + LLDB is a next generation, high-performance debugger. It is built as a set 158 + of reusable components which highly leverage existing libraries in the 159 + larger LLVM Project, such as the Clang expression parser and LLVM 160 + disassembler. 161 + ''; 162 + }; 163 + } // lib.optionalAttrs enableManpages { 164 + pname = "lldb-manpages"; 165 + 166 + ninjaFlags = [ "docs-lldb-man" ]; 167 + 168 + propagatedBuildInputs = []; 169 + 170 + # manually install lldb man page 171 + installPhase = '' 172 + mkdir -p $out/share/man/man1 173 + install docs/man/lldb.1 -t $out/share/man/man1/ 174 + ''; 175 + 176 + postPatch = null; 177 + postInstall = null; 178 + 179 + outputs = [ "out" ]; 180 + 181 + doCheck = false; 182 + 183 + meta = llvm_meta // { 184 + description = "man pages for LLDB ${version}"; 185 + }; 186 + })
+23
pkgs/development/compilers/llvm/16/lldb/gnu-install-dirs.patch
··· 1 + diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake 2 + index 3291a7c808e1..b27d27ce6a87 100644 3 + --- a/cmake/modules/AddLLDB.cmake 4 + +++ b/cmake/modules/AddLLDB.cmake 5 + @@ -109,7 +109,7 @@ function(add_lldb_library name) 6 + endif() 7 + 8 + if(PARAM_SHARED) 9 + - set(install_dest lib${LLVM_LIBDIR_SUFFIX}) 10 + + set(install_dest ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 11 + if(PARAM_INSTALL_PREFIX) 12 + set(install_dest ${PARAM_INSTALL_PREFIX}) 13 + endif() 14 + diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt 15 + index 7d48491ec89a..c04543585588 100644 16 + --- a/tools/intel-features/CMakeLists.txt 17 + +++ b/tools/intel-features/CMakeLists.txt 18 + @@ -30,4 +30,4 @@ add_lldb_library(lldbIntelFeatures SHARED 19 + ) 20 + 21 + install(TARGETS lldbIntelFeatures 22 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}) 23 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+46
pkgs/development/compilers/llvm/16/lldb/procfs.patch
··· 1 + --- a/source/Plugins/Process/Linux/Procfs.h 2 + +++ b/source/Plugins/Process/Linux/Procfs.h 3 + @@ -10,6 +10,13 @@ 4 + // sys/procfs.h on Android/Linux for all supported architectures. 5 + 6 + #include <sys/ptrace.h> 7 + +#include <asm/ptrace.h> 8 + + 9 + +// on i686 preprocessor symbols with these register names are defined as 10 + +// numeric constants; these symbols clash with identifier names used in 11 + +// `llvm/Support/VirtualFileSystem.h` and `llvm/ADT/SmallVector.h` 12 + +#undef FS 13 + +#undef CS 14 + 15 + #include "lldb/lldb-types.h" 16 + 17 + @@ -17,23 +24,13 @@ 18 + 19 + #include <vector> 20 + 21 + -#ifdef __ANDROID__ 22 + -#if defined(__arm64__) || defined(__aarch64__) 23 + -typedef unsigned long elf_greg_t; 24 + -typedef elf_greg_t 25 + - elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))]; 26 + -typedef struct user_fpsimd_state elf_fpregset_t; 27 + -#ifndef NT_FPREGSET 28 + -#define NT_FPREGSET NT_PRFPREG 29 + -#endif // NT_FPREGSET 30 + -#elif defined(__mips__) 31 + -#ifndef NT_FPREGSET 32 + -#define NT_FPREGSET NT_PRFPREG 33 + -#endif // NT_FPREGSET 34 + -#endif 35 + -#else // __ANDROID__ 36 + +#if !defined(__GLIBC__) && defined(__powerpc__) 37 + +#define pt_regs musl_pt_regs 38 + +#include <sys/procfs.h> 39 + +#undef pt_regs 40 + +#else 41 + #include <sys/procfs.h> 42 + -#endif // __ANDROID__ 43 + +#endif 44 + 45 + namespace lldb_private { 46 + namespace process_linux {
+14
pkgs/development/compilers/llvm/16/lldb/resource-dir.patch
··· 1 + diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake 2 + index ec06ba285f27..286162f098fb 100644 3 + --- a/cmake/modules/LLDBConfig.cmake 4 + +++ b/cmake/modules/LLDBConfig.cmake 5 + @@ -290,7 +290,8 @@ if (NOT TARGET clang-resource-headers) 6 + # could be and pick the first that exists. 7 + foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}" 8 + "${LLVM_BUILD_LIBRARY_DIR}" 9 + - "${LLVM_LIBRARY_DIR}") 10 + + "${LLVM_LIBRARY_DIR}" 11 + + "@clangLibDir@") 12 + # Build the resource directory path by appending 'clang/<version number>'. 13 + set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}") 14 + if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")
+433
pkgs/development/compilers/llvm/16/llvm/default.nix
··· 1 + { lib, stdenv, llvm_meta 2 + , pkgsBuildBuild 3 + , monorepoSrc 4 + , runCommand 5 + , fetchpatch 6 + , cmake 7 + , darwin 8 + , ninja 9 + , python3 10 + , python3Packages 11 + , libffi 12 + # TODO: Gold plugin on LLVM16 has a severe memory corruption bug: https://github.com/llvm/llvm-project/issues/61350. 13 + , enableGoldPlugin ? false 14 + , libbfd 15 + , libpfm 16 + , libxml2 17 + , ncurses 18 + , version 19 + , release_version 20 + , zlib 21 + , which 22 + , sysctl 23 + , buildLlvmTools 24 + , debugVersion ? false 25 + , doCheck ? (!stdenv.isx86_32 /* TODO: why */) && (!stdenv.hostPlatform.isMusl) 26 + && (stdenv.hostPlatform == stdenv.buildPlatform) 27 + , enableManpages ? false 28 + , enableSharedLibraries ? !stdenv.hostPlatform.isStatic 29 + , enablePFM ? stdenv.isLinux /* PFM only supports Linux */ 30 + # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 31 + # broken for the armv7l builder 32 + && !stdenv.hostPlatform.isAarch 33 + , enablePolly ? true 34 + } @args: 35 + 36 + let 37 + inherit (lib) optional optionals optionalString; 38 + 39 + # Used when creating a version-suffixed symlink of libLLVM.dylib 40 + shortVersion = with lib; 41 + concatStringsSep "." (take 1 (splitString "." release_version)); 42 + 43 + # Ordinarily we would just the `doCheck` and `checkDeps` functionality 44 + # `mkDerivation` gives us to manage our test dependencies (instead of breaking 45 + # out `doCheck` as a package level attribute). 46 + # 47 + # Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in 48 + # particular the children it uses to do feature detection. 49 + # 50 + # This means that python deps we add to `checkDeps` (which the python 51 + # interpreter is made aware of via `$PYTHONPATH` – populated by the python 52 + # setup hook) are not picked up by `lit` which causes it to skip tests. 53 + # 54 + # Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work 55 + # because this package is shadowed in `$PATH` by the regular `python3` 56 + # package. 57 + # 58 + # So, we "manually" assemble one python derivation for the package to depend 59 + # on, taking into account whether checks are enabled or not: 60 + python = if doCheck then 61 + # Note that we _explicitly_ ask for a python interpreter for our host 62 + # platform here; the splicing that would ordinarily take care of this for 63 + # us does not seem to work once we use `withPackages`. 64 + let 65 + checkDeps = ps: with ps; [ psutil ]; 66 + in pkgsBuildBuild.targetPackages.python3.withPackages checkDeps 67 + else python3; 68 + 69 + in 70 + assert (lib.assertMsg (!enableGoldPlugin) "Gold plugin cannot be enabled on LLVM16 due to a upstream issue: https://github.com/llvm/llvm-project/issues/61350"); 71 + stdenv.mkDerivation (rec { 72 + pname = "llvm"; 73 + inherit version; 74 + 75 + src = runCommand "${pname}-src-${version}" {} ('' 76 + mkdir -p "$out" 77 + cp -r ${monorepoSrc}/cmake "$out" 78 + cp -r ${monorepoSrc}/${pname} "$out" 79 + cp -r ${monorepoSrc}/third-party "$out" 80 + '' + lib.optionalString enablePolly '' 81 + chmod u+w "$out/${pname}/tools" 82 + cp -r ${monorepoSrc}/polly "$out/${pname}/tools" 83 + ''); 84 + 85 + sourceRoot = "${src.name}/${pname}"; 86 + 87 + outputs = [ "out" "lib" "dev" "python" ]; 88 + 89 + nativeBuildInputs = [ cmake ninja python ] 90 + ++ optionals enableManpages [ 91 + # Note: we intentionally use `python3Packages` instead of `python3.pkgs`; 92 + # splicing does *not* work with the latter. (TODO: fix) 93 + python3Packages.sphinx python3Packages.recommonmark 94 + ]; 95 + 96 + buildInputs = [ libxml2 libffi ] 97 + ++ optional enablePFM libpfm; # exegesis 98 + 99 + propagatedBuildInputs = [ ncurses zlib ]; 100 + 101 + nativeCheckInputs = [ 102 + which 103 + ] ++ lib.optional stdenv.isDarwin sysctl; 104 + 105 + patches = [ 106 + ./gnu-install-dirs.patch 107 + 108 + # Running the tests involves invoking binaries (like `opt`) that depend on 109 + # the LLVM dylibs and reference them by absolute install path (i.e. their 110 + # nix store path). 111 + # 112 + # Because we have not yet run the install phase (we're running these tests 113 + # as part of `checkPhase` instead of `installCheckPhase`) these absolute 114 + # paths do not exist yet; to work around this we point the loader (`ld` on 115 + # unix, `dyld` on macOS) at the `lib` directory which will later become this 116 + # package's `lib` output. 117 + # 118 + # Previously we would just set `LD_LIBRARY_PATH` to include the build `lib` 119 + # dir but: 120 + # - this doesn't generalize well to other platforms; `lit` doesn't forward 121 + # `DYLD_LIBRARY_PATH` (macOS): 122 + # + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26 123 + # - even if `lit` forwarded this env var, we actually cannot set 124 + # `DYLD_LIBRARY_PATH` in the child processes `lit` launches because 125 + # `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for 126 + # "protected processes" (i.e. the python interpreter that runs `lit`): 127 + # https://stackoverflow.com/a/35570229 128 + # - other LLVM subprojects deal with this issue by having their `lit` 129 + # configuration set these env vars for us; it makes sense to do the same 130 + # for LLVM: 131 + # + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31 132 + # 133 + # !!! TODO: look into upstreaming this patch 134 + ./llvm-lit-cfg-add-libs-to-dylib-path.patch 135 + 136 + # `lit` has a mode where it executes run lines as a shell script which is 137 + # constructs; this is problematic for macOS because it means that there's 138 + # another process in between `lit` and the binaries being tested. As noted 139 + # above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our 140 + # tests fail with dyld errors. 141 + # 142 + # To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when 143 + # present in the test configuration. 144 + # 145 + # It's not clear to me why this isn't an issue for LLVM developers running 146 + # on macOS (nothing about this _seems_ nix specific).. 147 + ./lit-shell-script-runner-set-dyld-library-path.patch 148 + ] ++ lib.optionals enablePolly [ 149 + ./gnu-install-dirs-polly.patch 150 + 151 + # Just like the `llvm-lit-cfg` patch, but for `polly`. 152 + ./polly-lit-cfg-add-libs-to-dylib-path.patch 153 + ]; 154 + 155 + postPatch = optionalString stdenv.isDarwin '' 156 + substituteInPlace cmake/modules/AddLLVM.cmake \ 157 + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ 158 + --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" 159 + 160 + # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick 161 + # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7 162 + rm test/MC/ELF/cfi-version.ll 163 + 164 + # This test tries to call `sw_vers` by absolute path (`/usr/bin/sw_vers`) 165 + # and thus fails under the sandbox: 166 + substituteInPlace unittests/Support/Host.cpp \ 167 + --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" 168 + '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) '' 169 + # This test tries to call the intrinsics `@llvm.roundeven.f32` and 170 + # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf` 171 + # and `roundeven` on x86_64 macOS. 172 + # 173 + # However these functions are glibc specific so the test fails: 174 + # - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html 175 + # - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html 176 + # 177 + # TODO(@rrbutani): this seems to run fine on `aarch64-darwin`, why does it 178 + # pass there? 179 + substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ 180 + --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ 181 + --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" 182 + 183 + # This test fails on darwin x86_64 because `sw_vers` reports a different 184 + # macOS version than what LLVM finds by reading 185 + # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into 186 + # the sandbox on macOS). 187 + # 188 + # The `sw_vers` provided by nixpkgs reports the macOS version associated 189 + # with the `CoreFoundation` framework with which it was built. Because 190 + # nixpkgs pins the SDK for `aarch64-darwin` and `x86_64-darwin` what 191 + # `sw_vers` reports is not guaranteed to match the macOS version of the host 192 + # that's building this derivation. 193 + # 194 + # Astute readers will note that we only _patch_ this test on aarch64-darwin 195 + # (to use the nixpkgs provided `sw_vers`) instead of disabling it outright. 196 + # So why does this test pass on aarch64? 197 + # 198 + # Well, it seems that `sw_vers` on aarch64 actually links against the _host_ 199 + # CoreFoundation framework instead of the nixpkgs provided one. 200 + # 201 + # Not entirely sure what the right fix is here. I'm assuming aarch64 202 + # `sw_vers` doesn't intentionally link against the host `CoreFoundation` 203 + # (still digging into how this ends up happening, will follow up) but that 204 + # aside I think the more pertinent question is: should we be patching LLVM's 205 + # macOS version detection logic to use `sw_vers` instead of reading host 206 + # paths? This *is* a way in which details about builder machines can creep 207 + # into the artifacts that are produced, affecting reproducibility, but it's 208 + # not clear to me when/where/for what this even gets used in LLVM. 209 + # 210 + # TODO(@rrbutani): fix/follow-up 211 + substituteInPlace unittests/Support/Host.cpp \ 212 + --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" 213 + 214 + # This test fails with a `dysmutil` crash; have not yet dug into what's 215 + # going on here (TODO(@rrbutani)). 216 + rm test/tools/dsymutil/ARM/obfuscated.test 217 + '' + '' 218 + # FileSystem permissions tests fail with various special bits 219 + substituteInPlace unittests/Support/CMakeLists.txt \ 220 + --replace "Path.cpp" "" 221 + rm unittests/Support/Path.cpp 222 + substituteInPlace unittests/IR/CMakeLists.txt \ 223 + --replace "PassBuilderCallbacksTest.cpp" "" 224 + rm unittests/IR/PassBuilderCallbacksTest.cpp 225 + rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test 226 + '' + optionalString stdenv.hostPlatform.isMusl '' 227 + patch -p1 -i ${../../TLI-musl.patch} 228 + substituteInPlace unittests/Support/CMakeLists.txt \ 229 + --replace "add_subdirectory(DynamicLibrary)" "" 230 + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp 231 + # valgrind unhappy with musl or glibc, but fails w/musl only 232 + rm test/CodeGen/AArch64/wineh4.mir 233 + '' + optionalString stdenv.hostPlatform.isAarch32 '' 234 + # skip failing X86 test cases on 32-bit ARM 235 + rm test/DebugInfo/X86/convert-debugloc.ll 236 + rm test/DebugInfo/X86/convert-inlined.ll 237 + rm test/DebugInfo/X86/convert-linked.ll 238 + rm test/tools/dsymutil/X86/op-convert.test 239 + rm test/tools/gold/X86/split-dwarf.ll 240 + rm test/tools/llvm-dwarfdump/X86/prettyprint_types.s 241 + rm test/tools/llvm-dwarfdump/X86/simplified-template-names.s 242 + 243 + # !!! Note: these tests are removed in LLVM 16. 244 + # 245 + # See here for context: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999790443 246 + rm test/CodeGen/RISCV/rv32zbp.ll 247 + rm test/CodeGen/RISCV/rv64zbp.ll 248 + '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' 249 + # Seems to require certain floating point hardware (NEON?) 250 + rm test/ExecutionEngine/frem.ll 251 + '' + '' 252 + patchShebangs test/BugPoint/compile-custom.ll.py 253 + ''; 254 + 255 + preConfigure = '' 256 + # Workaround for configure flags that need to have spaces 257 + cmakeFlagsArray+=( 258 + -DLLVM_LIT_ARGS="-svj''${NIX_BUILD_CORES} --no-progress-bar" 259 + ) 260 + ''; 261 + 262 + # Defensive check: some paths (that we make symlinks to) depend on the release 263 + # version, for example: 264 + # - https://github.com/llvm/llvm-project/blob/406bde9a15136254f2b10d9ef3a42033b3cb1b16/clang/lib/Headers/CMakeLists.txt#L185 265 + # 266 + # So we want to sure that the version in the source matches the release 267 + # version we were given. 268 + # 269 + # We do this check here, in the LLVM build, because it happens early. 270 + postConfigure = let 271 + v = lib.versions; 272 + major = v.major release_version; 273 + minor = v.minor release_version; 274 + patch = v.patch release_version; 275 + in '' 276 + # $1: part, $2: expected 277 + check_version() { 278 + part="''${1^^}" 279 + part="$(cat include/llvm/Config/llvm-config.h | grep "#define LLVM_VERSION_''${part} " | cut -d' ' -f3)" 280 + 281 + if [[ "$part" != "$2" ]]; then 282 + echo >&2 \ 283 + "mismatch in the $1 version! we have version ${release_version}" \ 284 + "and expected the $1 version to be '$2'; the source has '$part' instead" 285 + exit 3 286 + fi 287 + } 288 + 289 + check_version major ${major} 290 + check_version minor ${minor} 291 + check_version patch ${patch} 292 + ''; 293 + 294 + # E.g. mesa.drivers use the build-id as a cache key (see #93946): 295 + LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; 296 + 297 + cmakeFlags = with stdenv; let 298 + # These flags influence llvm-config's BuildVariables.inc in addition to the 299 + # general build. We need to make sure these are also passed via 300 + # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native 301 + # will return different results from the cross llvm-config. 302 + # 303 + # Some flags don't need to be repassed because LLVM already does so (like 304 + # CMAKE_BUILD_TYPE), others are irrelevant to the result. 305 + flagsForLlvmConfig = [ 306 + "-DLLVM_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/llvm" 307 + "-DLLVM_ENABLE_RTTI=ON" 308 + ] ++ optionals enableSharedLibraries [ 309 + "-DLLVM_LINK_LLVM_DYLIB=ON" 310 + ]; 311 + in flagsForLlvmConfig ++ [ 312 + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" 313 + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc 314 + "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" 315 + "-DLLVM_ENABLE_FFI=ON" 316 + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" 317 + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" 318 + "-DLLVM_ENABLE_DUMP=ON" 319 + ] ++ optionals stdenv.hostPlatform.isStatic [ 320 + # Disables building of shared libs, -fPIC is still injected by cc-wrapper 321 + "-DLLVM_ENABLE_PIC=OFF" 322 + "-DLLVM_BUILD_STATIC=ON" 323 + "-DLLVM_LINK_LLVM_DYLIB=off" 324 + # libxml2 needs to be disabled because the LLVM build system ignores its .la 325 + # file and doesn't link zlib as well. 326 + # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812 327 + "-DLLVM_ENABLE_LIBXML2=OFF" 328 + ] ++ optionals enableManpages [ 329 + "-DLLVM_BUILD_DOCS=ON" 330 + "-DLLVM_ENABLE_SPHINX=ON" 331 + "-DSPHINX_OUTPUT_MAN=ON" 332 + "-DSPHINX_OUTPUT_HTML=OFF" 333 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 334 + ] ++ optionals (false) [ 335 + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" 336 + ] ++ optionals isDarwin [ 337 + "-DLLVM_ENABLE_LIBCXX=ON" 338 + "-DCAN_TARGET_i386=false" 339 + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 340 + "-DCMAKE_CROSSCOMPILING=True" 341 + "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen" 342 + ( 343 + let 344 + nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc; 345 + nativeBintools = nativeCC.bintools.bintools; 346 + nativeToolchainFlags = [ 347 + "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc" 348 + "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++" 349 + "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar" 350 + "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" 351 + "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" 352 + ]; 353 + # We need to repass the custom GNUInstallDirs values, otherwise CMake 354 + # will choose them for us, leading to wrong results in llvm-config-native 355 + nativeInstallFlags = [ 356 + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" 357 + "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin" 358 + "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include" 359 + "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib" 360 + "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec" 361 + ]; 362 + in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=" 363 + + lib.concatStringsSep ";" (lib.concatLists [ 364 + flagsForLlvmConfig 365 + nativeToolchainFlags 366 + nativeInstallFlags 367 + ]) 368 + ) 369 + ]; 370 + 371 + postInstall = '' 372 + mkdir -p $python/share 373 + mv $out/share/opt-viewer $python/share/opt-viewer 374 + moveToOutput "bin/llvm-config*" "$dev" 375 + substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ 376 + --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \ 377 + --replace "$out/bin/llvm-config" "$dev/bin/llvm-config" 378 + substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ 379 + --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")' 380 + '' 381 + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' 382 + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib 383 + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib 384 + '' 385 + + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' 386 + cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native 387 + ''; 388 + 389 + inherit doCheck; 390 + 391 + checkTarget = "check-all"; 392 + 393 + # For the update script: 394 + passthru.monorepoSrc = monorepoSrc; 395 + 396 + requiredSystemFeatures = [ "big-parallel" ]; 397 + meta = llvm_meta // { 398 + homepage = "https://llvm.org/"; 399 + description = "A collection of modular and reusable compiler and toolchain technologies"; 400 + longDescription = '' 401 + The LLVM Project is a collection of modular and reusable compiler and 402 + toolchain technologies. Despite its name, LLVM has little to do with 403 + traditional virtual machines. The name "LLVM" itself is not an acronym; it 404 + is the full name of the project. 405 + LLVM began as a research project at the University of Illinois, with the 406 + goal of providing a modern, SSA-based compilation strategy capable of 407 + supporting both static and dynamic compilation of arbitrary programming 408 + languages. Since then, LLVM has grown to be an umbrella project consisting 409 + of a number of subprojects, many of which are being used in production by 410 + a wide variety of commercial and open source projects as well as being 411 + widely used in academic research. Code in the LLVM project is licensed 412 + under the "Apache 2.0 License with LLVM exceptions". 413 + ''; 414 + }; 415 + } // lib.optionalAttrs enableManpages { 416 + pname = "llvm-manpages"; 417 + 418 + propagatedBuildInputs = []; 419 + 420 + ninjaFlags = [ "docs-llvm-man" ]; 421 + installTargets = [ "install-docs-llvm-man" ]; 422 + 423 + postPatch = null; 424 + postInstall = null; 425 + 426 + outputs = [ "out" ]; 427 + 428 + doCheck = false; 429 + 430 + meta = llvm_meta // { 431 + description = "man pages for LLVM ${version}"; 432 + }; 433 + })
+19
pkgs/development/compilers/llvm/16/llvm/gnu-install-dirs-polly.patch
··· 1 + This is the one remaining Polly install dirs related change that hasn't made it 2 + into upstream yet; previously this patch file also included: 3 + https://reviews.llvm.org/D117541 4 + 5 + diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake 6 + index 518a09b45a42..bd9d6f5542ad 100644 7 + --- a/tools/polly/cmake/polly_macros.cmake 8 + +++ b/tools/polly/cmake/polly_macros.cmake 9 + @@ -44,8 +44,8 @@ macro(add_polly_library name) 10 + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly") 11 + install(TARGETS ${name} 12 + EXPORT LLVMExports 13 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 14 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) 15 + + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} 16 + + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 17 + endif() 18 + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) 19 + endmacro(add_polly_library)
+138
pkgs/development/compilers/llvm/16/llvm/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 45399dc0537e..5d946e9e6583 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -942,7 +942,7 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "") 6 + add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src 7 + ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime) 8 + install(TARGETS tf_xla_runtime EXPORT LLVMExports 9 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime) 10 + + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime) 11 + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime) 12 + # Once we add more modules, we should handle this more automatically. 13 + if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL) 14 + diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake 15 + index 057431208322..56f0dcb258da 100644 16 + --- a/cmake/modules/AddLLVM.cmake 17 + +++ b/cmake/modules/AddLLVM.cmake 18 + @@ -844,8 +844,8 @@ macro(add_llvm_library name) 19 + get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) 20 + install(TARGETS ${name} 21 + ${export_to_llvmexports} 22 + - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} 23 + - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} 24 + + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} 25 + + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} 26 + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) 27 + 28 + if (NOT LLVM_ENABLE_IDE) 29 + @@ -2007,7 +2007,7 @@ function(llvm_install_library_symlink name dest type) 30 + set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX}) 31 + set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}) 32 + 33 + - set(output_dir lib${LLVM_LIBDIR_SUFFIX}) 34 + + set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) 35 + if(WIN32 AND "${type}" STREQUAL "SHARED") 36 + set(output_dir "${CMAKE_INSTALL_BINDIR}") 37 + endif() 38 + @@ -2271,15 +2271,15 @@ function(llvm_setup_rpath name) 39 + 40 + if (APPLE) 41 + set(_install_name_dir INSTALL_NAME_DIR "@rpath") 42 + - set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 43 + + set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 44 + elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS) 45 + # $ORIGIN is not interpreted at link time by aix ld. 46 + # Since BUILD_SHARED_LIBS is only recommended for use by developers, 47 + # hardcode the rpath to build/install lib dir first in this mode. 48 + # FIXME: update this when there is better solution. 49 + - set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 50 + + set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 51 + elseif(UNIX) 52 + - set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 53 + + set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 54 + if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") 55 + set_property(TARGET ${name} APPEND_STRING PROPERTY 56 + LINK_FLAGS " -Wl,-z,origin ") 57 + diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake 58 + index 891c9e6d618c..8d963f3b0069 100644 59 + --- a/cmake/modules/AddOCaml.cmake 60 + +++ b/cmake/modules/AddOCaml.cmake 61 + @@ -147,9 +147,9 @@ function(add_ocaml_library name) 62 + endforeach() 63 + 64 + if( APPLE ) 65 + - set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}") 66 + + set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 67 + elseif( UNIX ) 68 + - set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}") 69 + + set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 70 + endif() 71 + list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}") 72 + 73 + diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt 74 + index d4b0ab959148..26ed981fd09f 100644 75 + --- a/cmake/modules/CMakeLists.txt 76 + +++ b/cmake/modules/CMakeLists.txt 77 + @@ -128,7 +128,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS 78 + ) 79 + list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) 80 + 81 + -extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "lib\${LLVM_LIBDIR_SUFFIX}") 82 + +extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}") 83 + set(LLVM_CONFIG_LIBRARY_DIRS 84 + "${LLVM_CONFIG_LIBRARY_DIR}" 85 + # FIXME: Should there be other entries here? 86 + diff --git a/docs/CMake.rst b/docs/CMake.rst 87 + index 879b7b231d4c..9c31d14e8950 100644 88 + --- a/docs/CMake.rst 89 + +++ b/docs/CMake.rst 90 + @@ -250,7 +250,7 @@ description is in `LLVM-related variables`_ below. 91 + **LLVM_LIBDIR_SUFFIX**:STRING 92 + Extra suffix to append to the directory where libraries are to be 93 + installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` 94 + - to install libraries to ``/usr/lib64``. 95 + + to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``. 96 + 97 + **LLVM_PARALLEL_{COMPILE,LINK}_JOBS**:STRING 98 + Building the llvm toolchain can use a lot of resources, particularly 99 + @@ -284,6 +284,10 @@ manual, or execute ``cmake --help-variable VARIABLE_NAME``. 100 + The path to install executables, relative to the *CMAKE_INSTALL_PREFIX*. 101 + Defaults to "bin". 102 + 103 + +**CMAKE_INSTALL_LIBDIR**:PATH 104 + + The path to install libraries, relative to the *CMAKE_INSTALL_PREFIX*. 105 + + Defaults to "lib". 106 + + 107 + **CMAKE_INSTALL_INCLUDEDIR**:PATH 108 + The path to install header files, relative to the *CMAKE_INSTALL_PREFIX*. 109 + Defaults to "include". 110 + diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in 111 + index 370005cd8d7d..7e790bc52111 100644 112 + --- a/tools/llvm-config/BuildVariables.inc.in 113 + +++ b/tools/llvm-config/BuildVariables.inc.in 114 + @@ -23,6 +23,7 @@ 115 + #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@" 116 + #define LLVM_BUILDMODE "@LLVM_BUILDMODE@" 117 + #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@" 118 + +#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@" 119 + #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@" 120 + #define LLVM_INSTALL_PACKAGE_DIR "@LLVM_INSTALL_PACKAGE_DIR@" 121 + #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@" 122 + diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp 123 + index 2c6c55f89d38..f6d2068a0827 100644 124 + --- a/tools/llvm-config/llvm-config.cpp 125 + +++ b/tools/llvm-config/llvm-config.cpp 126 + @@ -369,7 +369,11 @@ int main(int argc, char **argv) { 127 + sys::fs::make_absolute(ActivePrefix, Path); 128 + ActiveBinDir = std::string(Path.str()); 129 + } 130 + - ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; 131 + + { 132 + + SmallString<256> Path(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX); 133 + + sys::fs::make_absolute(ActivePrefix, Path); 134 + + ActiveLibDir = std::string(Path.str()); 135 + + } 136 + { 137 + SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR); 138 + sys::fs::make_absolute(ActivePrefix, Path);
+17
pkgs/development/compilers/llvm/16/llvm/lit-shell-script-runner-set-dyld-library-path.patch
··· 1 + diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py 2 + index 0242e0b75af3..d732011306f7 100644 3 + --- a/utils/lit/lit/TestRunner.py 4 + +++ b/utils/lit/lit/TestRunner.py 5 + @@ -1029,6 +1029,12 @@ def executeScript(test, litConfig, tmpBase, commands, cwd): 6 + f.write('@echo off\n') 7 + f.write('\n@if %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands)) 8 + else: 9 + + # This env var is *purged* when invoking subprocesses so we have to 10 + + # manually set it from within the bash script in order for the commands 11 + + # in run lines to see this var: 12 + + if "DYLD_LIBRARY_PATH" in test.config.environment: 13 + + f.write(f'export DYLD_LIBRARY_PATH="{test.config.environment["DYLD_LIBRARY_PATH"]}"\n') 14 + + 15 + for i, ln in enumerate(commands): 16 + match = re.match(kPdbgRegex, ln) 17 + if match:
+79
pkgs/development/compilers/llvm/16/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
··· 1 + diff --git a/test/Unit/lit.cfg.py b/test/Unit/lit.cfg.py 2 + index 81e8dc04acea..479ff95681e2 100644 3 + --- a/test/Unit/lit.cfg.py 4 + +++ b/test/Unit/lit.cfg.py 5 + @@ -3,6 +3,7 @@ 6 + # Configuration file for the 'lit' test runner. 7 + 8 + import os 9 + +import platform 10 + import subprocess 11 + 12 + import lit.formats 13 + @@ -55,3 +56,26 @@ if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir): 14 + # Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate. 15 + if sys.platform == 'win32' and 'SYSTEMDRIVE' in os.environ: 16 + config.environment['SYSTEMDRIVE'] = os.environ['SYSTEMDRIVE'] 17 + + 18 + +# Add the LLVM dynamic libs to the platform-specific loader search path env var: 19 + +# 20 + +# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. 21 + +def find_shlibpath_var(): 22 + + if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: 23 + + yield 'LD_LIBRARY_PATH' 24 + + elif platform.system() == 'Darwin': 25 + + yield 'DYLD_LIBRARY_PATH' 26 + + elif platform.system() == 'Windows': 27 + + yield 'PATH' 28 + + elif platform.system() == 'AIX': 29 + + yield 'LIBPATH' 30 + + 31 + +for shlibpath_var in find_shlibpath_var(): 32 + + shlibpath = os.path.pathsep.join( 33 + + (config.shlibdir, 34 + + config.environment.get(shlibpath_var, ''))) 35 + + config.environment[shlibpath_var] = shlibpath 36 + + break 37 + +else: 38 + + lit_config.warning("unable to inject shared library path on '{}'" 39 + + .format(platform.system())) 40 + diff --git a/test/lit.cfg.py b/test/lit.cfg.py 41 + index 75a38b4c5dad..856fc75c9d74 100644 42 + --- a/test/lit.cfg.py 43 + +++ b/test/lit.cfg.py 44 + @@ -42,6 +42,26 @@ llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) 45 + llvm_config.with_system_environment( 46 + ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) 47 + 48 + +# Add the LLVM dynamic libs to the platform-specific loader search path env var: 49 + +# 50 + +# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. 51 + +def find_shlibpath_var(): 52 + + if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: 53 + + yield 'LD_LIBRARY_PATH' 54 + + elif platform.system() == 'Darwin': 55 + + yield 'DYLD_LIBRARY_PATH' 56 + + elif platform.system() == 'Windows': 57 + + yield 'PATH' 58 + + elif platform.system() == 'AIX': 59 + + yield 'LIBPATH' 60 + + 61 + +for shlibpath_var in find_shlibpath_var(): 62 + + shlibpath = config.llvm_shlib_dir 63 + + llvm_config.with_environment(shlibpath_var, shlibpath, append_path = True) 64 + + break 65 + +else: 66 + + lit_config.warning("unable to inject shared library path on '{}'" 67 + + .format(platform.system())) 68 + 69 + # Set up OCAMLPATH to include newly built OCaml libraries. 70 + top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml') 71 + @@ -318,7 +338,7 @@ def have_cxx_shared_library(): 72 + 73 + try: 74 + readobj_cmd = subprocess.Popen( 75 + - [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE) 76 + + [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE, env=config.environment) 77 + except OSError: 78 + print('could not exec llvm-readobj') 79 + return False
+24
pkgs/development/compilers/llvm/16/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
··· 1 + diff --git a/tools/polly/test/lit.cfg b/tools/polly/test/lit.cfg 2 + index 41e3a589c61e..09f3b17498b0 100644 3 + --- a/tools/polly/test/lit.cfg 4 + +++ b/tools/polly/test/lit.cfg 5 + @@ -36,9 +36,17 @@ base_paths = [config.llvm_tools_dir, config.environment['PATH']] 6 + path = os.path.pathsep.join(base_paths + config.extra_paths) 7 + config.environment['PATH'] = path 8 + 9 + +# (Copied from polly/test/Unit/lit.cfg) 10 + +if platform.system() == 'Darwin': 11 + + shlibpath_var = 'DYLD_LIBRARY_PATH' 12 + +elif platform.system() == 'Windows': 13 + + shlibpath_var = 'PATH' 14 + +else: 15 + + shlibpath_var = 'LD_LIBRARY_PATH' 16 + + 17 + path = os.path.pathsep.join((config.llvm_libs_dir, 18 + - config.environment.get('LD_LIBRARY_PATH',''))) 19 + -config.environment['LD_LIBRARY_PATH'] = path 20 + + config.environment.get(shlibpath_var,''))) 21 + +config.environment[shlibpath_var] = path 22 + 23 + llvm_config.use_default_substitutions() 24 +
+74
pkgs/development/compilers/llvm/16/openmp/default.nix
··· 1 + { lib 2 + , stdenv 3 + , llvm_meta 4 + , monorepoSrc 5 + , runCommand 6 + , cmake 7 + , ninja 8 + , llvm 9 + , targetLlvm 10 + , lit 11 + , clang-unwrapped 12 + , perl 13 + , pkg-config 14 + , xcbuild 15 + , version 16 + }: 17 + 18 + stdenv.mkDerivation rec { 19 + pname = "openmp"; 20 + inherit version; 21 + 22 + src = runCommand "${pname}-src-${version}" {} '' 23 + mkdir -p "$out" 24 + cp -r ${monorepoSrc}/cmake "$out" 25 + cp -r ${monorepoSrc}/${pname} "$out" 26 + ''; 27 + 28 + sourceRoot = "${src.name}/${pname}"; 29 + 30 + patches = [ 31 + ./fix-find-tool.patch 32 + ./gnu-install-dirs.patch 33 + ./run-lit-directly.patch 34 + ]; 35 + 36 + outputs = [ "out" "dev" ]; 37 + 38 + nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; 39 + buildInputs = [ 40 + (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) 41 + ]; 42 + 43 + nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; 44 + 45 + # Unsup:Pass:XFail:Fail 46 + # 26:267:16:8 47 + doCheck = false; 48 + checkTarget = "check-openmp"; 49 + 50 + preCheck = '' 51 + patchShebangs ../tools/archer/tests/deflake.bash 52 + ''; 53 + 54 + cmakeFlags = [ 55 + "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" 56 + "-DOPT_TOOL=${llvm}/bin/opt" 57 + "-DLINK_TOOL=${llvm}/bin/llvm-link" 58 + ]; 59 + 60 + meta = llvm_meta // { 61 + homepage = "https://openmp.llvm.org/"; 62 + description = "Support for the OpenMP language"; 63 + longDescription = '' 64 + The OpenMP subproject of LLVM contains the components required to build an 65 + executable OpenMP program that are outside the compiler itself. 66 + Contains the code for the runtime library against which code compiled by 67 + "clang -fopenmp" must be linked before it can run and the library that 68 + supports offload to target devices. 69 + ''; 70 + # "All of the code is dual licensed under the MIT license and the UIUC 71 + # License (a BSD-like license)": 72 + license = with lib.licenses; [ mit ncsa ]; 73 + }; 74 + }
+21
pkgs/development/compilers/llvm/16/openmp/fix-find-tool.patch
··· 1 + diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt 2 + index 49b398c9f765..6f1dd1340010 100644 3 + --- a/libomptarget/DeviceRTL/CMakeLists.txt 4 + +++ b/libomptarget/DeviceRTL/CMakeLists.txt 5 + @@ -27,11 +27,11 @@ endif() 6 + if (LLVM_DIR) 7 + # Builds that use pre-installed LLVM have LLVM_DIR set. 8 + # A standalone or LLVM_ENABLE_RUNTIMES=openmp build takes this route 9 + - find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 10 + - find_program(PACKAGER_TOOL clang-offload-packager PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 11 + - find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 12 + - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 13 + - find_program(EXTRACT_TOOL llvm-extract PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) 14 + + find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR}) 15 + + find_program(PACKAGER_TOOL clang-offload-packager PATHS ${LLVM_TOOLS_BINARY_DIR}) 16 + + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR}) 17 + + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR}) 18 + + find_program(EXTRACT_TOOL llvm-extract PATHS ${LLVM_TOOLS_BINARY_DIR}) 19 + if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL) OR (NOT EXTRACT_TOOL) OR (NOT PACKAGER_TOOL)) 20 + libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL}, opt: ${OPT_TOOL}, llvm-extract: ${EXTRACT_TOOL}, or clang-offload-packager: ${PACKAGER_TOOL}") 21 + return()
+22
pkgs/development/compilers/llvm/16/openmp/gnu-install-dirs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index b6ddbe90516d..311ab1d50e7f 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -29,7 +29,7 @@ if (OPENMP_STANDALONE_BUILD) 6 + set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING 7 + "Suffix of lib installation directory, e.g. 64 => lib64") 8 + # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. 9 + - set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") 10 + + set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") 11 + 12 + # Group test settings. 13 + set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING 14 + @@ -40,7 +40,7 @@ if (OPENMP_STANDALONE_BUILD) 15 + else() 16 + set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) 17 + # If building in tree, we honor the same install suffix LLVM uses. 18 + - set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}") 19 + + set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") 20 + 21 + if (NOT MSVC) 22 + set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
pkgs/development/compilers/llvm/16/openmp/run-lit-directly.patch

This is a binary file and will not be displayed.

+15
pkgs/top-level/all-packages.nix
··· 14393 14393 clang_13 = llvmPackages_13.clang; 14394 14394 clang_14 = llvmPackages_14.clang; 14395 14395 clang_15 = llvmPackages_15.clang; 14396 + clang_16 = llvmPackages_15.clang; 14396 14397 14397 14398 clang-tools = callPackage ../development/tools/clang-tools { 14398 14399 llvmPackages = llvmPackages_latest; ··· 14440 14441 14441 14442 clang-tools_15 = callPackage ../development/tools/clang-tools { 14442 14443 llvmPackages = llvmPackages_15; 14444 + }; 14445 + 14446 + clang-tools_16 = callPackage ../development/tools/clang-tools { 14447 + llvmPackages = llvmPackages_16; 14443 14448 }; 14444 14449 14445 14450 clang-analyzer = callPackage ../development/tools/analysis/clang-analyzer { ··· 15387 15392 lld_13 = llvmPackages_13.lld; 15388 15393 lld_14 = llvmPackages_14.lld; 15389 15394 lld_15 = llvmPackages_15.lld; 15395 + lld_16 = llvmPackages_16.lld; 15390 15396 15391 15397 lldb = llvmPackages_latest.lldb; 15392 15398 lldb_5 = llvmPackages_5.lldb; ··· 15400 15406 lldb_13 = llvmPackages_13.lldb; 15401 15407 lldb_14 = llvmPackages_14.lldb; 15402 15408 lldb_15 = llvmPackages_15.lldb; 15409 + lldb_16 = llvmPackages_16.lldb; 15403 15410 15404 15411 llvm = llvmPackages.llvm; 15405 15412 llvm_5 = llvmPackages_5.llvm; ··· 15413 15420 llvm_13 = llvmPackages_13.llvm; 15414 15421 llvm_14 = llvmPackages_14.llvm; 15415 15422 llvm_15 = llvmPackages_15.llvm; 15423 + llvm_16 = llvmPackages_16.llvm; 15416 15424 15417 15425 libllvm = llvmPackages.libllvm; 15418 15426 llvm-manpages = llvmPackages.llvm-manpages; ··· 15511 15519 buildLlvmTools = buildPackages.llvmPackages_15.tools; 15512 15520 targetLlvmLibraries = targetPackages.llvmPackages_15.libraries or llvmPackages_15.libraries; 15513 15521 targetLlvm = targetPackages.llvmPackages_15.llvm or llvmPackages_15.llvm; 15522 + })); 15523 + 15524 + llvmPackages_16 = recurseIntoAttrs (callPackage ../development/compilers/llvm/16 ({ 15525 + inherit (stdenvAdapters) overrideCC; 15526 + buildLlvmTools = buildPackages.llvmPackages_16.tools; 15527 + targetLlvmLibraries = targetPackages.llvmPackages_16.libraries or llvmPackages_16.libraries; 15528 + targetLlvm = targetPackages.llvmPackages_16.llvm or llvmPackages_16.llvm; 15514 15529 })); 15515 15530 15516 15531 llvmPackages_latest = llvmPackages_14;