Blame SOURCES/gcc48-cloog-dl2.patch

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