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