commit:     48b08d607267d78c51fe94926abf2fde35a6f4d7
Author:     Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
AuthorDate: Thu Aug  4 09:12:03 2022 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Sun Aug  7 08:40:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=48b08d60

dev-python/llvmlite: add 0.39.0

Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../llvmlite/files/llvmlite-0.39.0-llvm12.patch    | 97 ++++++++++++++++++++++
 dev-python/llvmlite/llvmlite-0.39.0.ebuild         | 62 ++++++++++++++
 2 files changed, 159 insertions(+)

diff --git a/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch 
b/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch
new file mode 100644
index 000000000..17eb80e87
--- /dev/null
+++ b/dev-python/llvmlite/files/llvmlite-0.39.0-llvm12.patch
@@ -0,0 +1,97 @@
+From 1d928ebcd59b23b5050234a2bf71f9be7f5f6bd1 Mon Sep 17 00:00:00 2001
+From: Richard Barnes <[email protected]>
+Date: Wed, 1 Dec 2021 10:29:08 -0700
+Subject: [PATCH] Enable LLVM-12 and LLVM-13
+
+---
+ ffi/build.py                   |  5 ++---
+ ffi/targets.cpp                |  2 ++
+ llvmlite/tests/test_binding.py | 19 ++++++++++++++++---
+ 3 files changed, 20 insertions(+), 6 deletions(-)
+
+Index: llvmlite-0.39.0/ffi/build.py
+===================================================================
+--- llvmlite-0.39.0.orig/ffi/build.py
++++ llvmlite-0.39.0/ffi/build.py
+@@ -163,9 +163,8 @@ def main_posix(kind, library_ext):
+         print(msg)
+         print(warning + '\n')
+     else:
+-
+-        if not out.startswith('11'):
+-            msg = ("Building llvmlite requires LLVM 11.x.x, got "
++        if not (out.startswith('11') or out.startswith('12') or 
out.startswith('13')):
++            msg = ("Building llvmlite requires LLVM 11-13.x.x, got "
+                    "{!r}. Be sure to set LLVM_CONFIG to the right executable "
+                    "path.\nRead the documentation at "
+                    "http://llvmlite.pydata.org/ for more information about "
+Index: llvmlite-0.39.0/ffi/targets.cpp
+===================================================================
+--- llvmlite-0.39.0.orig/ffi/targets.cpp
++++ llvmlite-0.39.0/ffi/targets.cpp
+@@ -204,7 +204,9 @@ LLVMPY_CreateTargetMachine(LLVMTargetRef
+         rm = Reloc::DynamicNoPIC;
+ 
+     TargetOptions opt;
++#if LLVM_VERSION_MAJOR < 12
+     opt.PrintMachineCode = PrintMC;
++#endif
+     opt.MCOptions.ABIName = ABIName;
+ 
+     bool jit = JIT;
+Index: llvmlite-0.39.0/llvmlite/tests/test_binding.py
+===================================================================
+--- llvmlite-0.39.0.orig/llvmlite/tests/test_binding.py
++++ llvmlite-0.39.0/llvmlite/tests/test_binding.py
+@@ -18,6 +18,16 @@ from llvmlite.binding import ffi
+ from llvmlite.tests import TestCase
+ 
+ 
++def clean_string_whitespace(x: str) -> str:
++    # Remove trailing whitespace from the end of each line
++    x = re.sub(r"\s+$", "", x, flags=re.MULTILINE)
++    # Remove intermediate blank lines
++    x = re.sub(r"\n\s*\n", r"\n", x, flags=re.MULTILINE)
++    # Remove extraneous whitespace from the beginning and end of the string
++    x = x.strip()
++    return x
++
++
+ # arvm7l needs extra ABI symbols to link successfully
+ if platform.machine() == 'armv7l':
+     llvm.load_library_permanently('libgcc_s.so.1')
+@@ -555,7 +565,10 @@ class TestMisc(BaseTest):
+         bd = ir.IRBuilder(fn.append_basic_block(name="<>!*''#"))
+         bd.ret(ir.Constant(ir.IntType(32), 12345))
+         asm = str(mod)
+-        self.assertEqual(asm, asm_nonalphanum_blocklabel)
++        self.assertEqual(
++            clean_string_whitespace(asm),
++            clean_string_whitespace(asm_nonalphanum_blocklabel)
++        )
+ 
+     def test_global_context(self):
+         gcontext1 = llvm.context.get_global_context()
+@@ -640,7 +653,7 @@ class TestMisc(BaseTest):
+     def test_version(self):
+         major, minor, patch = llvm.llvm_version_info
+         # one of these can be valid
+-        valid = [(11,)]
++        valid = [(11,), (12,), (13,)]
+         self.assertIn((major,), valid)
+         self.assertIn(patch, range(10))
+ 
+Index: llvmlite-0.39.0/ffi/passmanagers.cpp
+===================================================================
+--- llvmlite-0.39.0.orig/ffi/passmanagers.cpp
++++ llvmlite-0.39.0/ffi/passmanagers.cpp
+@@ -17,9 +17,6 @@
+ #include "llvm-c/Transforms/IPO.h"
+ #include "llvm-c/Transforms/Scalar.h"
+ #include "llvm/IR/LegacyPassManager.h"
+-#if LLVM_VERSION_MAJOR > 11
+-#include "llvm/IR/RemarkStreamer.h"
+-#endif
+ #include "llvm/IR/LLVMRemarkStreamer.h"
+ #include "llvm/Remarks/RemarkStreamer.h"
+ #include "llvm/Transforms/IPO.h"

diff --git a/dev-python/llvmlite/llvmlite-0.39.0.ebuild 
b/dev-python/llvmlite/llvmlite-0.39.0.ebuild
new file mode 100644
index 000000000..a2c3a6750
--- /dev/null
+++ b/dev-python/llvmlite/llvmlite-0.39.0.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit distutils-r1 llvm
+
+DESCRIPTION="Python wrapper around the llvm C++ library"
+HOMEPAGE="https://llvmlite.pydata.org/";
+SRC_URI="https://github.com/numba/llvmlite/archive/v${PV/_/}.tar.gz -> 
${P/_/}.gh.tar.gz"
+S="${WORKDIR}/${P/_/}"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~x86"
+IUSE="examples"
+
+LLVM_MAX_SLOT=13
+
+RDEPEND="
+       sys-devel/llvm:${LLVM_MAX_SLOT}
+       sys-libs/zlib:0=
+"
+DEPEND="${RDEPEND}"
+
+PATCHES=( "${FILESDIR}/${P}-llvm12.patch" )
+
+src_prepare() {
+       sed -i -e '/max_python/s:3\.10:3.11:' setup.py || die
+       distutils-r1_src_prepare
+}
+
+python_configure_all() {
+       # upstream's build system is just horrible, and they ignored the PR
+       # fixing it, so let's build the shared lib properly using implicit
+       # make rules
+
+       export LDLIBS=$(llvm-config --libs all)
+       export CXXFLAGS="$(llvm-config --cxxflags) -fPIC ${CXXFLAGS}"
+       export LDFLAGS="$(llvm-config --ldflags) ${LDFLAGS}"
+
+       local files=( ffi/*.cpp )
+       emake -f - <<EOF
+ffi/libllvmlite.so: ${files[*]/.cpp/.o}
+       \$(CXX) -shared \$(CXXFLAGS) \$(LDFLAGS) -o \$@ \$^ \$(LDLIBS)
+EOF
+
+       export LLVMLITE_SKIP_LLVM_VERSION_CHECK=1
+}
+
+python_test() {
+       "${EPYTHON}" runtests.py -v || die "Tests failed under ${EPYTHON}"
+}
+
+python_install_all() {
+       distutils-r1_python_install_all
+       if use examples; then
+               dodoc -r examples
+               docompress -x /usr/share/doc/${PF}/examples
+       fi
+}

Reply via email to