Blame SOURCES/gcc6-isl-dl2.patch

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