Blame SOURCES/gcc6-isl-dl2.patch

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