Bug 16464

Summary: LIBINTL contains pathes to static libraries
Product: R Reporter: Ingo Feinerer <feinerer>
Component: InstallationAssignee: Brian Ripley <ripley>
Status: CLOSED FIXED    
Severity: normal    
Priority: P5    
Version: R 3.2.1   
Hardware: All   
OS: unix-other   

Description Ingo Feinerer 2015-07-04 06:10:16 UTC
When building R 3.2.1 on OpenBSD (amd64 platform) $LIBINTL contains the pathes
to static libraries (libintl.a and libiconv.a):

From configure:

checking how to link with libintl... /usr/local/lib/libintl.a /usr/local/lib/libiconv.a -lc -Wl,-rpath,/usr/local/lib

From build:

... -L../../lib -lRblas -R/usr/local/lib/R/lib -lgfortran -lm -lquadmath /usr/local/lib/libintl.a /usr/local/lib/libiconv.a -lc -Wl,-rpath,/usr/local/lib -lreadline -lncurses  -lpcre -llzma -lbz2 -lm -liconv -licuuc -licui18n

However, we would like to use the shared libraries (which do exist as
/usr/local/lib/libiconv.so.6.0 and /usr/local/lib/libintl.so.6.0) instead. At
the moment our fix is to use $LTLIBINTL instead but ideally it would be
possible to avoid patching on OpenBSD side.

For those interested in details:
- Original mail on LIBINTL->LTLIBINTL patches
  https://marc.info/?l=openbsd-ports&m=143526271406832&w=2
- Two patches for addressing this problem in the OpenBSD package (search for
  LTLIBINTL):
  http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/math/R/patches/patch-configure?rev=1.25&content-type=text/x-cvsweb-markup
  http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/math/R/patches/patch-src_main_Makefile_in?rev=1.13&content-type=text/x-cvsweb-markup

If you need further details or have questions please do not hesitate to
contact me.

Best regards,
Ingo Feinerer
Comment 1 Brian Ripley 2015-08-12 16:33:04 UTC
This isn't from R, but from m4/gettext.m4 which came from that project.

You'll need to track down why it is preferring static libs.   In particular, what

"checking for GNU gettext in libintl... "

is doing on your platform.  Note that on a generic ELF platform, you need libintl.so to be present, not just libintl.so.6.0, and it would link to the .so form.  That might be what is different ....
Comment 2 Ingo Feinerer 2015-08-16 10:16:59 UTC
(In reply to Brian Ripley from comment #1)
> This isn't from R, but from m4/gettext.m4 which came from that project.
> 
> You'll need to track down why it is preferring static libs.   In particular,
> what
> 
> "checking for GNU gettext in libintl... "
> 
> is doing on your platform.

The problem appears to be an outdated version of m4/gettext-lib.m4 shipped
with R.

When concatenating lib-ld.m4, lib-link.m4, and lib-prefix.m4 from a recent 
upstream gettext and replacing the m4/gettext-lib.m4 in R-devel with it, the 
detection now works correctly:

$ cd gettext-0.19.5.1/gettext-runtime/gnulib-m4
$ ls lib-*
lib-ld.m4  lib-link.m4  lib-prefix.m4
$ cat lib-* > ~/src/R-devel/m4/gettext-lib.m4

After regenerating configure

$ rm configure
$ aclocal -I m4
$ autoconf

now I have

checking how to link with libintl... /usr/local/lib/libintl.so.6.0 /usr/local/lib/libiconv.so.6.0 -lc -Wl,-rpath,/usr/local/lib

which looks fine to me. Moreover, the build itself also works now without
patching:

... -lRblas -R/usr/local/lib/R/lib -lgfortran -lm -lquadmath /usr/local/lib/libintl.so.6.0 /usr/local/lib/libiconv.so.6.0 -lc -Wl,-rpath,/usr/local/lib -lreadline -lncurses  -lpcre -llzma -lbz2 -lz -lm -liconv -licuuc -licui18n

Note: it might be necessary to coordinate an update of m4/gettext-lib.m4 with m4/gettext.m4 in the R sources.
Comment 3 Brian Ripley 2015-08-16 12:50:39 UTC
There are two parts to this, detecting an external libintl (other than libc), and configuration for the included src/extra/intl.

I have updated the first in R-devel, >= r69088.  If this works for you we can port to R-patched.  We do not intend to change the included src/extra/intl.

[All of my systems use the included libintl or have this in libc, so my ability to test is limited.]
Comment 4 Brian Ripley 2015-08-16 15:01:24 UTC
I decided to experment with an external libintl on Solaris.  If I install both static and dynamic versions, both R 3.2.2 and R-devel correctly select the dynamic versions, e.g. in 3.2.2

checking where the gettext function comes from... external libintl
checking how to link with libintl... /usr/local/lib/libintl.so /usr/local/lib/libiconv.so -lc -R/usr/local/lib

So whatever is going on on OpenBSD is not reproducible elsewhere.
Comment 5 Ingo Feinerer 2015-08-16 17:53:55 UTC
R-devel >= r69088 works on OpenBSD and fixes the original problem.

There is no urgent need from my side to port this to R-patched (as we have the necessary patches in place at the moment).

Thank you very much!
Comment 6 Brian Ripley 2015-08-16 20:46:33 UTC
The 3.2.x series will be active for several more months, so we may as well port there.