1 |
commit: 48b08d607267d78c51fe94926abf2fde35a6f4d7 |
2 |
Author: Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Aug 4 09:12:03 2022 +0000 |
4 |
Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 7 08:40:42 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=48b08d60 |
7 |
|
8 |
dev-python/llvmlite: add 0.39.0 |
9 |
|
10 |
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com> |
11 |
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org> |
12 |
|
13 |
.../llvmlite/files/llvmlite-0.39.0-llvm12.patch | 97 ++++++++++++++++++++++ |
14 |
dev-python/llvmlite/llvmlite-0.39.0.ebuild | 62 ++++++++++++++ |
15 |
2 files changed, 159 insertions(+) |
16 |
|
17 |
diff --git a/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch b/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch |
18 |
new file mode 100644 |
19 |
index 000000000..17eb80e87 |
20 |
--- /dev/null |
21 |
+++ b/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch |
22 |
@@ -0,0 +1,97 @@ |
23 |
+From 1d928ebcd59b23b5050234a2bf71f9be7f5f6bd1 Mon Sep 17 00:00:00 2001 |
24 |
+From: Richard Barnes <rbarnes@×××.edu> |
25 |
+Date: Wed, 1 Dec 2021 10:29:08 -0700 |
26 |
+Subject: [PATCH] Enable LLVM-12 and LLVM-13 |
27 |
+ |
28 |
+--- |
29 |
+ ffi/build.py | 5 ++--- |
30 |
+ ffi/targets.cpp | 2 ++ |
31 |
+ llvmlite/tests/test_binding.py | 19 ++++++++++++++++--- |
32 |
+ 3 files changed, 20 insertions(+), 6 deletions(-) |
33 |
+ |
34 |
+Index: llvmlite-0.39.0/ffi/build.py |
35 |
+=================================================================== |
36 |
+--- llvmlite-0.39.0.orig/ffi/build.py |
37 |
++++ llvmlite-0.39.0/ffi/build.py |
38 |
+@@ -163,9 +163,8 @@ def main_posix(kind, library_ext): |
39 |
+ print(msg) |
40 |
+ print(warning + '\n') |
41 |
+ else: |
42 |
+- |
43 |
+- if not out.startswith('11'): |
44 |
+- msg = ("Building llvmlite requires LLVM 11.x.x, got " |
45 |
++ if not (out.startswith('11') or out.startswith('12') or out.startswith('13')): |
46 |
++ msg = ("Building llvmlite requires LLVM 11-13.x.x, got " |
47 |
+ "{!r}. Be sure to set LLVM_CONFIG to the right executable " |
48 |
+ "path.\nRead the documentation at " |
49 |
+ "http://llvmlite.pydata.org/ for more information about " |
50 |
+Index: llvmlite-0.39.0/ffi/targets.cpp |
51 |
+=================================================================== |
52 |
+--- llvmlite-0.39.0.orig/ffi/targets.cpp |
53 |
++++ llvmlite-0.39.0/ffi/targets.cpp |
54 |
+@@ -204,7 +204,9 @@ LLVMPY_CreateTargetMachine(LLVMTargetRef |
55 |
+ rm = Reloc::DynamicNoPIC; |
56 |
+ |
57 |
+ TargetOptions opt; |
58 |
++#if LLVM_VERSION_MAJOR < 12 |
59 |
+ opt.PrintMachineCode = PrintMC; |
60 |
++#endif |
61 |
+ opt.MCOptions.ABIName = ABIName; |
62 |
+ |
63 |
+ bool jit = JIT; |
64 |
+Index: llvmlite-0.39.0/llvmlite/tests/test_binding.py |
65 |
+=================================================================== |
66 |
+--- llvmlite-0.39.0.orig/llvmlite/tests/test_binding.py |
67 |
++++ llvmlite-0.39.0/llvmlite/tests/test_binding.py |
68 |
+@@ -18,6 +18,16 @@ from llvmlite.binding import ffi |
69 |
+ from llvmlite.tests import TestCase |
70 |
+ |
71 |
+ |
72 |
++def clean_string_whitespace(x: str) -> str: |
73 |
++ # Remove trailing whitespace from the end of each line |
74 |
++ x = re.sub(r"\s+$", "", x, flags=re.MULTILINE) |
75 |
++ # Remove intermediate blank lines |
76 |
++ x = re.sub(r"\n\s*\n", r"\n", x, flags=re.MULTILINE) |
77 |
++ # Remove extraneous whitespace from the beginning and end of the string |
78 |
++ x = x.strip() |
79 |
++ return x |
80 |
++ |
81 |
++ |
82 |
+ # arvm7l needs extra ABI symbols to link successfully |
83 |
+ if platform.machine() == 'armv7l': |
84 |
+ llvm.load_library_permanently('libgcc_s.so.1') |
85 |
+@@ -555,7 +565,10 @@ class TestMisc(BaseTest): |
86 |
+ bd = ir.IRBuilder(fn.append_basic_block(name="<>!*''#")) |
87 |
+ bd.ret(ir.Constant(ir.IntType(32), 12345)) |
88 |
+ asm = str(mod) |
89 |
+- self.assertEqual(asm, asm_nonalphanum_blocklabel) |
90 |
++ self.assertEqual( |
91 |
++ clean_string_whitespace(asm), |
92 |
++ clean_string_whitespace(asm_nonalphanum_blocklabel) |
93 |
++ ) |
94 |
+ |
95 |
+ def test_global_context(self): |
96 |
+ gcontext1 = llvm.context.get_global_context() |
97 |
+@@ -640,7 +653,7 @@ class TestMisc(BaseTest): |
98 |
+ def test_version(self): |
99 |
+ major, minor, patch = llvm.llvm_version_info |
100 |
+ # one of these can be valid |
101 |
+- valid = [(11,)] |
102 |
++ valid = [(11,), (12,), (13,)] |
103 |
+ self.assertIn((major,), valid) |
104 |
+ self.assertIn(patch, range(10)) |
105 |
+ |
106 |
+Index: llvmlite-0.39.0/ffi/passmanagers.cpp |
107 |
+=================================================================== |
108 |
+--- llvmlite-0.39.0.orig/ffi/passmanagers.cpp |
109 |
++++ llvmlite-0.39.0/ffi/passmanagers.cpp |
110 |
+@@ -17,9 +17,6 @@ |
111 |
+ #include "llvm-c/Transforms/IPO.h" |
112 |
+ #include "llvm-c/Transforms/Scalar.h" |
113 |
+ #include "llvm/IR/LegacyPassManager.h" |
114 |
+-#if LLVM_VERSION_MAJOR > 11 |
115 |
+-#include "llvm/IR/RemarkStreamer.h" |
116 |
+-#endif |
117 |
+ #include "llvm/IR/LLVMRemarkStreamer.h" |
118 |
+ #include "llvm/Remarks/RemarkStreamer.h" |
119 |
+ #include "llvm/Transforms/IPO.h" |
120 |
|
121 |
diff --git a/dev-python/llvmlite/llvmlite-0.39.0.ebuild b/dev-python/llvmlite/llvmlite-0.39.0.ebuild |
122 |
new file mode 100644 |
123 |
index 000000000..a2c3a6750 |
124 |
--- /dev/null |
125 |
+++ b/dev-python/llvmlite/llvmlite-0.39.0.ebuild |
126 |
@@ -0,0 +1,62 @@ |
127 |
+# Copyright 1999-2022 Gentoo Authors |
128 |
+# Distributed under the terms of the GNU General Public License v2 |
129 |
+ |
130 |
+EAPI=8 |
131 |
+ |
132 |
+PYTHON_COMPAT=( python3_{8..10} ) |
133 |
+inherit distutils-r1 llvm |
134 |
+ |
135 |
+DESCRIPTION="Python wrapper around the llvm C++ library" |
136 |
+HOMEPAGE="https://llvmlite.pydata.org/" |
137 |
+SRC_URI="https://github.com/numba/llvmlite/archive/v${PV/_/}.tar.gz -> ${P/_/}.gh.tar.gz" |
138 |
+S="${WORKDIR}/${P/_/}" |
139 |
+ |
140 |
+LICENSE="BSD" |
141 |
+SLOT="0" |
142 |
+KEYWORDS="~amd64 ~arm ~arm64 ~x86" |
143 |
+IUSE="examples" |
144 |
+ |
145 |
+LLVM_MAX_SLOT=13 |
146 |
+ |
147 |
+RDEPEND=" |
148 |
+ sys-devel/llvm:${LLVM_MAX_SLOT} |
149 |
+ sys-libs/zlib:0= |
150 |
+" |
151 |
+DEPEND="${RDEPEND}" |
152 |
+ |
153 |
+PATCHES=( "${FILESDIR}/${P}-llvm12.patch" ) |
154 |
+ |
155 |
+src_prepare() { |
156 |
+ sed -i -e '/max_python/s:3\.10:3.11:' setup.py || die |
157 |
+ distutils-r1_src_prepare |
158 |
+} |
159 |
+ |
160 |
+python_configure_all() { |
161 |
+ # upstream's build system is just horrible, and they ignored the PR |
162 |
+ # fixing it, so let's build the shared lib properly using implicit |
163 |
+ # make rules |
164 |
+ |
165 |
+ export LDLIBS=$(llvm-config --libs all) |
166 |
+ export CXXFLAGS="$(llvm-config --cxxflags) -fPIC ${CXXFLAGS}" |
167 |
+ export LDFLAGS="$(llvm-config --ldflags) ${LDFLAGS}" |
168 |
+ |
169 |
+ local files=( ffi/*.cpp ) |
170 |
+ emake -f - <<EOF |
171 |
+ffi/libllvmlite.so: ${files[*]/.cpp/.o} |
172 |
+ \$(CXX) -shared \$(CXXFLAGS) \$(LDFLAGS) -o \$@ \$^ \$(LDLIBS) |
173 |
+EOF |
174 |
+ |
175 |
+ export LLVMLITE_SKIP_LLVM_VERSION_CHECK=1 |
176 |
+} |
177 |
+ |
178 |
+python_test() { |
179 |
+ "${EPYTHON}" runtests.py -v || die "Tests failed under ${EPYTHON}" |
180 |
+} |
181 |
+ |
182 |
+python_install_all() { |
183 |
+ distutils-r1_python_install_all |
184 |
+ if use examples; then |
185 |
+ dodoc -r examples |
186 |
+ docompress -x /usr/share/doc/${PF}/examples |
187 |
+ fi |
188 |
+} |