From 711bfac13c370e892d164363084a2272dc413941 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 12 Oct 2023 13:19:06 +0100 Subject: [PATCH] Revert "Merge pull request #967 from apmasell/orcjit_lib_name" This reverts commit bbb88a78164e3ec733107eab81004f7eaa68737f, reversing changes made to ff1d118213ea8516a2898cd50326235c2b1ab214. --- llvmlite/binding/orcjit.py | 22 ++++++++-------------- llvmlite/tests/test_binding.py | 1 - 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/llvmlite/binding/orcjit.py b/llvmlite/binding/orcjit.py index 82996f586..16dbcadf7 100644 --- a/llvmlite/binding/orcjit.py +++ b/llvmlite/binding/orcjit.py @@ -144,8 +144,8 @@ def link(self, lljit, library_name): however, the name of the library cannot be reused. """ assert not lljit.closed, "Cannot add to closed JIT" - encoded_library_name = str(library_name).encode('utf-8') - assert len(encoded_library_name) > 0, "Library cannot be empty" + library_name = str(library_name).encode('utf-8') + assert len(library_name) > 0, "Library cannot be empty" elements = (_LinkElement * len(self.__entries))() for idx, (kind, value) in enumerate(self.__entries): elements[idx].element_kind = c_uint8(kind) @@ -163,7 +163,7 @@ def link(self, lljit, library_name): with ffi.OutputString() as outerr: tracker = lljit._capi.LLVMPY_LLJIT_Link( lljit._ptr, - encoded_library_name, + library_name, elements, len(self.__entries), imports, @@ -173,10 +173,9 @@ def link(self, lljit, library_name): outerr) if not tracker: raise RuntimeError(str(outerr)) - return ResourceTracker(tracker, - library_name, - {name: exports[idx].address - for idx, name in enumerate(self.__exports)}) + return ResourceTracker(tracker, {name: exports[idx].address + for idx, name in + enumerate(self.__exports)}) class ResourceTracker(ffi.ObjectRef): @@ -196,9 +195,8 @@ class ResourceTracker(ffi.ObjectRef): LLVM internally tracks references between different libraries, so only "leaf" libraries need to be tracked. """ - def __init__(self, ptr, name, addresses): + def __init__(self, ptr, addresses): self.__addresses = addresses - self.__name = name ffi.ObjectRef.__init__(self, ptr) def __getitem__(self, item): @@ -207,10 +205,6 @@ def __getitem__(self, item): """ return self.__addresses[item] - @property - def name(self): - return self.__name - def _dispose(self): with ffi.OutputString() as outerr: if self._capi.LLVMPY_LLJIT_Dylib_Tracker_Dispose(self, outerr): @@ -258,7 +252,7 @@ def lookup(self, dylib, fn): if not tracker: raise RuntimeError(str(outerr)) - return ResourceTracker(tracker, dylib, {fn: address.value}) + return ResourceTracker(tracker, {fn: address.value}) @property def target_data(self): diff --git a/llvmlite/tests/test_binding.py b/llvmlite/tests/test_binding.py index d1326f449..eabe03864 100644 --- a/llvmlite/tests/test_binding.py +++ b/llvmlite/tests/test_binding.py @@ -1239,7 +1239,6 @@ def jit(self, asm=asm_sum, func_name="sum", target_machine=None, .link(lljit, func_name) cfptr = rt[func_name] self.assertTrue(cfptr) - self.assertEqual(func_name, rt.name) return lljit, rt, func_type(cfptr) # From test_dylib_symbols