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