Why do I get error compiling Ruby 3.2 on CentOS 7?

I try to build Ruby 3.2 using ruby-build plugin for rbenv but get some strange compilation error:

compiling bignum.c
In file included from vm_core.h:164:0,
                 from iseq.h:14,
                 from mini_builtin.c:3,
                 from miniinit.c:51:
thread_pthread.h:109:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
 RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
In file included from iseq.h:14:0,
                 from mini_builtin.c:3,
                 from miniinit.c:51:
vm_core.h: In function ‘rb_current_execution_context’:
vm_core.h:1864:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
     rb_execution_context_t *ec = ruby_current_ec;
vm_core.h:1864:34: note: each undeclared identifier is reported only once for each function it appears in

Here is the full log:

Ruby 3.1 builds without any problems on the same machine. What could be the problem?


  • The problem was centos7 being shipped with too old GCC. There was devtoolset-7-gcc.x86_64 package available on the machine in my case, so I was able to install Ruby 3.2 using the following command:

    CC=/opt/rh/devtoolset-7/root/usr/bin/gcc rbenv install 3.2.0 -v

    Hope this helps someone.