d: Disable the D runtime garbage collector after initializing (PR103520)
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 1 Dec 2021 22:56:28 +0000 (23:56 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Thu, 2 Dec 2021 00:46:07 +0000 (01:46 +0100)
Not all targets that support building libdruntime have a stable garbage
collector, so to avoid running into problems where live memory allocated
by the D GC is freed, disable all in-flight collections until a time
when scanning is more reliably implemented everywhere.

PR d/103520

gcc/d/ChangeLog:

* d-frontend.h (gc_disable): Declare.
* d-lang.cc (d_init_options): Disable the D runtime garbage collector
after initializing.

gcc/d/d-frontend.h
gcc/d/d-lang.cc

index 3edf812..e7695d5 100644 (file)
@@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 /* These functions are defined in D runtime.  */
 extern "C" int rt_init (void);
 extern "C" int rt_term (void);
-//extern "C" void gc_disable (void);
+extern "C" void gc_disable (void);
 extern "C" void *gc_malloc (size_t sz, unsigned ba = 0, const void *ti = NULL);
 extern "C" void gc_free (void *);
 extern "C" void gc_collect (void);
index d20370e..dbf7a8b 100644 (file)
@@ -288,7 +288,7 @@ d_init_options (unsigned int, cl_decoded_option *decoded_options)
 {
   /* Initialize the D runtime.  */
   rt_init ();
-//  gc_disable ();
+  gc_disable ();
 
   /* Set default values.  */
   global._init ();