Blame SOURCES/gcc11-isl-dl2.patch

6f0f47
2011-04-04  Jakub Jelinek  <jakub@redhat.com>
6f0f47
6f0f47
	* toplev.c (toplev_main_argv): New variable.
6f0f47
	(toplev_main): Initialize it.
6f0f47
	* graphite.c (init_isl_pointers): Load libisl.so.15 from gcc's private
6f0f47
	directory.
6f0f47
6f0f47
--- gcc/toplev.c.jj	2008-12-09 23:59:10.000000000 +0100
6f0f47
+++ gcc/toplev.c	2009-01-27 14:33:52.000000000 +0100
6f0f47
@@ -117,6 +117,8 @@ static void compile_file (void);
6f0f47
 /* True if we don't need a backend (e.g. preprocessing only).  */
6f0f47
 static bool no_backend;
6f0f47
 
6f0f47
+const char **toplev_main_argv;
6f0f47
+
6f0f47
 /* Decoded options, and number of such options.  */
6f0f47
 struct cl_decoded_option *save_decoded_options;
6f0f47
 unsigned int save_decoded_options_count;
6f0f47
@@ -2287,6 +2289,8 @@ toplev::main (int argc, char **argv)
6f0f47
 
6f0f47
   expandargv (&argc, &argv);
6f0f47
 
6f0f47
+  toplev_main_argv = CONST_CAST2 (const char **, char **, argv);
6f0f47
+
6f0f47
   /* Initialization of GCC's environment, and diagnostics.  */
6f0f47
   general_init (argv[0], m_init_signals);
6f0f47
 
6f0f47
--- gcc/graphite.c.jj	2010-12-01 10:24:32.000000000 -0500
6f0f47
+++ gcc/graphite.c	2010-12-01 11:46:07.832118193 -0500
6f0f47
@@ -64,11 +64,39 @@ __typeof (isl_pointers__) isl_pointers__
6f0f47
 static bool
6f0f47
 init_isl_pointers (void)
6f0f47
 {
6f0f47
-  void *h;
6f0f47
+  void *h = NULL;
6f0f47
+  extern const char **toplev_main_argv;
6f0f47
+  char *buf, *p;
6f0f47
+  size_t len;
6f0f47
 
6f0f47
   if (isl_pointers__.inited)
6f0f47
     return isl_pointers__.h != NULL;
6f0f47
-  h = dlopen ("libisl.so.15", RTLD_LAZY);
6f0f47
+  len = progname - toplev_main_argv[0];
6f0f47
+  buf = XALLOCAVAR (char, len + sizeof "libisl.so.15");
6f0f47
+  memcpy (buf, toplev_main_argv[0], len);
6f0f47
+  strcpy (buf + len, "libisl.so.15");
6f0f47
+  len += sizeof "libisl.so.15";
6f0f47
+  p = strstr (buf, "/libexec/");
6f0f47
+  if (p != NULL)
6f0f47
+    {
6f0f47
+      while (1)
6f0f47
+	{
6f0f47
+	  char *q = strstr (p + 8, "/libexec/");
6f0f47
+	  if (q == NULL)
6f0f47
+	    break;
6f0f47
+	  p = q;
6f0f47
+	}
6f0f47
+      memmove (p + 4, p + 8, len - (p + 8 - buf));
6f0f47
+      h = dlopen (buf, RTLD_LAZY);
6f0f47
+      if (h == NULL)
6f0f47
+	{
6f0f47
+	  len = progname - toplev_main_argv[0];
6f0f47
+	  memcpy (buf, toplev_main_argv[0], len);
6f0f47
+	  strcpy (buf + len, "libisl.so.15");
6f0f47
+	}
6f0f47
+    }
6f0f47
+  if (h == NULL)
6f0f47
+    h = dlopen (buf, RTLD_LAZY);
6f0f47
   isl_pointers__.h = h;
6f0f47
   if (h == NULL)
6f0f47
     return false;