summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNARUSE, Yui <nurse@users.noreply.github.com>2024-03-21 10:28:51 +0900
committerGitHub <noreply@github.com>2024-03-21 01:28:51 +0000
commita406c516685f1950269c4e43d13cc748f0bfbc06 (patch)
treefd78bf05aa8afcbfd5ce39751ef05e77edfa5339 /ext
parent05787897f69087abdabee926971cdf364bd73730 (diff)
merge revision(s) ae8990aef098410ecc2b5f48fea9d7d171a3c5f6: [Backport #20183] (#10310)
Alias init functions The extension library has each initialization function named "Init_" + basename. If multiple extensions have the same base name (such as cgi/escape and erb/escape), the same function will be registered for both names. To fix this conflict, rename the initialization functions under sub directories using using parent names, when statically linking.
Diffstat (limited to 'ext')
-rwxr-xr-xext/extmk.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 428ffc91a6..d9c2417dfa 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -132,6 +132,14 @@ def extract_makefile(makefile, keep = true)
true
end
+def create_makefile(target, srcprefix = nil)
+ if $static and target.include?("/")
+ base = File.basename(target)
+ $defs << "-DInit_#{base}=Init_#{target.tr('/', '_')}"
+ end
+ super
+end
+
def extmake(target, basedir = 'ext', maybestatic = true)
FileUtils.mkpath target unless File.directory?(target)
begin
@@ -545,7 +553,13 @@ extend Module.new {
end
def create_makefile(*args, &block)
- return super unless @gemname
+ unless @gemname
+ if $static and (target = args.first).include?("/")
+ base = File.basename(target)
+ $defs << "-DInit_#{base}=Init_#{target.tr('/', '_')}"
+ end
+ return super
+ end
super(*args) do |conf|
conf.find do |s|
s.sub!(%r(^(srcdir *= *)\$\(top_srcdir\)/\.bundle/gems/[^/]+(?=/))) {