From 57a1f69a66a209df99679a19a51cd571fc5b765f Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 1 Nov 2019 19:08:09 -0700 Subject: [PATCH] accelerate core ruby requires see https://bugs.ruby-lang.org/issues/15856 Signed-off-by: Lamont Granquist --- config/patches/ruby/ruby-fast-load_26.patch | 16 ++++++++++++++++ config/software/ruby.rb | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 config/patches/ruby/ruby-fast-load_26.patch diff --git a/config/patches/ruby/ruby-fast-load_26.patch b/config/patches/ruby/ruby-fast-load_26.patch new file mode 100644 index 000000000..5d4ad87a0 --- /dev/null +++ b/config/patches/ruby/ruby-fast-load_26.patch @@ -0,0 +1,16 @@ +diff --git a/load.c b/load.c +index 576464fb68..ae89f63820 100644 +--- a/load.c ++++ b/load.c +@@ -908,6 +908,11 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level, feature_func + if (loading) *path = rb_filesystem_str_new_cstr(loading); + return 'r'; + } ++ else if ((ft = rb_feature_p(ftptr, 0, FALSE, FALSE, &loading)) == 's') { ++ if (loading) *path = rb_filesystem_str_new_cstr(loading); ++ return 's'; ++ } ++ + tmp = fname; + type = rb_find_file_ext_safe(&tmp, loadable_ext, safe_level); + switch (type) { diff --git a/config/software/ruby.rb b/config/software/ruby.rb index 0ee409040..25ba5e483 100644 --- a/config/software/ruby.rb +++ b/config/software/ruby.rb @@ -128,6 +128,14 @@ patch source: "ruby-no-stack-protector.patch", plevel: 1, env: patch_env end + # accelerate requires of c-extension. + # + # this would break code which did `require "thing"` and loaded thing.so and + # then fiddled with the libpath and did `require "thing"` and loaded thing.rb + # over the top of it. AFAIK no sane ruby code should need to do that, and the + # cost of this behavior in core ruby is enormous. + patch source: "ruby-fast-load_26.patch", plevel: 1, env: patch_env + # disable libpath in mkmf across all platforms, it trolls omnibus and # breaks the postgresql cookbook. i'm not sure why ruby authors decided # this was a good idea, but it breaks our use case hard. AIX cannot even