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