Blame SOURCES/gcc5-isl-dl2.patch

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