ruby / racc

Racc is an LALR(1) parser generator. It is written in Ruby itself, and generates ruby programs.
Other
541 stars 88 forks source link

racc: Failed to build gem native extension #212

Closed tkowalewski closed 1 year ago

tkowalewski commented 1 year ago

I'm trying to install racc, but when LD_PRELOAD env is set (to /usr/lib/x86_64-linux-gnu/libjemalloc.so.2) error occurs.

Building native extensions. This could take a while...
ERROR:  Error installing racc:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/racc-1.6.2/ext/racc/cparse
/usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.0.0 extconf.rb
checking for rb_block_call()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/bin/$(RUBY_BASE_NAME)
/usr/local/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:564:in `try_link0'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:582:in `try_link'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:794:in `try_func'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:1083:in `block in have_func'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
    from /usr/local/lib/ruby/3.0.0/mkmf.rb:1082:in `have_func'
    from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/bundle/extensions/x86_64-linux/3.0.0/racc-1.6.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/racc-1.6.2 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/3.0.0/racc-1.6.2/gem_make.out

mkmf.log

"gcc -o conftest -I/usr/local/include/ruby-3.0.0/x86_64-linux -I/usr/local/include/ruby-3.0.0/ruby/backward -I/usr/local/include/ruby-3.0.0 -I.    -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable  -fPIC conftest.c  -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby  -lm   -lc"
In file included from /usr/include/math.h:457,
                 from /usr/local/include/ruby-3.0.0/ruby/missing.h:22,
                 from /usr/local/include/ruby-3.0.0/ruby/defines.h:80,
                 from /usr/local/include/ruby-3.0.0/ruby/ruby.h:23,
                 from /usr/local/include/ruby-3.0.0/ruby.h:38,
                 from conftest.c:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:101:1: internal compiler error: Segmentation fault
 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
 ^~~~~~~~~~
mmap: Permission denied
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

Environment:

zenspider commented 1 year ago

That looks like a bug in gcc to me:

mmap: Permission denied
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
flavorjones commented 1 year ago

Agree, I'm not sure there's anything we can do in the racc gem that would avoid this from happening.