Skip to content

Commit

Permalink
merge revision(s) ae8990a:
Browse files Browse the repository at this point in the history
	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.
	---
	 ext/extmk.rb            | 16 +++++++++++++++-
	 template/extinit.c.tmpl |  2 +-
	 2 files changed, 16 insertions(+), 2 deletions(-)
  • Loading branch information
hsbt committed May 23, 2024
1 parent 60fb6d4 commit 929e2dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion ext/extmk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,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
Expand Down Expand Up @@ -546,7 +554,13 @@ def configuration(srcdir)
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/[^/]+(?=/))) {
Expand Down
2 changes: 1 addition & 1 deletion template/extinit.c.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%# -*- C -*-
% extinits = ARGV.map {|n| [n[%r[[^/.]+(?=\.[^/]*)?\z]], n]}
% extinits = ARGV.map {|n| [n.tr('/', '_'), n]}
#include "ruby/ruby.h"

#define init(func, name) { \
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 5
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 258
#define RUBY_PATCHLEVEL 259

#define RUBY_RELEASE_YEAR 2024
#define RUBY_RELEASE_MONTH 5
Expand Down

0 comments on commit 929e2dc

Please sign in to comment.