b7242a
From eca084e4079c77c061045df9c21b219175b05228 Mon Sep 17 00:00:00 2001
b7242a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
b7242a
Date: Mon, 6 Jan 2020 13:56:04 +0100
b7242a
Subject: [PATCH] Initialize ABRT hook.
b7242a
b7242a
The ABRT hook used to be initialized by preludes via patches [[1], [2]].
b7242a
Unfortunately, due to [[3]] and especially since [[4]], this would
b7242a
require boostrapping [[5]].
b7242a
b7242a
To keep the things simple for now, load the ABRT hook via C.
b7242a
b7242a
[1]: https://bugs.ruby-lang.org/issues/8566
b7242a
[2]: https://bugs.ruby-lang.org/issues/15306
b7242a
[3]: https://bugs.ruby-lang.org/issues/16254
b7242a
[4]: https://github.com/ruby/ruby/pull/2735
b7242a
[5]: https://lists.fedoraproject.org/archives/list/ruby-sig@lists.fedoraproject.org/message/LH6L6YJOYQT4Y5ZNOO4SLIPTUWZ5V45Q/
b7242a
---
b7242a
 abrt.c    | 12 ++++++++++++
b7242a
 common.mk |  3 ++-
b7242a
 ruby.c    |  4 ++++
b7242a
 3 files changed, 18 insertions(+), 1 deletion(-)
b7242a
 create mode 100644 abrt.c
b7242a
b7242a
diff --git a/abrt.c b/abrt.c
b7242a
new file mode 100644
b7242a
index 0000000000..74b0bd5c0f
b7242a
--- /dev/null
b7242a
+++ b/abrt.c
b7242a
@@ -0,0 +1,12 @@
b7242a
+#include "internal.h"
b7242a
+
b7242a
+void
b7242a
+Init_abrt(void)
b7242a
+{
b7242a
+  rb_eval_string(
b7242a
+    "  begin\n"
b7242a
+    "    require 'abrt'\n"
b7242a
+    "  rescue LoadError\n"
b7242a
+    "  end\n"
b7242a
+  );
b7242a
+}
b7242a
diff --git a/common.mk b/common.mk
b7242a
index b2e5b2b6d0..f39f81da5c 100644
b7242a
--- a/common.mk
b7242a
+++ b/common.mk
b7242a
@@ -81,7 +81,8 @@ ENC_MK        = enc.mk
b7242a
 MAKE_ENC      = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
b7242a
 		RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(mflags)
b7242a
 
b7242a
-COMMONOBJS    = array.$(OBJEXT) \
b7242a
+COMMONOBJS    = abrt.$(OBJEXT) \
b7242a
+                array.$(OBJEXT) \
b7242a
 		ast.$(OBJEXT) \
b7242a
 		bignum.$(OBJEXT) \
b7242a
 		class.$(OBJEXT) \
b7242a
diff --git a/ruby.c b/ruby.c
b7242a
index 60c57d6259..1eec16f2c8 100644
b7242a
--- a/ruby.c
b7242a
+++ b/ruby.c
b7242a
@@ -1489,10 +1489,14 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
b7242a
 
b7242a
 void Init_builtin_features(void);
b7242a
 
b7242a
+/* abrt.c */
b7242a
+void Init_abrt(void);
b7242a
+
b7242a
 static void
b7242a
 ruby_init_prelude(void)
b7242a
 {
b7242a
     Init_builtin_features();
b7242a
+    Init_abrt();
b7242a
     rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
b7242a
 }
b7242a
 
b7242a
-- 
b7242a
2.24.1
b7242a