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