ruby-changes:25514
From: knu <ko1@a...>
Date: Fri, 9 Nov 2012 12:34:22 +0900 (JST)
Subject: [ruby-changes:25514] knu:r37571 (trunk): Fix build when gcc is used and the platform's libc lacks alloca().
knu 2012-11-09 12:34:08 +0900 (Fri, 09 Nov 2012) New Revision: 37571 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37571 Log: Fix build when gcc is used and the platform's libc lacks alloca(). * include/ruby/ruby.h (alloca), eval_intern.h (alloca), gc.c (alloca): Make alloca() globally available by moving the ultimate ifdef's to ruby/ruby.h. Gcc hides its builtin alloca() when compiling with -ansi, and linking thus fails on platforms that lack their own alloca() implementation in libc, which include OpenBSD and some ports of NetBSD. We use alloca() everywhere including from within third party C extentions, so alloca() must be made globally available. [Bug #7307] * addr2line.c (alloca): Replace the alloca() part with the ultimate ifdef's. [Bug #7307] Modified files: trunk/ChangeLog trunk/addr2line.c trunk/eval_intern.h trunk/gc.c trunk/include/ruby/ruby.h Index: eval_intern.h =================================================================== --- eval_intern.h (revision 37570) +++ eval_intern.h (revision 37571) @@ -31,27 +31,6 @@ #include <crt_externs.h> #endif -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -# ifndef atarist -# ifndef alloca -# define alloca __builtin_alloca -# endif -# endif /* atarist */ -#else -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX -#pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca(); -# endif -# endif /* AIX */ -# endif /* HAVE_ALLOCA_H */ -#endif /* __GNUC__ */ - #ifndef HAVE_STRING_H char *strrchr(const char *, const char); #endif Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 37570) +++ include/ruby/ruby.h (revision 37571) @@ -73,13 +73,26 @@ #pragma GCC visibility push(default) #endif -#if defined(HAVE_ALLOCA_H) -#include <alloca.h> +/* Make alloca work the best possible way. */ +#ifdef __GNUC__ +# ifndef atarist +# ifndef alloca +# define alloca __builtin_alloca +# endif +# endif /* atarist */ #else +# ifdef HAVE_ALLOCA_H +# include <alloca.h> +# else # ifdef _AIX #pragma alloca -# endif -#endif +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca(); +# endif +# endif /* AIX */ +# endif /* HAVE_ALLOCA_H */ +#endif /* __GNUC__ */ #if defined HAVE_UINTPTR_T && 0 typedef uintptr_t VALUE; Index: ChangeLog =================================================================== --- ChangeLog (revision 37570) +++ ChangeLog (revision 37571) @@ -1,3 +1,17 @@ +Fri Nov 9 12:07:06 2012 Akinori MUSHA <knu@i...> + + * include/ruby/ruby.h (alloca), eval_intern.h (alloca), gc.c + (alloca): Make alloca() globally available by moving the + ultimate ifdef's to ruby/ruby.h. Gcc hides its builtin alloca() + when compiling with -ansi, and linking thus fails on platforms + that lack their own alloca() implementation in libc, which + include OpenBSD and some ports of NetBSD. We use alloca() + everywhere including from within third party C extentions, so + alloca() must be made globally available. [Bug #7307] + + * addr2line.c (alloca): Replace the alloca() part with the + ultimate ifdef's. [Bug #7307] + Fri Nov 9 09:30:00 2012 Zachary Scott <zachary@z...> * io.c (IO#new): Index: addr2line.c =================================================================== --- addr2line.c (revision 37570) +++ addr2line.c (revision 37571) @@ -32,9 +32,26 @@ #include <sys/stat.h> #include <unistd.h> -#if defined(HAVE_ALLOCA_H) -#include <alloca.h> -#endif +/* Make alloca work the best possible way. */ +#ifdef __GNUC__ +# ifndef atarist +# ifndef alloca +# define alloca __builtin_alloca +# endif +# endif /* atarist */ +#else +# ifdef HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX +#pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca(); +# endif +# endif /* AIX */ +# endif /* HAVE_ALLOCA_H */ +#endif /* __GNUC__ */ #ifdef HAVE_DL_ITERATE_PHDR # ifndef _GNU_SOURCE Index: gc.c =================================================================== --- gc.c (revision 37570) +++ gc.c (revision 37571) @@ -65,27 +65,6 @@ #define rb_setjmp(env) RUBY_SETJMP(env) #define rb_jmp_buf rb_jmpbuf_t -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -# ifndef atarist -# ifndef alloca -# define alloca __builtin_alloca -# endif -# endif /* atarist */ -#else -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca (); -# endif -# endif /* AIX */ -# endif /* HAVE_ALLOCA_H */ -#endif /* __GNUC__ */ - #ifndef GC_MALLOC_LIMIT #define GC_MALLOC_LIMIT 8000000 #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/