FreeBSD Port: R-2.0.1

Rainer Hurling Rainer.Hurling at
Mon May 23 03:12:47 PDT 2005


at the last weekend I found a quick dirty workaround for our compilation 
problem. Before making the port (thank you for your patch) I contacted 
Prof Brian Ripley from R Core Team for a more general solution.

Eric van Gyzen wrote:
> Klaus F. Østergaard wrote:
>>When do you plan to upgrade R to the current 2.1.0?
> When I can coerce it into compilation:
> errors.o(.text+0x154b): In function `do_gettext':
>   /tmp/R-2.1.0/src/main/errors.c:779:
>   undefined reference to `__builtin_alloca'
> ...
> errors.o(.text+0x274d):/tmp/R-2.1.0/src/main/errors.c:829:
>   more undefined references to `__builtin_alloca' follow
> I gladly welcome suggestions.  :-/

This is what I wrote to Prof Brian Ripley:

FreeBSD has no system-wide 'alloca.h'. Instead it uses a routine in 
'stdlib.h' for this. Here is a copy of the section in /usr/include/stdlib.h:

  * The alloca() function can't be implemented in C, and on some
  * platforms it can't be implemented at all as a callable function.
  * The GNU C compiler provides a built-in alloca() which we can use;
  * in all other cases, provide a prototype, mainly to pacify various
  * incarnations of lint.  On platforms where alloca() is not in libc,
  * programs which use it will fail to link when compiled with non-GNU
  * compilers.
#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
#undef  alloca    /* some GNU bits try to get cute and define this on 
their own */
#define alloca(sz) __builtin_alloca(sz)
#elif defined(lint)
void    *alloca(size_t);

Obviously it should be possible to use 'stdlib.h' instead of 'alloca.h'.
So I replaced all code entries from 'alloca.h' to 'stdlib.h'.

The following files where affected in R-2.1.0:

After the changes, I had been able to build the source tree and to 
install it. It works like a charm :-)

Now I am looking for somebody, who can adapt the configure scripts of R 
to change the behaviour for FreeBSD systems to work with 'stdlib.h' 
instead of 'alloca.h'.

Yet I have no answer from Ripley.

Rainer Hurling

P.S.: With your patch for the port I run into the same problem with 
alloca.h :-(

More information about the freebsd-ports mailing list