Bug 701439

Summary: [configure] fix static build with libidn
Product: Ghostscript Reporter: bernd.kuhls
Component: Build ProcessAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 9.27   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: fix static build with libidn & libiconv
fix static build with libidn & libiconv

Description bernd.kuhls 2019-08-17 18:38:38 UTC
Created attachment 18008 [details]
fix static build with libidn & libiconv

Statically linking bin/gs with libidn support when libidn itself is linked to libiconv fails:

/home/buildroot/autobuild/run/instance-1/output/host/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libidn.a(striconv.o): in function `mem_cd_iconv':
(.text+0x50): undefined reference to `libiconv'

This was detected by buildroot autobuilders:
http://autobuild.buildroot.net/results/45a/45a94a494eb2b719ac338d2e734753b11a4a0144/

The cause is a wrong linking order in obj/ldt.tr, -liconv needs to be placed after -lidn.

To fix the problem use pkgconf to detect the libraries needed to link libidn, see attached patch.

Certainly this patch will not be included upstream due to the use of BUILD_PKGCONFIG instead of PKGCONFIG, but yes, the error occured when cross-compiling. I regard this patch as RFC and kindly ask devs more familiar with the ghostscript build system to come up with a proper fix.

I stopped debugging the build process after I found
http://git.ghostscript.com/?p=ghostpdl.git;a=blob;f=configure.ac;h=c5ddefe7dfc7853ad68ea2ba89063d4674daeece;hb=HEAD#l205 ;)
Comment 1 bernd.kuhls 2019-08-18 10:07:20 UTC
Created attachment 18010 [details]
fix static build with libidn & libiconv

It was pointed out to me that the BUILD_PKGCONFIG vs. PKGCONFIG problem was buildroot-specific: http://lists.busybox.net/pipermail/buildroot/2019-August/257315.html

Attached you will find an updated version of the patch using PKGCONFIG.
Comment 2 Chris Liddell (chrisl) 2019-08-20 17:07:56 UTC
Just so you know, I'm not ignoring the issues you've raised, but I'm busy with the 9.28 release right now, so I'll get to them when I can.

As mentioned in the comment about BUILD_PKGCONFIG, I do think it's a bit hacky, but it was the best idea I could come up with. I'm open to suggestions.

FWIW, at first glance, your patch looks fine, but I'll want to spend some time testing before it goes into our canonical source repo.
Comment 3 Chris Liddell (chrisl) 2019-11-22 12:18:41 UTC
Applied:

https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=64a35dc73ee8


Thanks!