3696d7b
From eca084e4079c77c061045df9c21b219175b05228 Mon Sep 17 00:00:00 2001
3696d7b
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
3696d7b
Date: Mon, 6 Jan 2020 13:56:04 +0100
3696d7b
Subject: [PATCH] Initialize ABRT hook.
3696d7b
3696d7b
The ABRT hook used to be initialized by preludes via patches [[1], [2]].
3696d7b
Unfortunately, due to [[3]] and especially since [[4]], this would
3696d7b
require boostrapping [[5]].
3696d7b
3696d7b
To keep the things simple for now, load the ABRT hook via C.
3696d7b
3696d7b
[1]: https://bugs.ruby-lang.org/issues/8566
3696d7b
[2]: https://bugs.ruby-lang.org/issues/15306
3696d7b
[3]: https://bugs.ruby-lang.org/issues/16254
3696d7b
[4]: https://github.com/ruby/ruby/pull/2735
3696d7b
[5]: https://lists.fedoraproject.org/archives/list/ruby-sig@lists.fedoraproject.org/message/LH6L6YJOYQT4Y5ZNOO4SLIPTUWZ5V45Q/
3696d7b
---
05a6c9c
 abrt.c                                | 12 ++++++++++++
05a6c9c
 common.mk                             |  3 ++-
05a6c9c
 ruby.c                                |  4 ++++
05a6c9c
 spec/ruby/core/kernel/require_spec.rb |  2 ++
05a6c9c
 4 files changed, 20 insertions(+), 1 deletion(-)
3696d7b
 create mode 100644 abrt.c
3696d7b
3696d7b
diff --git a/abrt.c b/abrt.c
3696d7b
new file mode 100644
3696d7b
index 0000000000..74b0bd5c0f
3696d7b
--- /dev/null
3696d7b
+++ b/abrt.c
3696d7b
@@ -0,0 +1,12 @@
3696d7b
+#include "internal.h"
3696d7b
+
3696d7b
+void
3696d7b
+Init_abrt(void)
3696d7b
+{
3696d7b
+  rb_eval_string(
3696d7b
+    "  begin\n"
3696d7b
+    "    require 'abrt'\n"
3696d7b
+    "  rescue LoadError\n"
3696d7b
+    "  end\n"
3696d7b
+  );
3696d7b
+}
3696d7b
diff --git a/common.mk b/common.mk
3696d7b
index b2e5b2b6d0..f39f81da5c 100644
3696d7b
--- a/common.mk
3696d7b
+++ b/common.mk
05a6c9c
@@ -111,7 +111,8 @@ PRISM_FILES = prism/api_node.$(OBJEXT) \
05a6c9c
 		prism/prism.$(OBJEXT) \
05a6c9c
 		prism_init.$(OBJEXT)
3696d7b
 
3696d7b
-COMMONOBJS    = array.$(OBJEXT) \
3696d7b
+COMMONOBJS    = abrt.$(OBJEXT) \
3696d7b
+                array.$(OBJEXT) \
3696d7b
 		ast.$(OBJEXT) \
3696d7b
 		bignum.$(OBJEXT) \
3696d7b
 		class.$(OBJEXT) \
3696d7b
diff --git a/ruby.c b/ruby.c
3696d7b
index 60c57d6259..1eec16f2c8 100644
3696d7b
--- a/ruby.c
3696d7b
+++ b/ruby.c
05a6c9c
@@ -1724,10 +1724,14 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
3696d7b
 
3696d7b
 void Init_builtin_features(void);
3696d7b
 
3696d7b
+/* abrt.c */
3696d7b
+void Init_abrt(void);
3696d7b
+
3696d7b
 static void
3696d7b
 ruby_init_prelude(void)
3696d7b
 {
3696d7b
     Init_builtin_features();
3696d7b
+    Init_abrt();
3696d7b
     rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
3696d7b
 }
3696d7b
 
05a6c9c
diff --git a/spec/ruby/core/kernel/require_spec.rb b/spec/ruby/core/kernel/require_spec.rb
05a6c9c
index 60c57d6259..1eec16f2c8 100644
05a6c9c
--- a/spec/ruby/core/kernel/require_spec.rb
05a6c9c
+++ b/spec/ruby/core/kernel/require_spec.rb
05a6c9c
@@ -25,6 +25,8 @@
05a6c9c
     out = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems --disable-did-you-mean')
05a6c9c
     features = out.lines.map { |line| File.basename(line.chomp, '.*') }
05a6c9c
 
05a6c9c
+    # Ignore ABRT
05a6c9c
+    features -= %w[abrt]
05a6c9c
     # Ignore CRuby internals
05a6c9c
     features -= %w[encdb transdb windows_1252]
05a6c9c
     features.reject! { |feature| feature.end_with?('-fake') }