#4147 Build error with python3.8-config --ldflags
Closed: Fixed a year ago by pbrezina. Opened a year ago by ahasenack.

Hi,

in Ubuntu and Debian at least, python3-config --ldflags returns multiple paths for -L:

root@sid-py38:~# python3.8-config --ldflags
-L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -L/usr/lib  -lcrypt -lpthread -ldl  -lutil -lm -lm

Since commit 80fdef5, the ./configure script tries to figure out the full path to the libpython3.8.so file but just adds the name of the library to a multi-line result from the previous grep -o:

python_lib_path="` $PYTHON_CONFIG --ldflags | grep -o -- '-L/[^ ]*' | sed -e 's/^-L//'`"
if test x"$python_lib_path" != x; then
    PYTHON_DLOPEN_LIB=$python_lib_path"/"$PYTHON_DLOPEN_LIB
fi
PYTHON_DLOPEN_LIB=$PYTHON_DLOPEN_LIB".so"

Since we have two -L components, the end result is invalid:

| #define PYTHON_DLOPEN_LIB "/usr/lib/python3.8/config-3.8-x86_64-linux-gnu
| /usr/lib/libpython3.8.so"

conftest.c:170:27: warning: missing terminating " character
  170 | #define PYTHON_DLOPEN_LIB "/usr/lib/python3.8/config-3.8-x86_64-linux-gnu
      | ^
conftest.c:171:25: warning: missing terminating " character
  171 | /usr/lib/libpython3.8.so"
      | ^
configure:23091: $? = 0

Maybe it would be best to loop over the -L values until we find the file? Something like this:

--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -36,10 +36,13 @@ path. If you want to build sssd without $1 bindings then specify
     if test $? -eq 0; then
         PYTHON_DLOPEN_LIB="` $PYTHON_CONFIG --libs --embed | grep -o -- '-lpython@<:@^ @:>@*' |sed -e 's/^-l/lib/'`"
         if test x"$PYTHON_DLOPEN_LIB" != x; then
-            python_lib_path="` $PYTHON_CONFIG --ldflags | grep -o -- '-L/@<:@^ @:>@*' | sed -e 's/^-L//'`"
-            if test x"$python_lib_path" != x; then
-                PYTHON_DLOPEN_LIB=$python_lib_path"/"$PYTHON_DLOPEN_LIB
-            fi
+            python_lib_paths="` $PYTHON_CONFIG --ldflags | grep -o -- '-L/@<:@^ @:>@*' | sed -e 's/^-L//'`"
+            for p in $python_lib_paths; do
+                if test -e $p"/"$PYTHON_DLOPEN_LIB; then
+                    PYTHON_DLOPEN_LIB=$p"/"$PYTHON_DLOPEN_LIB
+                    break
+                fi
+            done
             PYTHON_DLOPEN_LIB=$PYTHON_DLOPEN_LIB".so"
             AC_DEFINE_UNQUOTED([PYTHON_DLOPEN_LIB], ["$PYTHON_DLOPEN_LIB"], [The path of libpython for dlopen-tests])
         fi

Hi,

thank you, I think this is a good idea. Would you mind to open a pull-request at https://github.com/SSSD/sssd?

bye,
Sumit

IMHO, it would be better to simplify it a bit.
We might get pat to binary from output of ldd

 ldd $PYTHON3 | grep python
        libpython3.8.so.1.0 => /lib64/libpython3.8.so.1.0 (0x00007f8cab3e7000)

ldd would not work on debian :-(

root@1dd2e7b133f6:~# cat /etc/debian_version
bullseye/sid
root@1dd2e7b133f6:~# ldd /usr/bin/python3.8
        linux-vdso.so.1 (0x00007fff0e3fb000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0509c73000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0509c52000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0509c4d000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f0509c48000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0509b03000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f0509ad6000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0509ab7000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0509e3d000)
root@1dd2e7b133f6:~# ldd /usr/bin/python3.8 | grep python

Please ignore previous comment

  • master
    • 4dbfaae - Fix another build failure with python 3.8

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/5105

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Login to comment on this ticket.

Metadata