llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

Tests fail: KeyError: 'LLVMPY_AddRefPrunePass'

Open yurivict opened this issue 3 years ago • 7 comments

Tests fail, see:

=========================================================================================== ERRORS ===========================================================================================
______________________________________________________________________ ERROR collecting llvmlite/tests/test_binding.py _______________________________________________________________________
llvmlite/binding/ffi.py:95: in __getattr__
    return self._fntab[name]
E   KeyError: 'LLVMPY_AddRefPrunePass'

During handling of the above exception, another exception occurred:
llvmlite/tests/test_binding.py:16: in <module>
    from llvmlite import binding as llvm
llvmlite/binding/__init__.py:10: in <module>
    from .passmanagers import *
llvmlite/binding/passmanagers.py:397: in <module>
    ffi.lib.LLVMPY_AddRefPrunePass.argtypes = [ffi.LLVMPassManagerRef, c_int,
llvmlite/binding/ffi.py:98: in __getattr__
    cfn = getattr(self._lib, name)
/usr/local/lib/python3.9/ctypes/__init__.py:387: in __getattr__
    func = self.__getitem__(name)
/usr/local/lib/python3.9/ctypes/__init__.py:392: in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
E   AttributeError: Undefined symbol "LLVMPY_AddRefPrunePass"
_________________________________________________________________________ ERROR collecting llvmlite/tests/test_ir.py _________________________________________________________________________
llvmlite/binding/ffi.py:95: in __getattr__
    return self._fntab[name]
E   KeyError: 'LLVMPY_AddRefPrunePass'

During handling of the above exception, another exception occurred:
llvmlite/tests/test_ir.py:14: in <module>
    from llvmlite import binding as llvm
llvmlite/binding/__init__.py:10: in <module>
    from .passmanagers import *
llvmlite/binding/passmanagers.py:397: in <module>
    ffi.lib.LLVMPY_AddRefPrunePass.argtypes = [ffi.LLVMPassManagerRef, c_int,
llvmlite/binding/ffi.py:98: in __getattr__
    cfn = getattr(self._lib, name)
/usr/local/lib/python3.9/ctypes/__init__.py:387: in __getattr__
    func = self.__getitem__(name)
/usr/local/lib/python3.9/ctypes/__init__.py:392: in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
E   AttributeError: Undefined symbol "LLVMPY_AddRefPrunePass"
______________________________________________________________________ ERROR collecting llvmlite/tests/test_refprune.py ______________________________________________________________________
llvmlite/binding/ffi.py:95: in __getattr__
    return self._fntab[name]
E   KeyError: 'LLVMPY_AddRefPrunePass'

During handling of the above exception, another exception occurred:
llvmlite/tests/test_refprune.py:3: in <module>
    from llvmlite import binding as llvm
llvmlite/binding/__init__.py:10: in <module>
    from .passmanagers import *
llvmlite/binding/passmanagers.py:397: in <module>
    ffi.lib.LLVMPY_AddRefPrunePass.argtypes = [ffi.LLVMPassManagerRef, c_int,
llvmlite/binding/ffi.py:98: in __getattr__
    cfn = getattr(self._lib, name)
/usr/local/lib/python3.9/ctypes/__init__.py:387: in __getattr__
    func = self.__getitem__(name)
/usr/local/lib/python3.9/ctypes/__init__.py:392: in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
E   AttributeError: Undefined symbol "LLVMPY_AddRefPrunePass"
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 3 errors in 1.41s ======================================================================================

Version: 0.39.1 llvm-11 Python-3.9 FreeBSD 13.1

yurivict avatar Sep 17 '22 15:09 yurivict

@yurivict thank you for submitting this. May I ask how you installed Python and how you installed llvmlite?

FWIW: the "thing" that appears to be missing should come from here: https://github.com/numba/llvmlite/blob/main/ffi/custom_passes.cpp#L1171 -- so my guess would be, that you are experiencing some sort of linking issue.

esc avatar Sep 19 '22 10:09 esc

Both Python and llvmlite are installed from FreeBSD ports.

yurivict avatar Sep 19 '22 15:09 yurivict

Both Python and llvmlite are installed from FreeBSD ports.

OK; thank you for following up. Is there a way to submit this issue to the folks that maintain this port? The Numba team doesn't officially support/test-on FreeBSD (it's a best effort) and we didn't build the ports/packages you are installing, so we don't know exactly how they were built and thus our chances of success to debug this are somewhat limited.

esc avatar Sep 19 '22 15:09 esc

The C++ part looks like this:

===>  Building for py39-llvmlite-0.39.1
running build
got version from file /disk-samsung/freebsd-ports/devel/py-llvmlite/work-py39/llvmlite-0.39.1/llvmlite/_version.py {'version': '0.39.1', 'full': '31f808fa7a5796bb8d4b14e8a9e27c6dd15f2b6c'}
running build_ext
/usr/local/bin/python3.9 /disk-samsung/freebsd-ports/devel/py-llvmlite/work-py39/llvmlite-0.39.1/ffi/build.py
LLVM version... --- libllvmlite.so ---
c++ -shared -fno-omit-frame-pointer -fno-omit-frame-pointer -fPIC  -fPIC -fno-omit-frame-pointer -I/usr/local/llvm11/include -std=c++14 -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp  executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp  linker.cpp object_file.cpp -o libllvmlite.so  -Wl,-rpath=/usr/local/lib/gcc11  -L/usr/local/lib/gcc11 -B/usr/local/bin -fstack-protector-strong  -L/usr/local/llvm11/lib -lLLVM-11

It doesn't include custom_passes.cpp.

custom_passes.cpp isn't mentioned anywhere in the log.

It seems that GNU make is used. How to switch to cmake?

yurivict avatar Sep 19 '22 15:09 yurivict

custom_passes.cpp is missing in ffi/Makefile.freebsd.

yurivict avatar Sep 19 '22 15:09 yurivict

custom_passes.cpp is missing in ffi/Makefile.freebsd.

Seems like it is indeed missing, which I think would explain the immediate problem. A patch to fix would be welcomed! Many thanks!

stuartarchibald avatar Sep 20 '22 07:09 stuartarchibald

@yurivict @stuartarchibald thank you for diagnosing. I have updated the labels to bug and build.

esc avatar Sep 22 '22 14:09 esc

As the automated system shows, I have submitted a patch for this issue. I've run it on 13.2-RELEASE-p2 for amd64. It does indeed resolve the missing symbol and the ensuing library seems to work enough that I can finally run OpenAI's Whisper project under FreeBSD. (This was a blocking issue there).

ke6jjj avatar Oct 10 '23 18:10 ke6jjj

Closing now as #997 has been merged.

esc avatar Feb 05 '24 08:02 esc