summaryrefslogtreecommitdiff
path: root/tool/mkconfig.rb
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-02-18 10:59:45 -0500
committerPeter Zhu <peter@peterzhu.ca>2022-02-22 09:55:21 -0500
commit3df16924b45adfd88c20ef5fe25b10a1acb82dd7 (patch)
treeb943497ee6802001a6cd06de1e51470c0f920dad /tool/mkconfig.rb
parent37d5890e4941cedf6918821b29bb4a7e3a092e62 (diff)
downloadruby-3df16924b45adfd88c20ef5fe25b10a1acb82dd7.tar.gz
[Feature #18249] Implement ABI checking
Header file include/ruby/internal/abi.h contains RUBY_ABI_VERSION which is the ABI version. This value should be bumped whenever an ABI incompatible change is introduced. When loading dynamic libraries, Ruby will compare its own `ruby_abi_version` and the `ruby_abi_version` of the loaded library. If these two values don't match it will raise a `LoadError`. This feature can also be turned off by setting the environment variable `RUBY_RUBY_ABI_CHECK=0`. This feature will prevent cases where previously installed native gems fail in unexpected ways due to incompatibility of changes in header files. This will force the developer to recompile their gems to use the same header files as the built Ruby. In Ruby, the ABI version is exposed through `RbConfig::CONFIG["ruby_abi_version"]`.
Diffstat (limited to 'tool/mkconfig.rb')
-rwxr-xr-xtool/mkconfig.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index 6e23af5185..0dd25eb400 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -229,6 +229,15 @@ end
print " CONFIG[#{v.dump}] = #{(versions[v]||vars[v]).dump}\n"
end
+# Get the ABI version
+File.foreach(File.join(srcdir, "include/ruby/internal/abi.h")) do |l|
+ m = /^\s*#\s*define\s+RUBY_ABI_VERSION\s+(\d+)/.match(l)
+ if m
+ print " CONFIG[\"ruby_abi_version\"] = \"#{m[1]}\"\n"
+ break
+ end
+end
+
dest = drive ? %r'= "(?!\$[\(\{])(?i:[a-z]:)' : %r'= "(?!\$[\(\{])'
v_disabled = {}
v_others.collect! do |x|