From: t_nissie@... Date: 2016-01-14T03:03:26+00:00 Subject: [ruby-core:72852] [Ruby trunk - Bug #11979] gcc-6 fails to optimize regcomp.c:compile_length_quantifier_node() Issue #11979 has been updated by Takeshi Nishimatsu. Subject changed from gcc-6 fails to optimize regcomp.c to gcc-6 fails to optimize regcomp.c:compile_length_quantifier_node() gcc-6 fails to optimize ruby-2.3.0/regcomp.c:compile_length_quantifier_node() and cannot build the ruby. Even the -O1 optimization option fails. Adding `__attribute__((optimize("O0")))` before the function can evade this issue. I confirmed this issue both on GNU/Linux and Mac OS X. Please note that there are two compile_length_quantifier_node() in ruby-2.3.0/regcomp.c. gcc-6 fails to optimize second one at the line 985. gcc-4.9.2 could build ruby-2.3.0. /usr/bin/gcc of Mac OS X (Apple LLVM version 7.0.2 (clang-700.1.81)) could build ruby-2.3.0, too. I will report this issue to https://gcc.gnu.org/bugzilla/ tomorrow. ~~~ $ wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.xz $ shasum ruby-2.3.0.tar.xz | grep 96e620e38af351c8da63e40cfe217ec79f912ba1 $ tar xf ruby-2.3.0.tar.xz $ mkdir ruby-2.3.0/build_on_MacOSX $ cd ruby-2.3.0/build_on_MacOSX $ /usr/local/bin/gcc --version gcc (GCC) 6.0.0 20151115 (experimental) $ ../configure CC=/usr/local/bin/gcc $ make -j4 : generating encdb.h ../template/encdb.h.tmpl:63:in `block (4 levels) in
': x_emoji.h:8: ENC_REPLICATE: UTF-8 is not defined yet. (replica UTF8-DoCoMo) (ArgumentError) : $ sed -e '984 a\ > __attribute__((optimize("O0")))' ../regcomp.c > regcomp.c $ diff -u ../regcomp.c . --- ../regcomp.c 2015-12-09 16:30:44.000000000 +0900 +++ ./regcomp.c 2016-01-14 08:21:52.798816125 +0900 @@ -982,6 +982,7 @@ #else /* USE_COMBINATION_EXPLOSION_CHECK */ static int +__attribute__((optimize("O0"))) compile_length_quantifier_node(QtfrNode* qn, regex_t* reg) { int len, mod_tlen; $ make V=1 encdb.h : ./miniruby -I../lib -I. -I.ext/common ../tool/generic_erb.rb -c -o encdb.h ../template/encdb.h.tmpl ../enc enc encdb.h updated $ make -j4 $ make check : # Running tests: Finished tests in 453.556568s, 34.7388 tests/s, 4931.0101 assertions/s. 15756 tests, 2236492 assertions, 0 failures, 0 errors, 53 skips ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15] check succeeded $ ~~~ ---------------------------------------- Bug #11979: gcc-6 fails to optimize regcomp.c:compile_length_quantifier_node() https://bugs.ruby-lang.org/issues/11979#change-56087 * Author: Takeshi Nishimatsu * Status: Open * Priority: Normal * Assignee: * ruby -v: 2.2.4, 2.3.0 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- This may be a GCC version specific issue. gcc-6, an experimental snapshot from http://ftp.tsukuba.wide.ad.jp/software/gcc/snapshots/6-20160110/ , fails to compile ruby-2.2.4 and ruby-2.3.0 with an error of **template/encdb.h.tmpl:63:in `block (4 levels) in
': x_emoji.h:8: ENC_REPLICATE: UTF-8 is not defined yet. (replica UTF8-DoCoMo) (ArgumentError)** . I confirmed it both on Linux and Mac OS X. gcc-4.9.2 could compile ruby-2.3.0. /usr/bin/gcc of Mac OS X (Apple LLVM version 7.0.2 (clang-700.1.81)) could compile ruby-2.3.0, too. Maybe, I should report it to https://gcc.gnu.org/bugzilla/ . Could you tell me how to make small reproducible code? (Or, please report it to the bugzilla with small code ;-) Compile log: ~~~ $ uname -a Linux emerald01 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 21:19:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux $ tar xf ruby-2.3.0.tar.xz $ mkdir ruby-2.3.0/Linux-x86_64-gcc-6-20160110-emerald01 $ cd ruby-2.3.0/Linux-x86_64-gcc-6-20160110-emerald01 $ pwd $ ../configure $ make -j16 $ make $ make V=1 CC = gcc LD = ld LDSHARED = gcc -shared CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -std=iso9899:1999 XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE CPPFLAGS = -I. -I.ext/include/x86_64-linux -I../include -I.. DLDFLAGS = -fstack-protector -pie SOLIBS = -lgmp Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --enable-languages=c,c++,fortran,go,objc --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib64 --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib64 --with-mpc-include=/usr/local/include --with-mpc-lib=/usr/local/lib64 Thread model: posix gcc version 6.0.0 20160110 (experimental) (GCC) ./miniruby -I../lib -I. -I.ext/common ../enc/make_encmake.rb --builtin-encs="enc/ascii.o enc/us_ascii.o enc/unicode.o enc/utf_8.o" --builtin-transes="enc/trans/newline.o" --module enc.mk ./miniruby -I../lib -I. -I.ext/common ../tool/generic_erb.rb -c -o encdb.h ../template/encdb.h.tmpl ../enc enc ../template/encdb.h.tmpl:63:in `block (4 levels) in
': x_emoji.h:8: ENC_REPLICATE: UTF-8 is not defined yet. (replica UTF8-DoCoMo) (ArgumentError) from ../template/encdb.h.tmpl:43:in `each_line' from ../template/encdb.h.tmpl:43:in `block (3 levels) in
' from ../template/encdb.h.tmpl:41:in `open' from ../template/encdb.h.tmpl:41:in `block (2 levels) in
' from ../template/encdb.h.tmpl:38:in `each' from ../template/encdb.h.tmpl:38:in `block in
' from ../template/encdb.h.tmpl:34:in `each' from ../template/encdb.h.tmpl:34:in `
' from /home002/t-nissie/COMMON/work/ruby/ruby/ruby-2.3.0/lib/erb.rb:864:in `eval' from /home002/t-nissie/COMMON/work/ruby/ruby/ruby-2.3.0/lib/erb.rb:864:in `result' from ../tool/generic_erb.rb:38:in `
' make: *** [encdb.h] Error 1 ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: