Blame SOURCES/gcc9-isl-dl2.patch

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