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