Bug 192397 - [patch] graphics/mupdf add -fPic option
[patch] graphics/mupdf add -fPic option
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Latest
Any Any
: --- Affects Only Me
Assigned To: Tijl Coosemans
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-05 09:56 UTC by Zsolt Udvari
Modified: 2014-08-05 19:07 UTC (History)
1 user (show)

See Also:


Attachments
The patch (683 bytes, patch)
2014-08-05 09:56 UTC, Zsolt Udvari
no flags Details | Diff
preliminary patch (3.04 KB, patch)
2014-08-05 12:56 UTC, Tijl Coosemans
no flags Details | Diff
proposed patch (3.24 KB, patch)
2014-08-05 15:26 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zsolt Udvari 2014-08-05 09:56:34 UTC
Created attachment 145387 [details]
The patch

* Added -fPIC option to XCFLAGS
* PORTREVISION bump
Comment 1 Tijl Coosemans freebsd_committer 2014-08-05 10:12:00 UTC
Why do you need this?  The package builds fine without.
Comment 2 Zsolt Udvari 2014-08-05 10:30:16 UTC
(In reply to Tijl Coosemans from comment #1)
> Why do you need this?  The package builds fine without.

I'm working on graphics/zathura-pdf-mupdf port ( http://pwmt.org/projects/zathura-pdf-mupdf/ ) and doesn't build it without -fPIC (and prints an error message about rebuilding with -fPIC). With -fPIC builds fine.
Comment 3 Zsolt Udvari 2014-08-05 11:23:52 UTC
(In reply to Zsolt Udvari from comment #2)
> (In reply to Tijl Coosemans from comment #1)
> > Why do you need this?  The package builds fine without.
> 
> I'm working on graphics/zathura-pdf-mupdf port (
> http://pwmt.org/projects/zathura-pdf-mupdf/ ) and doesn't build it without
> -fPIC (and prints an error message about rebuilding with -fPIC). With -fPIC
> builds fine.

Check this log: https://redports.org/~uzsolt/20140805110937-15588-230356/zathura-pdf-mupdf-0.2.6.log :
/usr/bin/ld: /usr/local/lib/libmupdf.a(list-device.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libmupdf.a: could not read symbols: Bad value
Comment 4 Baptiste Daroussin freebsd_committer 2014-08-05 11:52:11 UTC
zathura is trying to statically a shared object to libmupdf.a which case would expect PIC object in libmupdf.a on 64bits arches.

but PIC object in a .a can have some unwanted side effects this patch is for sure not the right solution
Comment 5 Baptiste Daroussin freebsd_committer 2014-08-05 12:00:37 UTC
What you probably want to do is create 2 .a:
libmupdf.a and libmupdf_shared.a the second built with -fPIC and make zathura use the second
Comment 6 Zsolt Udvari 2014-08-05 12:02:47 UTC
(In reply to Baptiste Daroussin from comment #5)
> What you probably want to do is create 2 .a:
> libmupdf.a and libmupdf_shared.a the second built with -fPIC and make
> zathura use the second

Okay, I'll try it. Thanks for information and suggestion.
Comment 7 Tijl Coosemans freebsd_committer 2014-08-05 12:56:17 UTC
Created attachment 145393 [details]
preliminary patch

Here's a preliminary patch.  The redports builds are still running.
Comment 8 Zsolt Udvari 2014-08-05 13:12:27 UTC
(In reply to Tijl Coosemans from comment #7)
> Created attachment 145393 [details]
> preliminary patch
> 
> Here's a preliminary patch.  The redports builds are still running.

Thank you. I didn't create similar thing (two versions of lib) in FreeBSD so the idea is very useful for me.
Comment 9 Tijl Coosemans freebsd_committer 2014-08-05 15:26:38 UTC
Created attachment 145397 [details]
proposed patch

This patch actually builds.
Comment 10 Zsolt Udvari 2014-08-05 18:01:35 UTC
(In reply to Tijl Coosemans from comment #9)
> Created attachment 145397 [details]
> proposed patch
> 
> This patch actually builds.

This patch builds well but zathura can't run:

error: could not load plugin /usr/local/lib/zathura/pdf.so (/usr/local/lib/zathura/pdf.so: Undefined symbol "fz_identity")

libmupdf_pic.a doesn't contain "fz_identity" but libmupdf.a contains:
$ grep fz_identity /usr/local/lib/libmupdf*
Binary file /usr/local/lib/libmupdf.a matches
Comment 11 Zsolt Udvari 2014-08-05 18:22:29 UTC
(In reply to Zsolt Udvari from comment #10)
> error: could not load plugin /usr/local/lib/zathura/pdf.so
> (/usr/local/lib/zathura/pdf.so: Undefined symbol "fz_identity")
> 
> libmupdf_pic.a doesn't contain "fz_identity" but libmupdf.a contains:
> $ grep fz_identity /usr/local/lib/libmupdf*
> Binary file /usr/local/lib/libmupdf.a matches
When I add "XCFLAGS=-fPIC" to MAKE_ARGS (globally) I can build and run zathura-pdf-mupdf well. But I've notice some (for me) interesting thing:

$ ls -l /usr/local/lib/libmupdf*
-rwxr-xr-x  1 root  wheel  10020966 aug  5 20:11 /usr/local/lib/libmupdf.a
-r--r--r--  1 root  wheel   9026504 aug  5 20:11 /usr/local/lib/libmupdf_pic.a

I think libmupdf.a and libmupdf_pic.a should same but their size are different.
Comment 12 Zsolt Udvari 2014-08-05 18:39:11 UTC
(In reply to Tijl Coosemans from comment #9)
> Created attachment 145397 [details]
> proposed patch
> 
> This patch actually builds.

Tijl: in section 'post-install' should use ${INSTALL_DATA} instead of ${INSTALL_LIB} ( https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/install.html ). With ${INSTALL_DATA} works well, zathura-pdf-mupdf too. So I think with this modification can apply your patch.
Comment 13 commit-hook freebsd_committer 2014-08-05 19:06:19 UTC
A commit references this bug:

Author: tijl
Date: Tue Aug  5 19:05:34 UTC 2014
New revision: 364135
URL: http://svnweb.freebsd.org/changeset/ports/364135

Log:
  - Add dependency on libcurl
  - Remove a patch and simplify the Makefile a bit
  - Create and install libmupdf_pic.a which can be linked into shared
    libraries such as the zathura-pdf-mupdf plugin

  PR:		192397
  Approved by:	Zsolt Udvari <udvzsolt@gmail.com> (maintainer)

Changes:
  head/graphics/mupdf/Makefile
  head/graphics/mupdf/files/patch-Makefile
  head/graphics/mupdf/pkg-plist
Comment 14 Tijl Coosemans freebsd_committer 2014-08-05 19:07:44 UTC
Committed in r364135.