Skip to content

Problem with installing stackprof with native extensions #2044

@matadcze

Description

@matadcze

Hi there!

I am playing a lot with truffle-ruby last time and during the installation of the gem, I have encountered a problem.

I have in the Gemfile

gem 'rbtrace'
gem 'stackprof'
gem 'flamegraph'
Installing stackprof 0.2.15 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/gems/truffleruby/20.1.0/gems/stackprof-0.2.15/ext/stackprof
/opt/graalvm-ce-java11-20.1.0/languages/ruby/bin/truffleruby -I
/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/mri -r
./siteconf20200707-1-1x4ur8g.rb extconf.rb
checking for rb_postponed_job_register_one()... no
extconf.rb:8:in `<main>': missing API: are you using ruby 2.1+? (RuntimeError)
*** 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=/opt/graalvm-ce-java11-20.1.0/languages/ruby/bin/truffleruby

Contents of mkmf.log:
have_func: checking for rb_postponed_job_register_one()... --------------------
no

"/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/bin/graalvm-native-clang -o
conftest -I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include/ruby/backward
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include -I.
-Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast
-Wno-incompatible-pointer-types -Wno-format-invalid-specifier
-Wno-format-extra-args -ferror-limit=500 conftest.c  -L.
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib  -rpath
/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/lib
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -rpath
/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -ltruffleruby
-lpolyglot-mock   "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

conftest.c:14:57: error: use of undeclared identifier
'rb_postponed_job_register_one'
int t(void) { void ((*volatile p)()); p = (void
((*)()))rb_postponed_job_register_one; return !p; }
                                                        ^
1 error generated.
"/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/bin/graalvm-native-clang -o
conftest -I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include/ruby/backward
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include -I.
-Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast
-Wno-incompatible-pointer-types -Wno-format-invalid-specifier
-Wno-format-extra-args -ferror-limit=500 conftest.c  -L.
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib  -rpath
/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/lib
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -rpath
/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -ltruffleruby
-lpolyglot-mock   "
Process failed: #<Process::Status: pid 4351 exit 1>
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return 0;
13: }
14: int t(void) { void ((*volatile p)()); p = (void
((*)()))rb_postponed_job_register_one; return !p; }
/* end */

ld.lld: error: undefined symbol: rb_postponed_job_register_one
>>> referenced by conftest.c:15
>>>               lto.tmp:(t)
clang-9: error: linker command failed with exit code 1 (use -v to see
invocation)
"/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/bin/graalvm-native-clang -o
conftest -I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include/ruby/backward
-I/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext/include -I.
-Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast
-Wno-incompatible-pointer-types -Wno-format-invalid-specifier
-Wno-format-extra-args -ferror-limit=500 conftest.c  -L.
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib  -rpath
/opt/graalvm-ce-java11-20.1.0/languages/llvm/native/lib
-L/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -rpath
/opt/graalvm-ce-java11-20.1.0/languages/ruby/lib/cext -ltruffleruby
-lpolyglot-mock   "
Process failed: #<Process::Status: pid 4355 exit 1>
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return 0;
13: }
14: extern void rb_postponed_job_register_one();
15: int t(void) { rb_postponed_job_register_one(); return 0; }
/* end */

--------------------


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

/gems/truffleruby/20.1.0/extensions/x86_64-linux/20.1.0/stackprof-0.2.15/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/gems/truffleruby/20.1.0/gems/stackprof-0.2.15 for inspection.
Results logged to
/gems/truffleruby/20.1.0/extensions/x86_64-linux/20.1.0/stackprof-0.2.15/gem_make.out

An error occurred while installing stackprof (0.2.15), and Bundler cannot
continue.
Make sure that `gem install stackprof -v '0.2.15' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  stackprof
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 5

I use the docker container with this Dockerfile. From stackprof#sampling about rb_postponed_job_register_one

signal handlers enqueue a sampling job using rb_postponed_job_register_one. this ensures callstack samples can be taken safely, in case the VM is garbage collecting or in some other inconsistent state during the interruption.

I think that it can be an interesting problem to solve. I would like to fix this issue. Is anybody interested in solving this problem with me?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions