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