Bug #19161
closedCannot compile 3.0.5 or 3.1.3 on Red Hat Enterprise Linux 7
Description
When attempting to run make
on either the 3.0.5 or 3.1.3 release, I get the following error (I included the whole output as it's pretty short):
BASERUBY = /opt/ruby/bin/ruby --disable=gems
CC = gcc -std=gnu11
LD = ld
LDSHARED = gcc -std=gnu11 -shared
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -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
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -I. -I.ext/include/x86_64-linux -I./include -I. -I./enc/unicode/13.0.0
CPPFLAGS =
DLDFLAGS = -Wl,--compress-debug-sections=zlib -fstack-protector-strong -pie
SOLIBS = -lz -lpthread -lrt -lrt -ldl -lcrypt -lm
LANG = en_US.UTF-8
LC_ALL =
LC_CTYPE =
MFLAGS =
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
compiling ./main.c
compiling dmydln.c
compiling miniinit.c
In file included from vm_core.h:83:0,
from iseq.h:14,
from mini_builtin.c:3,
from miniinit.c:51:
thread_pthread.h:108:43: 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:1870:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
rb_execution_context_t *ec = ruby_current_ec;
^
vm_core.h:1870:34: note: each undeclared identifier is reported only once for each function it appears in
miniinit.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
make: *** [miniinit.o] Error 1
Both Ruby 3.0.4 and 3.1.2 build without error and pass (all but one of) the make check
tests.
I know RHEL 7 is getting to be pretty old; I suspect a factor here are the ancient build tools available to me. But... EOL for Ruby 2.7 comes before the one for RHEL 7, so I'm trying to prioritize.
Updated by hsbt (Hiroshi SHIBATA) about 2 months ago
- Subject changed from Cannot compile 3.0.5 or 3.1.3 on Red Hat 7 to Cannot compile 3.0.5 or 3.1.3 on Red Hat Enterprise Linux 7
Updated by nobu (Nobuyoshi Nakada) about 2 months ago
- Status changed from Open to Feedback
Could you try this?
diff --git i/configure.ac w/configure.ac
index fcae66f775e..c933ed8b91f 100644
--- i/configure.ac
+++ w/configure.ac
@@ -363,6 +363,13 @@ AS_IF([test "$GCC" = yes], [
icc_version=`echo =__ICC | $CC -E -xc - | sed '/^=/!d;s///;/^__ICC/d'`
test -n "$icc_version" || icc_version=0
# RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"])
+
+ AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])],
+ [rb_cv_tls_supported=yes],
+ [rb_cv_tls_supported=no])])
+ AS_IF([test x"$rb_cv_tls_supported" != xyes],
+ [AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)])
], [
linker_flag=
])
diff --git i/thread_pthread.h w/thread_pthread.h
index 2ac354046c0..7d4df3e2785 100644
--- i/thread_pthread.h
+++ w/thread_pthread.h
@@ -72,7 +72,7 @@ typedef struct rb_global_vm_lock_struct {
#if __STDC_VERSION__ >= 201112
#define RB_THREAD_LOCAL_SPECIFIER _Thread_local
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && !defined(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)
/* note that ICC (linux) and Clang are covered by __GNUC__ */
#define RB_THREAD_LOCAL_SPECIFIER __thread
#else
Updated by hsbt (Hiroshi SHIBATA) about 2 months ago
- Status changed from Feedback to Closed
- Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: DONTNEED, 3.0: REQUIRED, 3.1: REQUIRED
I could reproduce on CentOS 7 and confirmed to fix nobu's patch.
Updated by mame (Yusuke Endoh) about 2 months ago
I investigated why our CI server for CentOS 7 could not find this problem. In short, this problem only occurs on tarball.
This problem occurs when gcc -std=gnu11
.
The CI server uses ./autogen.sh
to generate configure
script. Because the old autoconf on CentOS 7 does not know -std=gnu11
, the generated script does not produce -std=gnu11
.
On the other hand, the configure script in tarball is generated by the new autoconf, so it adds -std=gnu11
, which causes a problem.
I want to add CI for tarballs, but it would require more computing resource (and human resource).
From here, I found a simple workaround: ./configure cflags="-std=gnu99"
. Just FYI.
Updated by werebus (Matt Moretti) about 2 months ago
Thanks everyone,
I can confirm that adding cflags="-std=gnu99"
to the configure step worked around my issue. Re-running ./autogen.sh
on the server in question also worked.