Blame SOURCES/gcc12-isl-dl2.patch

888cb5
2011-04-04  Jakub Jelinek  <jakub@redhat.com>
888cb5
888cb5
	* toplev.cc (toplev_main_argv): New variable.
888cb5
	(toplev_main): Initialize it.
888cb5
	* graphite.cc (init_isl_pointers): Load libisl.so.15 from gcc's private
888cb5
	directory.
888cb5
888cb5
--- gcc/toplev.cc.jj	2008-12-09 23:59:10.000000000 +0100
888cb5
+++ gcc/toplev.cc	2009-01-27 14:33:52.000000000 +0100
888cb5
@@ -113,6 +113,8 @@ static void finalize (bool);
888cb5
 static void crash_signal (int) ATTRIBUTE_NORETURN;
888cb5
 static void compile_file (void);
888cb5
 
888cb5
+const char **toplev_main_argv;
888cb5
+
888cb5
 /* Decoded options, and number of such options.  */
888cb5
 struct cl_decoded_option *save_decoded_options;
888cb5
 unsigned int save_decoded_options_count;
888cb5
@@ -2239,6 +2241,8 @@ toplev::main (int argc, char **argv)
888cb5
 
888cb5
   expandargv (&argc, &argv);
888cb5
 
888cb5
+  toplev_main_argv = CONST_CAST2 (const char **, char **, argv);
888cb5
+
888cb5
   /* Initialization of GCC's environment, and diagnostics.  */
888cb5
   general_init (argv[0], m_init_signals);
888cb5
 
888cb5
--- gcc/graphite.cc.jj	2010-12-01 10:24:32.000000000 -0500
888cb5
+++ gcc/graphite.cc	2010-12-01 11:46:07.832118193 -0500
888cb5
@@ -64,11 +64,39 @@ __typeof (isl_pointers__) isl_pointers__
888cb5
 static bool
888cb5
 init_isl_pointers (void)
888cb5
 {
888cb5
-  void *h;
888cb5
+  void *h = NULL;
888cb5
+  extern const char **toplev_main_argv;
888cb5
+  char *buf, *p;
888cb5
+  size_t len;
888cb5
 
888cb5
   if (isl_pointers__.inited)
888cb5
     return isl_pointers__.h != NULL;
888cb5
-  h = dlopen ("libisl.so.15", RTLD_LAZY);
888cb5
+  len = progname - toplev_main_argv[0];
888cb5
+  buf = XALLOCAVAR (char, len + sizeof "libisl.so.15");
888cb5
+  memcpy (buf, toplev_main_argv[0], len);
888cb5
+  strcpy (buf + len, "libisl.so.15");
888cb5
+  len += sizeof "libisl.so.15";
888cb5
+  p = strstr (buf, "/libexec/");
888cb5
+  if (p != NULL)
888cb5
+    {
888cb5
+      while (1)
888cb5
+	{
888cb5
+	  char *q = strstr (p + 8, "/libexec/");
888cb5
+	  if (q == NULL)
888cb5
+	    break;
888cb5
+	  p = q;
888cb5
+	}
888cb5
+      memmove (p + 4, p + 8, len - (p + 8 - buf));
888cb5
+      h = dlopen (buf, RTLD_LAZY);
888cb5
+      if (h == NULL)
888cb5
+	{
888cb5
+	  len = progname - toplev_main_argv[0];
888cb5
+	  memcpy (buf, toplev_main_argv[0], len);
888cb5
+	  strcpy (buf + len, "libisl.so.15");
888cb5
+	}
888cb5
+    }
888cb5
+  if (h == NULL)
888cb5
+    h = dlopen (buf, RTLD_LAZY);
888cb5
   isl_pointers__.h = h;
888cb5
   if (h == NULL)
888cb5
     return false;