Blame SOURCES/gcc7-isl-dl2.patch

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