Blame SOURCES/gcc10-isl-dl2.patch

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