nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 102 lines 3.1 kB view raw
1{ 2 lib, 3 stdenv, 4 llvm_meta, 5 release_version, 6 buildLlvmPackages, 7 monorepoSrc, 8 runCommand, 9 cmake, 10 ninja, 11 libxml2, 12 libllvm, 13 version, 14 devExtraCmakeFlags ? [ ], 15 getVersionFile, 16}: 17 18stdenv.mkDerivation (finalAttrs: { 19 pname = "mlir"; 20 inherit version; 21 22 doCheck = 23 ( 24 !stdenv.hostPlatform.isx86_32 # TODO: why 25 ) 26 && (!stdenv.hostPlatform.isMusl); 27 28 # Blank llvm dir just so relative path works 29 src = runCommand "${finalAttrs.pname}-src-${version}" { inherit (monorepoSrc) passthru; } '' 30 mkdir -p "$out" 31 cp -r ${monorepoSrc}/cmake "$out" 32 cp -r ${monorepoSrc}/mlir "$out" 33 cp -r ${monorepoSrc}/third-party "$out/third-party" 34 35 mkdir -p "$out/llvm" 36 ''; 37 38 sourceRoot = "${finalAttrs.src.name}/mlir"; 39 40 patches = [ 41 ./gnu-install-dirs.patch 42 ] 43 ++ lib.optional (lib.versionOlder release_version "20") [ 44 # Fix build with gcc15 45 # https://github.com/llvm/llvm-project/commit/41eb186fbb024898bacc2577fa3b88db0510ba1f 46 # https://github.com/llvm/llvm-project/commit/101109fc5460d5bb9bb597c6ec77f998093a6687 47 (getVersionFile "mlir/mlir-add-include-cstdint.patch") 48 ]; 49 50 nativeBuildInputs = [ 51 cmake 52 ninja 53 ]; 54 55 buildInputs = [ 56 libllvm 57 libxml2 58 ]; 59 60 cmakeFlags = [ 61 (lib.cmakeBool "LLVM_BUILD_TOOLS" true) 62 # Install headers as well 63 (lib.cmakeBool "LLVM_INSTALL_TOOLCHAIN_ONLY" false) 64 (lib.cmakeFeature "MLIR_TOOLS_INSTALL_DIR" "${placeholder "out"}/bin/") 65 (lib.cmakeBool "LLVM_ENABLE_IDE" false) 66 (lib.cmakeFeature "MLIR_INSTALL_PACKAGE_DIR" "${placeholder "dev"}/lib/cmake/mlir") 67 (lib.cmakeFeature "MLIR_INSTALL_CMAKE_DIR" "${placeholder "dev"}/lib/cmake/mlir") 68 (lib.cmakeBool "LLVM_BUILD_TESTS" finalAttrs.finalPackage.doCheck) 69 (lib.cmakeBool "LLVM_ENABLE_FFI" true) 70 (lib.cmakeFeature "LLVM_HOST_TRIPLE" stdenv.hostPlatform.config) 71 (lib.cmakeFeature "LLVM_DEFAULT_TARGET_TRIPLE" stdenv.hostPlatform.config) 72 (lib.cmakeBool "LLVM_ENABLE_DUMP" true) 73 (lib.cmakeFeature "LLVM_TABLEGEN_EXE" "${buildLlvmPackages.tblgen}/bin/llvm-tblgen") 74 (lib.cmakeFeature "MLIR_TABLEGEN_EXE" "${buildLlvmPackages.tblgen}/bin/mlir-tblgen") 75 (lib.cmakeBool "LLVM_BUILD_LLVM_DYLIB" (!stdenv.hostPlatform.isStatic)) 76 ] 77 ++ lib.optionals stdenv.hostPlatform.isStatic [ 78 # Disables building of shared libs, -fPIC is still injected by cc-wrapper 79 (lib.cmakeBool "LLVM_ENABLE_PIC" false) 80 (lib.cmakeBool "LLVM_BUILD_STATIC" true) 81 (lib.cmakeBool "LLVM_LINK_LLVM_DYLIB" false) 82 ] 83 ++ devExtraCmakeFlags; 84 85 outputs = [ 86 "out" 87 "dev" 88 ]; 89 90 requiredSystemFeatures = [ "big-parallel" ]; 91 meta = llvm_meta // { 92 homepage = "https://mlir.llvm.org/"; 93 description = "Multi-Level IR Compiler Framework"; 94 longDescription = '' 95 The MLIR project is a novel approach to building reusable and extensible 96 compiler infrastructure. MLIR aims to address software fragmentation, 97 improve compilation for heterogeneous hardware, significantly reduce 98 the cost of building domain specific compilers, and aid in connecting 99 existing compilers together. 100 ''; 101 }; 102})