Blame SOURCES/gcc6-isl-dl2.patch

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