Can't build openmp project with python 3.12
The build works with Python 3.10, only thing changed to reproduce was using 3.12. Building release 17.x branch
Linking C shared module projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so
FAILED: projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so
: && /usr/bin/cc -fPIC -fPIC -fno-semantic-interposition -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -O3 -DNDEBUG -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -shared -o projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so projects/openmp/libompd/gdb-plugin/CMakeFiles/ompdModule.dir/ompdModule.c.o projects/openmp/libompd/gdb-plugin/CMakeFiles/ompdModule.dir/ompdAPITests.c.o /usr/local/lib/libpython3.12.a -ldl && :
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:40 (./Modules/clinic/_localemodule.c.h:40)
>>> _localemodule.o:(_locale_setlocale) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:50 (./Modules/clinic/_localemodule.c.h:50)
>>> _localemodule.o:(_locale_setlocale.cold) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_RuntimeWarning'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:172 (./Modules/_localemodule.c:172)
>>> _localemodule.o:(_locale_localeconv) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:478 (./Modules/clinic/_localemodule.c.h:478)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c:730 (./Modules/_localemodule.c:730)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_OSError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:740 (./Modules/_localemodule.c:740)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:354 (./Modules/clinic/_localemodule.c.h:354)
>>> _localemodule.o:(_locale_dcgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:382 (./Modules/clinic/_localemodule.c.h:382)
>>> _localemodule.o:(_locale_dcgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:289 (./Modules/clinic/_localemodule.c.h:289)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:299 (./Modules/clinic/_localemodule.c.h:299)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:317 (./Modules/clinic/_localemodule.c.h:317)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:528 (./Modules/clinic/_localemodule.c.h:528)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:538 (./Modules/clinic/_localemodule.c.h:538)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c:770 (./Modules/_localemodule.c:770)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:417 (./Modules/clinic/_localemodule.c.h:417)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:427 (./Modules/clinic/_localemodule.c.h:427)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_OSError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:701 (./Modules/_localemodule.c:701)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:252 (./Modules/clinic/_localemodule.c.h:252)
>>> _localemodule.o:(_locale_gettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:623 (./Modules/_localemodule.c:623)
>>> _localemodule.o:(_locale_nl_langinfo) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:405 (./Modules/_localemodule.c:405)
>>> _localemodule.o:(_locale_strxfrm) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
collect2: error: ld returned 1 exit status
@llvm/issue-subscribers-openmp
Author: Liam Clink (liam-clink)
Linking C shared module projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so
FAILED: projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so
: && /usr/bin/cc -fPIC -fPIC -fno-semantic-interposition -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -O3 -DNDEBUG -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -shared -o projects/openmp/libompd/gdb-plugin/python-module/ompd/ompdModule.so projects/openmp/libompd/gdb-plugin/CMakeFiles/ompdModule.dir/ompdModule.c.o projects/openmp/libompd/gdb-plugin/CMakeFiles/ompdModule.dir/ompdAPITests.c.o /usr/local/lib/libpython3.12.a -ldl && :
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:40 (./Modules/clinic/_localemodule.c.h:40)
>>> _localemodule.o:(_locale_setlocale) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:50 (./Modules/clinic/_localemodule.c.h:50)
>>> _localemodule.o:(_locale_setlocale.cold) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_RuntimeWarning'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:172 (./Modules/_localemodule.c:172)
>>> _localemodule.o:(_locale_localeconv) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:478 (./Modules/clinic/_localemodule.c.h:478)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c:730 (./Modules/_localemodule.c:730)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_OSError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:740 (./Modules/_localemodule.c:740)
>>> _localemodule.o:(_locale_bindtextdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:354 (./Modules/clinic/_localemodule.c.h:354)
>>> _localemodule.o:(_locale_dcgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:382 (./Modules/clinic/_localemodule.c.h:382)
>>> _localemodule.o:(_locale_dcgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:289 (./Modules/clinic/_localemodule.c.h:289)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:299 (./Modules/clinic/_localemodule.c.h:299)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:317 (./Modules/clinic/_localemodule.c.h:317)
>>> _localemodule.o:(_locale_dgettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:528 (./Modules/clinic/_localemodule.c.h:528)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:538 (./Modules/clinic/_localemodule.c.h:538)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c:770 (./Modules/_localemodule.c:770)
>>> _localemodule.o:(_locale_bind_textdomain_codeset) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '_Py_NoneStruct'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(object.o)
>>> referenced by _localemodule.c.h:417 (./Modules/clinic/_localemodule.c.h:417)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:427 (./Modules/clinic/_localemodule.c.h:427)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_OSError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:701 (./Modules/_localemodule.c:701)
>>> _localemodule.o:(_locale_textdomain) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c.h:252 (./Modules/clinic/_localemodule.c.h:252)
>>> _localemodule.o:(_locale_gettext) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:623 (./Modules/_localemodule.c:623)
>>> _localemodule.o:(_locale_nl_langinfo) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'PyExc_ValueError'; recompile with -fPIC
>>> defined in /usr/local/lib/libpython3.12.a(exceptions.o)
>>> referenced by _localemodule.c:405 (./Modules/_localemodule.c:405)
>>> _localemodule.o:(_locale_strxfrm) in archive /usr/local/lib/libpython3.12.a
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
collect2: error: ld returned 1 exit status
A workaround would be to use -DLIBOMP_OMPD_SUPPORT=OFF. I'm wondering if the symbols changed in libpython3.12.a, presumably they're not usable with -fPIC now considering that the OpenMP compilation is using -fPIC.
I am unfortunately don't know enough abot the project to know if losing -fPIC like this would be a problem, or why Python would drop this
I am unfortunately don't know enough abot the project to know if losing -fPIC like this would be a problem, or why Python would drop this
All that matters is libompd is trying to link against Python's static library. The R_X86_64_PC32 is a 32-byte program counter relative relocation, as opposed to a direct address. PC-relative addressing is related to -fPIC. So this suggests to me that our application is trying to build with -fPIC, but for some reason the Python library isn't providing it anymore with a valid relocation. I don't think there's anything we can do here, since it's not like we can alter the Python package. The one option would be to ignore the failure if building libompd fails.
Is it possible that the Python library can be recompiled with fPIC enabled if it isn't by default for some reason?
That is libpython, provided by the package manager. It's beyond our control. LLDB also has similar situation that if building LLVM with dynamic library enabled, the Python library error will be encountered.
@liam-clink This looks unusual. How did you install python? Did you build it yourself?
I did build it, with standard build options. Which is why I'm guessing that maybe fPIC is off by default in Python, at least 3.12
From what I remember, I always had to enable building the shared library. I'm not sure why it's off, but IIRC all prebuilt python packages do come with the shared library.
In this case the most logical thing to do would be to build it with the shared library.
Close the issue for now as it doesn't look like an issue from OpenMP side.