[LLVMdev] CWriter outputs non-portable use of alloca.h

John Criswell criswell at cs.uiuc.edu
Mon Jun 16 17:34:01 PDT 2003


Brian R. Gaeke wrote:
> Hi,
> 
> My recent refactoring of the (machine-dependent) use of <alloca.h>
> does not attempt to change CWriter's behavior of emitting a #include
> for <alloca.h>. FreeBSD does not have <alloca.h>, so this would cause
> trouble.
> 
> We could change it to emit an #ifndef __FreeBSD__...#endif around
> #include <alloca.h>.  I suggest this because, I'm guessing, whether or
> not the CWriter outputs pretty code is not of utmost importance.
> 
> Any counter-suggestions?

	Well, this should be fixed in the recent autoconf stuff that I've got 
working locally in my working directory.  I'd suggest using the 
HAVE_ALLOCA_H macro and plugging its definition into Makefile.Linux and 
Makefile.Sun until I check autoconf in.

	What would be better yet is to modify the code so that it does not use 
alloca() at all.  There seems to be little reason to use it aside from 
convenience (but perhaps I have missed something).  Using normal 
allocation routines (malloc, new) would be more portable anyway.  I 
considered doing that just last week, but decided to leave it for now. 
If you're familiar with that code, I'd recommend changing it.

	Every man page for alloca I've seen (Linux, Solaris, NetBSD) 
essentially reads "alloca() is cool, but don't use it!!"	:)

-- John T.

> 
> -Brian
> 



-- 
*********************************************************************
* John T. Criswell                         Email: criswell at uiuc.edu *
*********************************************************************





More information about the llvm-dev mailing list