Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 141 lines 4.2 kB view raw
1{ 2 lib, 3 stdenv, 4 llvm_meta, 5 release_version, 6 monorepoSrc ? null, 7 src ? null, 8 runCommand, 9 cmake, 10 ninja, 11 llvm, 12 targetLlvm, 13 lit, 14 clang-unwrapped, 15 perl, 16 pkg-config, 17 python3, 18 version, 19 devExtraCmakeFlags ? [ ], 20 ompdSupport ? true, 21 ompdGdbSupport ? ompdSupport, 22 getVersionFile, 23 fetchpatch, 24}: 25 26assert lib.assertMsg (ompdGdbSupport -> ompdSupport) "OMPD GDB support requires OMPD support!"; 27 28stdenv.mkDerivation ( 29 finalAttrs: 30 { 31 pname = "openmp"; 32 inherit version; 33 34 src = 35 if monorepoSrc != null then 36 runCommand "openmp-src-${version}" { inherit (monorepoSrc) passthru; } ( 37 '' 38 mkdir -p "$out" 39 '' 40 + lib.optionalString (lib.versionAtLeast release_version "14") '' 41 cp -r ${monorepoSrc}/cmake "$out" 42 '' 43 + '' 44 cp -r ${monorepoSrc}/openmp "$out" 45 '' 46 ) 47 else 48 src; 49 50 sourceRoot = "${finalAttrs.src.name}/openmp"; 51 52 outputs = [ "out" ] ++ lib.optionals (lib.versionAtLeast release_version "14") [ "dev" ]; 53 54 patchFlags = if lib.versionOlder release_version "14" then [ "-p2" ] else null; 55 56 patches = 57 lib.optional (lib.versionAtLeast release_version "15" && lib.versionOlder release_version "19") ( 58 getVersionFile "openmp/fix-find-tool.patch" 59 ) 60 ++ lib.optional (lib.versionAtLeast release_version "14" && lib.versionOlder release_version "18") ( 61 getVersionFile "openmp/gnu-install-dirs.patch" 62 ) 63 ++ lib.optional (lib.versionAtLeast release_version "14") ( 64 getVersionFile "openmp/run-lit-directly.patch" 65 ) 66 ++ 67 lib.optional (lib.versionOlder release_version "14") 68 # Fix cross. 69 ( 70 fetchpatch { 71 url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch"; 72 hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A="; 73 } 74 ); 75 76 nativeBuildInputs = 77 [ 78 cmake 79 python3.pythonOnBuildForHost 80 perl 81 ] 82 ++ lib.optionals (lib.versionAtLeast release_version "15") [ 83 ninja 84 ] 85 ++ lib.optionals (lib.versionAtLeast release_version "14") [ 86 pkg-config 87 lit 88 ]; 89 90 buildInputs = 91 [ 92 (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) 93 ] 94 ++ lib.optionals (ompdSupport && ompdGdbSupport) [ 95 python3 96 ]; 97 98 cmakeFlags = 99 [ 100 (lib.cmakeBool "LIBOMP_ENABLE_SHARED" ( 101 !stdenv.hostPlatform.isStatic && stdenv.hostPlatform.hasSharedLibraries 102 )) 103 (lib.cmakeBool "LIBOMP_OMPD_SUPPORT" ompdSupport) 104 (lib.cmakeBool "LIBOMP_OMPD_GDB_SUPPORT" ompdGdbSupport) 105 ] 106 ++ lib.optionals (lib.versions.major release_version == "13") [ 107 (lib.cmakeBool "LIBOMPTARGET_BUILD_AMDGCN_BCLIB" false) # Building the AMDGCN device RTL fails 108 ] 109 ++ lib.optionals (lib.versionAtLeast release_version "14") [ 110 (lib.cmakeFeature "CLANG_TOOL" "${clang-unwrapped}/bin/clang") 111 (lib.cmakeFeature "OPT_TOOL" "${llvm}/bin/opt") 112 (lib.cmakeFeature "LINK_TOOL" "${llvm}/bin/llvm-link") 113 ] 114 ++ devExtraCmakeFlags; 115 116 meta = llvm_meta // { 117 homepage = "https://openmp.llvm.org/"; 118 description = "Support for the OpenMP language"; 119 longDescription = '' 120 The OpenMP subproject of LLVM contains the components required to build an 121 executable OpenMP program that are outside the compiler itself. 122 Contains the code for the runtime library against which code compiled by 123 "clang -fopenmp" must be linked before it can run and the library that 124 supports offload to target devices. 125 ''; 126 # "All of the code is dual licensed under the MIT license and the UIUC 127 # License (a BSD-like license)": 128 license = with lib.licenses; [ 129 mit 130 ncsa 131 ]; 132 }; 133 } 134 // (lib.optionalAttrs (lib.versionAtLeast release_version "14") { 135 doCheck = false; 136 checkTarget = "check-openmp"; 137 preCheck = '' 138 patchShebangs ../tools/archer/tests/deflake.bash 139 ''; 140 }) 141)