Kuree / pysv

Running Python code in SystemVerilog
BSD 2-Clause "Simplified" License
62 stars 13 forks source link

Running "hello world" : Unable to create a shared library #23

Closed hmomkargit closed 1 year ago

hmomkargit commented 1 year ago

HI, I am using the pysv for the first time and trying to run the "hello world" example. When i run the python script, it fails at "compile_lib" stage. Could you please let me know if i am missing any steps ?

Snippet of error output : "

- pybind11 v2.6.2 dev1
-- Configuring done
-- Generating done
-- Build files have been written to: /data/shared/common/users/hmomkar/exp/pysv/build/build
[ 50%] Linking CXX shared module libpysv.so
/bin/ld: /apps/python/3.8.15/lib/libpython3.8.a(abstract.o): relocation R_X86_64_32S against symbol `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /apps/python/3.8.15/lib/libpython3.8.a(boolobject.o): relocation R_X86_64_32S against symbol `_Py_FalseStruct' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /apps/python/3.8.15/lib/libpython3.8.a(bytearrayobject.o): relocation R_X86_64_32 against symbol `_PyByteArray_empty_string' can not be used when making a shared object; recompile 

.. ... ..

/bin/ld: /apps/python/3.8.15/lib/libpython3.8.a(getcompiler.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
gmake[2]: *** [libpysv.so] Error 1
gmake[1]: *** [CMakeFiles/libpysv.dir/all] Error 2
gmake: *** [all] Error 2
Traceback (most recent call last):
  File "./ref.py", line 9, in <module>
    lib_path = compile_lib([hello_world], cwd="build")
  File "/data/home/hmomkar/.local/lib/python3.7/site-packages/pysv/compile.py", line 65, in compile_lib
    subprocess.check_call(["cmake", "--build", "."], cwd=build_dir)
  File "/apps/python/latest/lib/python3.7/subprocess.py", line 341, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.']' returned non-zero exit status 2.

"

Thanks for the help !

Kuree commented 1 year ago

Can you tell me your system specs, i.e. what distro is this? I will try to reproduce it in the meantime.

hmomkargit commented 1 year ago

Sure. I am using CentOS 7. Related tool version: cmake - 3.14.4 Python - 3.7.1 gcc -8.2

Let me know if you need more information. Thanks !

Omkar

hmomkargit commented 1 year ago

The issue was with way python was configured and installed. I re-installed python and configured with --enable_shared switch. Now, it is working.