Blame SOURCES/gcc5-isl-dl2.patch

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