Blame SOURCES/gcc48-cloog-dl2.patch

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