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

mupdf: fix library linking #30071

Merged
merged 3 commits into from Oct 5, 2017
Merged

mupdf: fix library linking #30071

merged 3 commits into from Oct 5, 2017

Conversation

danielfullmer
Copy link
Contributor

Motivation for this change

A recent change 47f0997 broke a package I maintain (k2pdfopt), which would complain about missing openssl symbols. While a quick fix would just be to link in openssl manually for my package, I believe this is the proper fix to make libmupdf behave more like a normal shared library.

Specifically, libmupdf.so does not have DT_NEEDED references to its
dependencies. Packages which link against libmupdf.so would have to also
manually link against its dependencies as well. This adds unnecessary complexity to packages which depend on it. (See also llpp, jfbview, and zathura-pdf-mupdf)

The first commit includes a patch which ensures that libmupdf.so is built with references to its own dependencies.
An additional commit fixes k2pdfopt, which uses a patched version of mupdf and requires another patch for an older version.

Output of readelf -d libmupdf.so before change:

...
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [/nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib]
...

After change:

...
0x0000000000000001 (NEEDED) Shared library: [libmupdfthird.so]
0x0000000000000001 (NEEDED) Shared library: [libmuthreads.so]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libfreetype.so.6]
0x0000000000000001 (NEEDED) Shared library: [libharfbuzz.so.0]
0x0000000000000001 (NEEDED) Shared library: [libjbig2dec.so.0]
0x0000000000000001 (NEEDED) Shared library: [libjpeg.so.62]
0x0000000000000001 (NEEDED) Shared library: [libopenjp2.so.7]
0x0000000000000001 (NEEDED) Shared library: [libz.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [libmupdf.so]
0x000000000000001d (RUNPATH) Library runpath: [/nix/store/05j0i5jhbp1j0mv36mj08rvn7pk7a3s4-mupdf-1.11/lib:/nix/store/7rda899md2d4q26lxb43yg3cmrgcdr1r-freetype-2.7.1/lib:/nix/store/riicxh9dp1bx90fjcf2yr7gw3wj0x7fm-harfbuzz-1.5.1/lib:/nix/store/gdnvg9j2hr4fh43arflqbzx5a86f7gpc-openjpeg-2.1.2/lib:/nix/store/i8wz3m067dzbs5x2glhxvcg7lvds1942-zlib-1.2.11/lib:/nix/store/bsqid2phn9ad8fyw2d63anzrrxp7a9x4-libjpeg-turbo-1.5.2/lib:/nix/store/0yqg15g97va4xrdzkgjd74nfxgw1c3ij-jbig2dec-0.13/lib:/nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib]
...

I believe llpp, jfbview, and zathura-pdf-mupdf could also be cleaned to not have to refer to mupdf's dependencies. Those packages build anyway, so it's not strictly necessary. Finally, I'm not an expert on compilers or linking so let me know if I'm misunderstanding anything.

CC @abbradar

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Previously, libmupdf.so did not have DT_NEEDED references to its
dependencies. Packages which linked against libmupdf would have to also
manually link against its dependencies as well.
@vyp
Copy link
Member

vyp commented Oct 4, 2017

cc mupdf maintainers: @viric @vrthra @fpletz

@fpletz fpletz requested a review from abbradar October 4, 2017 01:30
Copy link
Member

@abbradar abbradar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for adding a proper way to build shared mupdf!

I can test and merge this tomorrow; if anyone wants to do this sooner please go ahead.

Copy link
Contributor

@orivej orivej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not download mupdf-1.10a-shared_libs-1.patch from IPv6 enabled hosts because www.linuxfromscratch.org advertises an IPv6 address in the DNS but does not respond on it. Could you find another source?

@danielfullmer
Copy link
Contributor Author

@orivej I've changed the url to a mirror which works on ipv6.

Just a note that there are some other derivations which use a linuxfromscratch.org url: id3lib, cyrus-sasl, pycairo, and even chromium.

@orivej orivej merged commit dd9a473 into NixOS:master Oct 5, 2017
@orivej
Copy link
Contributor

orivej commented Oct 5, 2017

Thank you! Maybe I have not downloaded them, or maybe they were already cached by nixos cache servers, or maybe linuxfromscratch IPv6 is only temporarily down.

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 this pull request may close these issues.

None yet

5 participants