Skip to content

Commit cd1a0b3

Browse files
committed
Stop defining RUBY_ABI_VERSION if released versions
As commented in include/ruby/internal/abi.h, since teeny versions of Ruby should guarantee ABI compatibility, `RUBY_ABI_VERSION` has no role in released versions of Ruby.
1 parent a201cfd commit cd1a0b3

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ AC_SUBST(GIT)
8888
AC_SUBST(HAVE_GIT)
8989

9090
eval `sed -n -e ['s/^@%:@define RUBY_[A-Z_]*VERSION_\([A-Z][A-Z][A-Z_0-9]*\) \([0-9][0-9]*\)$/\1=\2/p'] \
91+
-e ['s/^@%:@define \(RUBY_ABI_VERSION\) \([0-9][0-9]*\).*/\1=\2/p'] \
9192
-e ['s/^@%:@define \(RUBY_PATCHLEVEL\) \(.*\)/\1=\2/p'] \
93+
$srcdir/include/ruby/internal/abi.h \
9294
$srcdir/include/ruby/version.h $srcdir/version.h`
9395
for v in MAJOR MINOR TEENY; do
9496
AS_IF([eval "test \"\$$v\" = ''"], [
@@ -100,6 +102,9 @@ AC_SUBST(MINOR)
100102
AC_SUBST(TEENY)
101103
AC_SUBST(RUBY_API_VERSION, '$(MAJOR).$(MINOR)')
102104
AC_SUBST(RUBY_PROGRAM_VERSION, '$(MAJOR).$(MINOR).$(TEENY)')
105+
AS_CASE([$RUBY_PATCHLEVEL], [-*], [
106+
AC_DEFINE_UNQUOTED(RUBY_ABI_VERSION, [${RUBY_ABI_VERSION}])
107+
], [RUBY_ABI_VERSION=])
103108

104109
AS_IF([test "$program_prefix" = NONE], [
105110
program_prefix=
@@ -4118,6 +4123,7 @@ AS_CASE(["$ruby_version"],
41184123
AS_IF([test ${RUBY_LIB_VERSION_STYLE+set}], [
41194124
{
41204125
echo "#define RUBY_LIB_VERSION_STYLE $RUBY_LIB_VERSION_STYLE"
4126+
echo '@%:@include "confdefs.h"'
41214127
echo '#define STRINGIZE(x) x'
41224128
test -f revision.h -o -f "${srcdir}/revision.h" || echo '#define RUBY_REVISION 0'
41234129
echo '#include "version.h"'

ext/-test-/abi/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# frozen_string_literal: false
2+
return unless RUBY_PATCHLEVEL < 0
23
require_relative "../auto_ext.rb"
34
auto_ext(inc: true)

include/ruby/internal/abi.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef RUBY_ABI_H
22
#define RUBY_ABI_H
33

4+
#ifdef RUBY_ABI_VERSION /* should match the definition in config.h */
5+
46
/* This number represents Ruby's ABI version.
57
*
68
* In development Ruby, it should be bumped every time an ABI incompatible
@@ -19,7 +21,7 @@
1921
* - Backwards compatible refactors.
2022
* - Editing comments.
2123
*
22-
* In released versions of Ruby, this number should not be changed since teeny
24+
* In released versions of Ruby, this number is not defined since teeny
2325
* versions of Ruby should guarantee ABI compatibility.
2426
*/
2527
#define RUBY_ABI_VERSION 2
@@ -49,3 +51,5 @@ ruby_abi_version(void)
4951
#endif
5052

5153
#endif
54+
55+
#endif

test/-ext-/test_abi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
return unless RUBY_PATCHLEVEL < 0
4+
35
class TestABI < Test::Unit::TestCase
46
def test_require_lib_with_incorrect_abi_on_dev_ruby
57
omit "ABI is not checked" unless abi_checking_supported?

version.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,25 @@
3838
#define RUBY_RELEASE_DAY_STR STRINGIZE(RUBY_RELEASE_DAY)
3939
#endif
4040

41+
#ifdef RUBY_ABI_VERSION
42+
# define RUBY_ABI_VERSION_SUFFIX "+"STRINGIZE(RUBY_ABI_VERSION)
43+
#else
44+
# define RUBY_ABI_VERSION_SUFFIX ""
45+
#endif
4146
#if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE
4247
# if RUBY_LIB_VERSION_STYLE == 3
4348
# define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR) \
44-
"."STRINGIZE(RUBY_API_VERSION_TEENY)"+"STRINGIZE(RUBY_ABI_VERSION)
49+
"."STRINGIZE(RUBY_API_VERSION_TEENY) RUBY_ABI_VERSION_SUFFIX
4550
# elif RUBY_LIB_VERSION_STYLE == 2
4651
# define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR) \
47-
"+"STRINGIZE(RUBY_ABI_VERSION)
52+
RUBY_ABI_VERSION_SUFFIX
4853
# endif
4954
#endif
5055

5156
#if RUBY_PATCHLEVEL == -1
5257
#define RUBY_PATCHLEVEL_STR "dev"
58+
#elif defined RUBY_ABI_VERSION
59+
#error RUBY_ABI_VERSION is defined in non-development branch
5360
#else
5461
#define RUBY_PATCHLEVEL_STR ""
5562
#endif

win32/Makefile.sub

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ PLATFORM_DIR = win32
148148
arch = $(ARCH)-$(PLATFORM)
149149
sitearch = $(ARCH)-$(RT)
150150
!if !defined(ruby_version)
151-
ruby_version = $(MAJOR).$(MINOR).0+$(ABI_VERSION)
151+
ruby_version = $(MAJOR).$(MINOR).0
152+
!endif
153+
!if defined(ABI_VERSION)
154+
ruby_version = $(ruby_version)+$(ABI_VERSION)
152155
!endif
153156
!if !defined(RUBY_VERSION_NAME)
154157
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
@@ -624,6 +627,9 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
624627
#endif
625628
!endif
626629
#define RUBY_MSVCRT_VERSION $(RT_VER)
630+
!if defined(ABI_VERSION)
631+
#define RUBY_ABI_VERSION $(ABI_VERSION)
632+
!endif
627633
#define STDC_HEADERS 1
628634
#define HAVE_SYS_TYPES_H 1
629635
#define HAVE_SYS_STAT_H 1

win32/setup.mak

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ main(void)
178178
-version-: nul verconf.mk
179179

180180
verconf.mk: nul
181+
@findstr /R /C:"^#define RUBY_ABI_VERSION " $(srcdir:/=\)\include\ruby\internal\abi.h > $(@)
181182
@$(CPP) -I$(srcdir) -I$(srcdir)/include <<"Creating $(@)" > $(*F).bat && cmd /c $(*F).bat > $(@)
182183
@echo off
183184
#define RUBY_REVISION 0
@@ -198,8 +199,9 @@ echo RUBY_RELEASE_DAY = %ruby_release_day:~-2%
198199
echo MAJOR = RUBY_VERSION_MAJOR
199200
echo MINOR = RUBY_VERSION_MINOR
200201
echo TEENY = RUBY_VERSION_TEENY
201-
echo ABI_VERSION = RUBY_ABI_VERSION
202202
#if defined RUBY_PATCHLEVEL && RUBY_PATCHLEVEL < 0
203+
#include "$(@F)"
204+
echo ABI_VERSION = RUBY_ABI_VERSION
203205
#endif
204206
set /a MSC_VER = _MSC_VER
205207
#if _MSC_VER >= 1920

0 commit comments

Comments
 (0)