Issue #7307 has been updated by knu (Akinori MUSHA).


shyouhei (Shyouhei Urabe) wrote:
> knu (Akinori MUSHA) wrote:
> > -ansi ???å¤??????¨ã???????®ã?¯ã?§ã???????°ã????????????????§ã????­ã??
> > æ½???¨ã????°ã?®ã????¶ã????ºã?????ç§»æ????§ã?®ä?????³ã?¼ã????®æ··??¥ã????²ã??????????ªå?¹æ????????å¾??????¦ã???????®ã?§ã??????????????
> 
> ????????§ã??????????¨ã?®å??æ©???«é?¢ã????¦ã?¯ä??è¨????????????§ã?????????????
> http://qa.atmarkit.co.jp/q/2159

??ªã????»ã?©ã???????£ã???????¯ã?³ã?³ã????¤ã?«ã?§ã????¦ã???????®ã?§ã????·ä???????«å?°ã????¾ã?§ã?¯ã???????????

??ªã???????????????????¨é????§ã??-pedantic???ä»?????????®ã??å®???ªã????¨æ???????¾ã????????å®???¹æ?§ã?®ã?»ã?©ã?¯å??????????¾ã????????
----------------------------------------
Bug #7307: gcc -ansi vs. alloca (undefined reference to `alloca')
https://bugs.ruby-lang.org/issues/7307#change-32668

Author: knu (Akinori MUSHA)
Status: Closed
Priority: Normal
Assignee: 
Category: build
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-08) [x86_64-openbsd]


Ruby 2.0.0????????? CFLAGS ??? -ansi ???ï¼???µã????¼ã?????????????°ï??ä»????????????
??ªã????¾ã???????????????????«ã???????? gcc ??? builtin alloca ??«ä??å­??????¦ã?????
libc ??? alloca(3) ???????????ªã????°å???????·ä???????«ã??OpenBSDï¼?????????³ã????????
???NetBSD??? mips, powerpc, powerpc64, sparc, sparc64 ç­?ï¼???§æ¬¡??®ã?????
??ªã?ªã?³ã?¯ã?¨ã?©ã?¼ã????ºç???????¾ã?????

linking miniruby
addr2line.o(.text+0x9e7): In function `follow_debuglink':
/home/knu/src/ruby-trunk-vanilla/addr2line.c:424: warning: strcpy() is almost always misused, please use strlcpy()
regerror.o(.text+0x499): In function `onig_vsnprintf_with_pattern':
/home/knu/src/ruby-trunk-vanilla/regerror.c:334: warning: strcat() is almost always misused, please use strlcat()
regerror.o(.text+0x55e):/home/knu/src/ruby-trunk-vanilla/regerror.c:197: warning: sprintf() is often misused, please use snprintf()
dmyencoding.o(.text+0x120e): In function `set_encoding_const':
/home/knu/src/ruby-trunk-vanilla/encoding.c:1535: undefined reference to `alloca'
bignum.o(.text+0xbfea): In function `rb_str_to_inum':
/home/knu/src/ruby-trunk-vanilla/bignum.c:791: undefined reference to `alloca'
object.o(.text+0x11c2): In function `rb_str_to_dbl':
/home/knu/src/ruby-trunk-vanilla/object.c:2565: undefined reference to `alloca'
parse.o(.text+0x1e24): In function `parser_yyerror':
/home/knu/src/ruby-trunk-vanilla/build.unknown.openbsd-amd64/parse.y:5221: undefined reference to `alloca'
parse.o(.text+0xb2c8): In function `parser_tokadd_string':
/home/knu/src/ruby-trunk-vanilla/build.unknown.openbsd-amd64/parse.y:6072: undefined reference to `alloca'
parse.o(.text+0xb2fb):/home/knu/src/ruby-trunk-vanilla/build.unknown.openbsd-amd64/parse.y:6085: more undefined references to `alloca' follow
collect2: ld returned 1 exit status
*** Error code 1

Stop in /home/knu/src/ruby-trunk-vanilla/build.unknown.openbsd-amd64 (line 180 of Makefile).


??ªã??ï¼?configure ??¯æ?????????????®ã?«ï????????????????®èª¬???¯ä»¥ä¸???®é???????§ã?????

1. autoconf ??? AC_FUNC_ALLOCA ??¯æ¬¡??®ã???????ªã?³ã?¼ã????«ã??????????¹ã????«å?????
???????????®ã?§ã?? gcc ???使ã??????????? alloca ??? __builtin_alloca ??«ç½®??????
???????®ã?? configure ??¯æ???????????

#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef _MSC_VER
#  include <malloc.h>
#  define alloca _alloca
# else
#  ifdef HAVE_ALLOCA_H
#   include <alloca.h>
#  else
#   ifdef _AIX
 #pragma alloca
#   else
#    ifndef alloca /* predefined by HP cc +Olibcalls */
void *alloca (size_t);
#    endif
#   endif
#  endif
# endif
#endif

2. gcc ??? -ansi ???ä»?????????? alloca ??????ä¾??????ªã???ªã??
ï¼?__builtin_alloca ??¯å¸¸??«ã?????ï¼?

3. ruby ??®ã?½ã?¼ã?¹ã????ªã?¼ã?§ã?¯ï???????¯ã?­ã??????????¦ï??åº???? alloca ???使ã???????
????????????ä¸?è¨?1??®ã???????? alloca ??®ã?±ã?¢ï??ç½®æ??ï¼????è¡???£ã?¦ã???????®ã?? gc.c
??? #include "eval_intern.h" ?????¦ã??????????®ã?®ã??

4. ??????????????ºæ?¬ç????«ã????¹ã?¦ã?®ã????¡ã?¤ã?«ã?? -ansi ä»??????§ã????«ã?????????????®ã?§ã??
addr2line.o, regerror.o, encoding.o ç­??????? alloca ??¸ã?®å????§ã???????¾ã??
??¦ã????¾ã????? libc ??? alloca ?????ªã????°å????§ã?¯ã?ªã?³ã?¯ã?¨ã?©ã?¼ã?¨ã?ªã??


解決ç­???¯ã?? ruby/ruby.h ??? alloca ??¢é?£é?¨ã?? gc.c ??ªã?©ã?«ã??????????????
gcc 対å???????«ã??å®???¨ã?ªã????®ã?«ã??????????¨ã?§ã?????

ä¸???®ã?????????????©ç?¨ã?????以ä????®ç?°å????? make test ???????????¾ã????????

- OpenBSD/amd64 5.2-RELEASE (GCC 4.2.1) - libc has no alloca
- FreeBSD/amd64 9.1-PRERELEASE (GCC 4.2.1)
- FreeBSD/amd64 9.1-PRERELEASE (clang 3.1)
- Mac OS X 10.8.2 (Apple clang 4.1)

?????ªã???????°ã?³ã?????????????¾ã?????


-- 
http://bugs.ruby-lang.org/