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