Blame SOURCES/gcc8-isl-dl2.patch

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