From david.kirkby at onetel.net  Sat Jun  7 13:20:11 2008
From: david.kirkby at onetel.net (Dr. David Kirkby)
Date: Sat, 07 Jun 2008 12:20:11 +0100
Subject: [Rd] Fail to call AC_CACHE_CHECK on R 2.7.0 for Solaris
Message-ID: <484A6EEB.10704@onetel.net>

I've tried to build R 2.6.1 and 2.7.0 on Solaris 10 update 4 (SPARC) and 
both configure ok, so you might ask why I suspect there is a problem.

I tried to build the maths program Sage

http://www.sagemath.org/

version 3.0.3alpha1. Sage fails when building R 2.6.1 - (Sage includes R 
in the package). The relavant bit of Sage, which is only using an 
unmodified R configure script is:

checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking for iconv... in libiconv
checking whether iconv accepts "UTF-8", "latin1" and "UCS-*"... no
checking for iconvlist... yes
configure: error: --with-iconv=yes (default) and a suitable iconv is
not available

Looking at the Sage problem in detail, I believe I know the reason and 
are somewhat surprised R builds at all on Solaris. I think this problem 
is an R problem, not a Sage problem.

For some reason the R "configure" script was not happy with my readline, 
but after trying to configure with the configure option

--with-readline=no

The R 2.6.1 source configured ok. I did not bother running 'make' but 
there were
no failures when the configure script was run.  I then repeated this
with the latest version of R (2.7.0) and got similar results.

Looking at the file configure.ac in R (both 2.6.1 and 2.7.0), I see:

## iconv headers and function.
if test "${use_iconv}" = yes; then
  R_ICONV
  if test "$r_cv_iconv_latin1" != yes; then
    AC_MSG_ERROR([--with-iconv=yes (default) and a suitable iconv is
not available])
  fi
else
    AC_MSG_WARN([--with-iconv=no is deprecated and will be withdrawn
shortly])
fi

Clearly the value of r_cv_iconv_latin1 determines if this test passes
or fails and so whether the error message that I get is printed or not.

The variable r_cv_iconv_latin1 is never set directly in configure, but
by in a Macro called AC_CACHE_CHECK in the file m4/R.m4.

Looking in that macro r4/R.m4 we see:

  AC_CACHE_CHECK([whether iconv accepts "UTF-8", "latin1" and "UCS-
*"],
  [r_cv_iconv_latin1],

So it would appear to me that AC_CACHE_CHECK needs to be run in order
that r_cv_iconv_latin will be set properly. But looking at
configure.ac, I think AC_CACHE_CHECK is only called on Linux, and not
on Solaris. Obviously this could explain why this bit of Sage works on
Linux, but not Solaris.

## check for visible __libc_stack_end on Linux
case "${host_os}" in
  linux*)
    AC_CACHE_CHECK([for visible __lib_stack_end],
    [r_cv_libc_stack_end],
    [AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include "confdefs.h"
#include <stdlib.h>
extern void * __libc_stack_end;

So it seems to me this will never work, as the the relevant macro is
not run on Solaris. It begs the obvious question why does this work
when I download the source of R. I can't see the answer to that one,
but there are reports of R failing to build on Solaris, but for me at
least, it configures ok.



[Rd] Fail to call AC_CACHE_CHECK on R 2.7.0 for Solaris
Dr. David Kirkby