Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 May 2005 12:12:44 +0200
From:      Rainer Hurling <Rainer.Hurling@nfv.gwdg.de>
To:        Eric van Gyzen <vangyzen@stat.duke.edu>
Cc:        ports@FreeBSD.org
Subject:   Re: FreeBSD Port: R-2.0.1
Message-ID:  <4291AC9C.3080607@nfv.gwdg.de>
In-Reply-To: <200505221600.15092.vangyzen@stat.duke.edu>
References:  <4290E143.6010603@mail.tele.dk> <200505221600.15092.vangyzen@stat.duke.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Eric,

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);
#endif


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:
   ./configure
   ./src/library/grDevice/src/devPS.c
   ./src/main/errors.c
   ./src/main/gram.c
   ./src/main/gram.y
   ./src/main/pcre.c
   ./src/main/vfonts.c
   ./src/main/util.c

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.

Regards,
Rainer Hurling

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4291AC9C.3080607>