From: Jon Forums Date: 2012-02-19T03:23:53+09:00 Subject: [ruby-core:42733] [ruby-trunk - Bug #5676] miniruby linking error: undefined reference to ___stack_chk_guard Issue #5676 has been updated by Jon Forums. I've recently adopted FreeBSD 9.0 (in my "A New Year, A New OS" resolution) and have apparently run into this problem on trunk when trying to build with the non-default gcc-4.6.2 package. The issue goes away when I remove -fstack-protector from XCFLAGS. As I'm new to FreeBSD so this may simply be my misconfiguration, but has anyone successfully built trunk with the gcc-4.6.2 package? BTW, why isn't `TRY_LD_FLAGS` also used in https://github.com/ruby/ruby/blob/trunk/configure.in#L506-508 (I tried it but it doesn't solve the failure) == BUILD FAILURE === pkg_info | grep gcc gcc-4.6.2 GNU Compiler Collection 4.6 git log -3 --oneline e0f059a * 2012-02-18 ace4630 * lib/fileutils.rb: refactored FileUtil methods to use the `define_command` API... 92e7c2d * ext/dbm/extconf.rb: remove dbm. gcc46 --version gcc46 (FreeBSD Ports Collection) 4.6.2 ../configure --enable-shared --disable-install-doc --with-gcc=gcc46 ... make ... linking miniruby dmyencoding.o: In function `set_encoding_const': /home/jon/rubydev/ruby-git/build/../encoding.c:1525: undefined reference to `__stack_chk_fail_local' bignum.o: In function `rb_str_to_inum': /home/jon/rubydev/ruby-git/build/../bignum.c:790: undefined reference to `__stack_chk_fail_local' dir.o: In function `dir_read': /home/jon/rubydev/ruby-git/build/../dir.c:586: undefined reference to `__stack_chk_fail_local' dir.o: In function `dir_each': /home/jon/rubydev/ruby-git/build/../dir.c:623: undefined reference to `__stack_chk_fail_local' dir.o: In function `glob_helper': /home/jon/rubydev/ruby-git/build/../dir.c:1475: undefined reference to `__stack_chk_fail_local' io.o:/home/jon/rubydev/ruby-git/build/../io.c:9639: more undefined references to `__stack_chk_fail_local' follow /usr/local/bin/ld: miniruby: hidden symbol `__stack_chk_fail_local' isn't defined /usr/local/bin/ld: final link failed: Bad value collect2: ld returned 1 exit status *** Error code 1 ---------------------------------------- Bug #5676: miniruby linking error: undefined reference to ___stack_chk_guard https://bugs.ruby-lang.org/issues/5676 Author: Martin D��rst Status: Closed Priority: Normal Assignee: Motohiro KOSAKI Category: build Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2011-11-27 trunk 33861) [i386-cygwin] I get what I think is a linking error when linking miniruby. Below is a (shortened) copy of the output I get. This is on a clean checkout of trunk (using Ruby 1.8.7 as baseruby). duerst@jougashima /cygdrive/c/Data/ruby-public $ make CC = gcc LD = ld LDSHARED = gcc -shared -s CFLAGS = -O3 -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -DRUBY_EXPORT CPPFLAGS = -I. -I.ext/include/i386-cygwin -I./include -I. DLDFLAGS = -Wl,--enable-auto-image-base,--enable-auto-import -Wl,--out-implib=libruby191.dll.a cygruby191.def -Xlinker --no-undefined SOLIBS = cygruby191.res.o -lpthread -lrt -ldl -lcrypt linking miniruby.exe dmyencoding.o: In function `set_encoding_const': /cygdrive/c/Data/ruby-public/encoding.c:1473: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/encoding.c:1520: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/encoding.c:1520: undefined reference to `___stack_chk_fail' bignum.o: In function `rb_str_to_inum': /cygdrive/c/Data/ruby-public/bignum.c:763: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/bignum.c:790: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/bignum.c:790: undefined reference to `___stack_chk_fail' dir.o: In function `dir_read': /cygdrive/c/Data/ruby-public/dir.c:569: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/dir.c:586: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/dir.c:586: undefined reference to `___stack_chk_fail' [... many more like these ...] vm_dump.o: In function `control_frame_dump': /cygdrive/c/Data/ruby-public/vm_dump.c:27: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/vm_dump.c:148: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/vm_dump.c:148: undefined reference to `___stack_chk_fail' cont.o: In function `cont_restore_0': /cygdrive/c/Data/ruby-public/cont.c:733: undefined reference to `___stack_chk_guard' unicode.o: In function `onigenc_unicode_property_name_to_ctype': /cygdrive/c/Data/ruby-public/./enc/unicode.c:2087: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/./enc/unicode.c:2114: undefined reference to `___stack_chk_guard' /cygdrive/c/Data/ruby-public/./enc/unicode.c:2114: undefined reference to `___stack_chk_fail' collect2: ld returned 1 exit status make: *** [miniruby.exe] Error 1 duerst@jougashima /cygdrive/c/Data/ruby-public $ -- http://bugs.ruby-lang.org/