STINNER Victor <vstin...@redhat.com> added the comment:

Example of the bug:

---
$ git apply ~/Setup.patch
$ ./configure --with-pydebug --enable-shared
$ make
$ grep _contextvars Makefile
(...)

Modules/_contextvarsmodule.o: $(srcdir)/Modules/_contextvarsmodule.c; $(CC) 
$(CCSHARED) $(PY_CFLAGS) $(PY_CPPFLAGS)  -c 
$(srcdir)/Modules/_contextvarsmodule.c -o Modules/_contextvarsmodule.o

Modules/_contextvars$(EXT_SUFFIX):  Modules/_contextvarsmodule.o; $(BLDSHARED)  
Modules/_contextvarsmodule.o   -o Modules/_contextvars$(EXT_SUFFIX)

$ find -name "_contextvars.*so"
./Modules/_contextvars.cpython-38dm-x86_64-linux-gnu.so

$ ldd $(find -name "_contextvars.*so")
        linux-vdso.so.1 (0x00007ffd27973000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd081433000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fd081074000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd081854000)
---

The _contextvars shared library is not linked to libpython. There is not 
"-lpythonX.Y" in the Makefile rule.


Now with the patch:
---
$ git clean -fdx
$ git apply ~/Setup.patch
$ ./configure --with-pydebug --enable-shared
$ make
$ grep _contextvars Makefile
(...)

Modules/_contextvarsmodule.o: $(srcdir)/Modules/_contextvarsmodule.c; $(CC) 
$(CCSHARED) $(PY_CFLAGS) $(PY_CPPFLAGS)  -c 
$(srcdir)/Modules/_contextvarsmodule.c -o Modules/_contextvarsmodule.o

Modules/_contextvars$(EXT_SUFFIX):  Modules/_contextvarsmodule.o $(LDLIBRARY); 
$(BLDSHARED)  Modules/_contextvarsmodule.o $(BLDLIBRARY)   -o 
Modules/_contextvars$(EXT_SUFFIX)

$ find -name "_contextvars.*so"
./Modules/_contextvars.cpython-38dm-x86_64-linux-gnu.so

$ ldd $(find -name "_contextvars.*so")
        linux-vdso.so.1 (0x00007ffd1e918000)
        libpython3.8dm.so.1.0 => not found
        (...)
---

With my patch, _contextvars.cpython-38dm-x86_64-linux-gnu.so is linked to 
libpython3.8dm.so.1.0 as expected. The Makefile rule adds  $(LDLIBRARY) to the 
dependencies of the _contextvars(...).so rule and it adds $(BLDLIBRARY) to the 
linker flags of this rule.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34814>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to