Skip to content

Commit 8e4439b

Browse files
committed
[GR-33594] Fix build issue with LLVM 12.
PullRequest: truffleruby/2898
2 parents f6618ff + f94bcdb commit 8e4439b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/cext/ABI_check.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6
1+
7

lib/cext/include/ruby/ruby.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,12 @@ VALUE rb_check_symbol(volatile VALUE *namep);
20492049
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
20502050
result rb_intern_id_cache; \
20512051
}
2052+
// Workaround compound-token-split-by-macro warning
2053+
#define RUBY_CONST_ID_CACHE_TOKEN_SPLIT(result, str) \
2054+
static ID rb_intern_id_cache; \
2055+
if (!polyglot_is_value((void*)rb_intern_id_cache)) \
2056+
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
2057+
result rb_intern_id_cache;
20522058
#else
20532059
#define RUBY_CONST_ID_CACHE(result, str) \
20542060
{ \
@@ -2065,10 +2071,17 @@ VALUE rb_check_symbol(volatile VALUE *namep);
20652071
#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
20662072
/* __builtin_constant_p and statement expression is available
20672073
* since gcc-2.7.2.3 at least. */
2074+
#ifdef TRUFFLERUBY
2075+
#define rb_intern(str) \
2076+
(__builtin_constant_p(str) ? \
2077+
__extension__ ({RUBY_CONST_ID_CACHE_TOKEN_SPLIT((ID), (str))}) : \
2078+
rb_intern(str))
2079+
#else
20682080
#define rb_intern(str) \
20692081
(__builtin_constant_p(str) ? \
20702082
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
20712083
rb_intern(str))
2084+
#endif
20722085
#define rb_intern_const(str) \
20732086
(__builtin_constant_p(str) ? \
20742087
__extension__ (rb_intern2((str), (long)strlen(str))) : \

0 commit comments

Comments
 (0)