Blame SOURCES/gcc10-isl-dl2.patch

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