Blame SOURCES/gcc10-isl-dl2.patch

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