FS#77224 - [libtiff] static linking is not possible due to jbigkit missing as a dependency
Attached to Project:
Arch Linux
Opened by LaserEyess (LaserEyess) - Sunday, 22 January 2023, 01:33 GMT
Last edited by David Runge (dvzrv) - Saturday, 02 September 2023, 15:48 GMT
Opened by LaserEyess (LaserEyess) - Sunday, 22 January 2023, 01:33 GMT
Last edited by David Runge (dvzrv) - Saturday, 02 September 2023, 15:48 GMT
|
Details
Description: When using libtiff in static compilation
libjbig cannot be found and compilation errors out
Additional info: * Version: 4.5.0-1 Steps to reproduce: Create a file that links to libtiff and try the following: $ gcc tiff.c $(pkg-config --cflags --libs --static libtiff-4) /usr/bin/ld: cannot find -ljbig: No such file or directory collect2: error: ld returned 1 exit status The problem is jbigkit is a makedepend and triggers this check in autotools[1]. Curiously, libtiff is usable as a shared library, I don't really know how that works. Someone I talked to said it could be a gcc bug with --as-needed. [1] https://gitlab.com/libtiff/libtiff/-/blob/master/configure.ac#L679-691 |
This task depends upon
Closed by David Runge (dvzrv)
Saturday, 02 September 2023, 15:48 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed with jbigkit 2.1-7. Further rebuilds are required and are tracked in https://archlinux.org/todo/rebuild-again st-jbigkit-shared-libraries/
Saturday, 02 September 2023, 15:48 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed with jbigkit 2.1-7. Further rebuilds are required and are tracked in https://archlinux.org/todo/rebuild-again st-jbigkit-shared-libraries/
[1] https://archlinux.org/todo/remove-static-libraries/
[2] https://en.wikipedia.org/wiki/LibTIFF#Exploits
This is trivial to reproduce, and I explained how to fix it in the issue. There is actually a second bug here that gcc is not linking libjbig to libtiff.so, but right now the broken .pc file is the biggest issue.
Libs.private: -lzstd -llzma -ljbig -ljpeg -lz -lm
the -ljbig part is the issue here.
[1] https://gitlab.com/libtiff/libtiff/-/blob/master/configure.ac#L679-691
[1] https://github.com/archlinux/svntogit-community/blob/packages/jbigkit/trunk/PKGBUILD#L24
Edit:
Another option what be to convert jbigkit to a shared library as Fedora [1] and Debian [2] have done.
Edit2:
If you remove the --static flag from the pkgconf / pkg-config invocation is the build correct?
[1] https://src.fedoraproject.org/rpms/jbigkit/blob/rawhide/f/jbigkit-2.1-shlib.patch
[2] https://sources.debian.org/data/main/j/jbigkit/2.1-6.1/debian/patches/improve-upstream-Makefiles.diff
$ gcc my_mpv_app.c $(pkg-config --cflags --libs --static my-libmpv)
Then when resolving the dependencies of ffpmeg->libtiff, it would propagate the --static flag, and thus -ljbig would be included and cause the error. Technically, -ljbig is not necessary here, since ffmpeg and libtiff are shared libs. However, in this particular case, because libjbig was statically compiled into libtiff.so, and because Libs.Private exists even though libtiff.a does not, you get the error.
I will open a rebuild TODO for the dependents.