tmm1 / stackprof

a sampling call-stack profiler for ruby 2.2+
MIT License
2.08k stars 128 forks source link

C99 error while compiling v0.2.25 #210

Closed a-prostakov closed 1 year ago

a-prostakov commented 1 year ago

Hi! Got this in our GH CI run:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
{path}/vendor/bundle/ruby/2.7.0/gems/stackprof-0.2.25/ext/stackprof
/opt/ruby-2.7.6/bin/ruby -I /opt/ruby-2.7.6/lib/ruby/2.7.0 -r
./siteconf20230508-2259-ichal1.rb extconf.rb
checking for rb_postponed_job_register_one()... yes
checking for rb_profile_frames()... yes
checking for rb_tracepoint_new()... yes
checking for RUBY_INTERNAL_EVENT_NEWOBJ... yes
creating Makefile

current directory:
{path}/vendor/bundle/ruby/2.7.0/gems/stackprof-0.2.25/ext/stackprof
make "DESTDIR=" clean

current directory:
{path}/vendor/bundle/ruby/2.7.0/gems/stackprof-0.2.25/ext/stackprof
make "DESTDIR="
compiling stackprof.c
stackprof.c: In function ‘stackprof_gc_mark’:
stackprof.c:815:5: error: ‘for’ loop initial declarations are only allowed in
C99 mode
     for (int i = 0; i < _stackprof.buffer_count; i++) {
     ^
stackprof.c:815:5: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [stackprof.o] Error 1

make failed, exit code 2

Looks like an outcome of https://github.com/tmm1/stackprof/commit/c1f12ca76773267669b8234f769a87a74ac41fd7 , which is believed to be only a patch change. Could you please tweak variable definition (define it out of the loop?), to support pre-C99 compilation?

casperisfine commented 1 year ago

Fix here https://github.com/tmm1/stackprof/pull/211