Hi.
This patch fixes a segfault that happens when compiling librsvg (more
specifically its dependency aho-corasick) with rustc_codegen_gcc (bug
112575).
I was not able to create a reproducer for this bug: I'm assuming I
might need to concat all the reproducers together in the same file in
order to be able to reproduce the issue.

I'm also not sure I put the cleanup in the correct location.
Is there any finalizer function for target specific code?

Thanks to fix this issue.
From e0f4f51682266bc9f507afdb64908ed3695a2f5e Mon Sep 17 00:00:00 2001
From: Antoni Boucher <boua...@zoho.com>
Date: Thu, 2 Nov 2023 17:18:35 -0400
Subject: [PATCH] libgccjit: Fix ira cost segfault

gcc/ChangeLog:
	PR jit/112575
	* config/i386/i386-options.cc (ix86_option_override_internal):
	Cleanup target_attribute_cache.
---
 gcc/config/i386/i386-options.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index df7d24352d1..f596c0fb53c 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -3070,6 +3070,12 @@ ix86_option_override_internal (bool main_args_p,
 	= opts->x_flag_unsafe_math_optimizations;
       target_option_default_node = target_option_current_node
         = build_target_option_node (opts, opts_set);
+      /* TODO: check if this is the correct location.  It should probably be in
+	 some finalizer function, but I don't
+	 know if there's one.  */
+      target_attribute_cache[0] = NULL;
+      target_attribute_cache[1] = NULL;
+      target_attribute_cache[2] = NULL;
     }
 
   if (opts->x_flag_cf_protection != CF_NONE)
-- 
2.42.1

Reply via email to