Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct dependency "libunistring" has no configure options #214

Closed
TurtleWilly opened this issue Jul 23, 2023 · 8 comments · Fixed by #240
Closed

Direct dependency "libunistring" has no configure options #214

TurtleWilly opened this issue Jul 23, 2023 · 8 comments · Fixed by #240

Comments

@TurtleWilly
Copy link

TurtleWilly commented Jul 23, 2023

When building libpsl with --enable-runtime=libidn2 libunistring also seems to become a direct dependency. While libidn2 can be tuned via pkg-config or the LIBIDN2_CFLAGS/ LIBIDN2_LIBS variables there's no such visible option for libunistring in libpsl's configure --help output. The libunistring package doesn't offer any pkg-config integration too sadly… resulting in the libpsl configure just fail when it can't be located in a default directory.

A --with-libunistring-prefix= configure option would be appreciated. It also would add verbosity to this requirement.

Currently an ugly workaround via the CPPFLAGS/LDFLAGS/LIBS variables kludge is required to make things work:

./configure --prefix=/usr/local/targetdirectory/libpsl/0.21.2 \
    --enable-runtime=libidn2 \
    CPPFLAGS="-I/usr/local/targetdirectory/libunistring/latest/include" \
    LDFLAGS="-L/usr/local/targetdirectory/libunistring/latest/lib" \
    LIBS="-lunistring" \
    …
@rockdaboot
Copy link
Owner

Libidn2 either has the needed unistring functions included (at least this is a built option for libidn2) or is already linked to libunistring when dynamically built. E.g.

$ ldd /lib/x86_64-linux-gnu/libidn2.so.0
        linux-vdso.so.1 (0x00007ffd6e38f000)
        libunistring.so.5 => /lib/x86_64-linux-gnu/libunistring.so.5 (0x00007f04e3d66000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f04e3b84000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f04e3f69000)

So having libunistring as a direct dependency in ./configure.ac is to simplify fully static builds of libpsl.

So are you sure that a --with-libunistring-prefix= is helpful to you? (TBH, I didn't try it.)

@rb07
Copy link

rb07 commented Feb 26, 2024

Yes it would help.

I ran into the same situation, building psl with libunistring in /usr/local results in 2 references to it:

$ ldd ./tests/test-is-public
       	linux-vdso.so.1 (0x00007ffd45d95000)
       	libpsl.so.5 => /root/build/libpsl-0.21.5/src/.libs/libpsl.so.5 (0x00007f90e267b000)
       	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f90e24a9000)
       	libunistring.so.5 => not found
       	libidn2.so.0 => /usr/local/lib/libidn2.so.0 (0x00007f90e2477000)
       	/lib64/ld-linux-x86-64.so.2 (0x00007f90e2696000)
       	libunistring.so.5 => /usr/local/lib/libunistring.so.5 (0x00007f90e22c1000)

All tests fail because of this.

And libidn has the correct reference:

$ ldd /usr/local/lib/libidn2.so.0
       	linux-vdso.so.1 (0x00007ffc809b4000)
       	libunistring.so.5 => /usr/local/lib/libunistring.so.5 (0x00007fda1a058000)
       	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fda19e86000)
       	/lib64/ld-linux-x86-64.so.2 (0x00007fda1a242000)

This just worked (something I also use with curl):

./configure --prefix=/usr/local \
            --disable-nls \
            LDFLAGS="-Wl,-rpath -Wl,/usr/local/lib"

@TurtleWilly
Copy link
Author

I'm currently failing to build from the master. 😢 I'm not entirely sure what is going wrong, but it's an unrelated problem (some parts of the autoconf stuff fails). I may have messed up my autoconf installation, or it is outdated (probably both 😄), so I'll first have to look into that in the next days. Sorry, I can't confirm or deny the working of the new option yet, but I very much appreciate that it was added. 👍

@TurtleWilly
Copy link
Author

Found a solution for the autoconf/automake problem I was encountering (it was missing m4 macros from pkg-config, which I then manually copied into the local "m4" directory to make things work. Who knew? 😄 )

Test (1) w/o --with-libunistring-prefix

$ ./configure --enable-runtime=libidn2
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
…
checking for iconv... yes
checking for working iconv... yes
checking how to link with libiconv... -liconv
checking for iconv declaration... 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for libunistring... no, trying again together with libiconv
checking for libunistring... no, consider installing GNU libunistring
…
checking for libidn2... yes
checking for library containing u8_tolower... no
configure: error: You requested libidn2|libidn but libunistring is not installed.
…

fails as expected.

and test (2) with --with-libunistring-prefix

$ ./configure \
    --enable-runtime=libidn2 \
    --with-libunistring-prefix=/usr/local/targetdirectory/libunistring/latest
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
…
checking for libunistring... yes
checking how to link with libunistring... -L/usr/local/targetdirectory/libunistring/latest/lib -lunistring -L/usr/local/targetdirectory/libiconv/latest/lib -liconv 
checking for libunistring version... 1.1.0
…
checking for libidn2... yes
checking for library containing u8_tolower... no
configure: error: You requested libidn2|libidn but libunistring is not installed.

Looks like it properly detects libunistring (including its iconv dependency), but later fails on the "u8_tolower" check (probably not using the detected information there yet?)

@eli-schwartz
Copy link
Collaborator

Found a solution for the autoconf/automake problem I was encountering (it was missing m4 macros from pkg-config, which I then manually copied into the local "m4" directory to make things work. Who knew? 😄 )

This should work fine as long as pkg-config is installed, since it will install its m4 macro collection to the system aclocal store.

What was the error?

@TurtleWilly
Copy link
Author

This should work fine as long as pkg-config is installed, since it will install its m4 macro collection to the system aclocal store.

What was the error?

Yes, pkg-config was installed, albeit the m4 macros didn't made it to a global aclocale directory. I only had linked up the binary and was using the lib/pkgconfig directory. I install all my packages into their own directory (/usr/local/silo/<package>/<version>) and then very strictly only link up things into the global /usr/local/* directories that I truly require, so I have a clutter-free environment w/o tons of path pollution by random binaries, libraries, etc., that's eventually easy to maintain.

Occasionally you stumble over some unexpected issues like this, then I learn new things in the process. I have not decided I want a global aclocal store and I'm still thinking about this… hence copying to the temporary local m4 directory was a suitable hot-fix here. 😎

@rockdaboot
Copy link
Owner

configure: error: You requested libidn2|libidn but libunistring is not installed.

@TurtleWilly Can you test #243?

@TurtleWilly
Copy link
Author

@TurtleWilly Can you test #243?

This seems to work for me. 👍 Only a cosmetic issue left now:

$ ./configure --with-libunistring-prefix=/usr/local/silo/libunistring/latest
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
…
checking how to link with libiconv... -liconv
checking for iconv declaration... 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for libunistring... yes
checking how to link with libunistring... -L/usr/local/silo/libunistring/latest/lib -lunistring -L/usr/local/silo/libiconv/latest/lib -liconv 
checking for libunistring version... 1.1.0
…
config.status: creating po/Makefile
configure: Summary of build options:

  Version:           0.21.5
  Host OS:           darwin14.5.0
  Install prefix:    /usr/local
  Compiler:          gcc
  CFlags:            -I/usr/local/silo/libidn2/latest/include -g -O2 -I/usr/local/silo/libunistring/latest/include -I/usr/local/silo/libiconv/latest/include
  LDFlags:           
  Libs:              -L/usr/local/silo/libidn2/latest/lib -lidn2 
  Runtime:           libidn2
  Builtin:           yes
  PSL Dist File:     
  PSL File:          $(top_srcdir)/list/public_suffix_list.dat
  PSL Test File:     $(top_srcdir)/list/tests/tests.txt
  Sanitizers:        UBSan no, ASan no, CFI no
  Docs:              
  Man pages:         no
  Tests:             Valgrind testing not enabled
  Fuzzing build:     no, 


$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in po
…
make[2]: Nothing to be done for `all-am'.

$ otool -L src/.libs/libpsl.5.dylib 
libpsl.5.dylib:
	/usr/local/lib/libpsl.5.dylib (compatibility version 9.0.0, current version 9.5.0)
	/usr/local/silo/libidn2/latest/lib/libidn2.0.dylib (compatibility version 4.0.0, current version 4.8.0)
	/usr/local/silo/libunistring/latest/lib/libunistring.5.dylib (compatibility version 6.0.0, current version 6.0.0)
	/usr/local/silo/libiconv/latest/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.1.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

The only thing that seems to be broken/ missing still is the detected bits are missing in the summary at the end of the configure output (see "Libs:" and "LDFlags:" rows).

… and with removing indirect dependencies:

$ ./configure --with-libunistring-prefix=/usr/local/silo/libunistring/latest LDFLAGS='-Wl,-dead_strip_dylibs -Wl,-dead_strip'

…
…
…

$ otool -L src/.libs/libpsl.5.dylib
src/.libs/libpsl.5.dylib:
	/usr/local/lib/libpsl.5.dylib (compatibility version 9.0.0, current version 9.5.0)
	/usr/local/silo/libidn2/latest/lib/libidn2.0.dylib (compatibility version 4.0.0, current version 4.8.0)
	/usr/local/silo/libunistring/latest/lib/libunistring.5.dylib (compatibility version 6.0.0, current version 6.0.0)
	/usr/local/silo/libiconv/latest/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants