Blame SOURCES/gcc49-cloog-dl2.patch

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