Blame SOURCES/gcc11-isl-dl2.patch

36b189
2011-04-04  Jakub Jelinek  <jakub@redhat.com>
36b189
36b189
	* toplev.c (toplev_main_argv): New variable.
36b189
	(toplev_main): Initialize it.
36b189
	* graphite.c (init_isl_pointers): Load libisl.so.15 from gcc's private
36b189
	directory.
36b189
36b189
--- gcc/toplev.c.jj	2008-12-09 23:59:10.000000000 +0100
36b189
+++ gcc/toplev.c	2009-01-27 14:33:52.000000000 +0100
36b189
@@ -117,6 +117,8 @@ static void compile_file (void);
36b189
 /* True if we don't need a backend (e.g. preprocessing only).  */
36b189
 static bool no_backend;
36b189
 
36b189
+const char **toplev_main_argv;
36b189
+
36b189
 /* Decoded options, and number of such options.  */
36b189
 struct cl_decoded_option *save_decoded_options;
36b189
 unsigned int save_decoded_options_count;
36b189
@@ -2287,6 +2289,8 @@ toplev::main (int argc, char **argv)
36b189
 
36b189
   expandargv (&argc, &argv);
36b189
 
36b189
+  toplev_main_argv = CONST_CAST2 (const char **, char **, argv);
36b189
+
36b189
   /* Initialization of GCC's environment, and diagnostics.  */
36b189
   general_init (argv[0], m_init_signals);
36b189
 
36b189
--- gcc/graphite.c.jj	2010-12-01 10:24:32.000000000 -0500
36b189
+++ gcc/graphite.c	2010-12-01 11:46:07.832118193 -0500
36b189
@@ -64,11 +64,39 @@ __typeof (isl_pointers__) isl_pointers__
36b189
 static bool
36b189
 init_isl_pointers (void)
36b189
 {
36b189
-  void *h;
36b189
+  void *h = NULL;
36b189
+  extern const char **toplev_main_argv;
36b189
+  char *buf, *p;
36b189
+  size_t len;
36b189
 
36b189
   if (isl_pointers__.inited)
36b189
     return isl_pointers__.h != NULL;
36b189
-  h = dlopen ("libisl.so.15", RTLD_LAZY);
36b189
+  len = progname - toplev_main_argv[0];
36b189
+  buf = XALLOCAVAR (char, len + sizeof "libisl.so.15");
36b189
+  memcpy (buf, toplev_main_argv[0], len);
36b189
+  strcpy (buf + len, "libisl.so.15");
36b189
+  len += sizeof "libisl.so.15";
36b189
+  p = strstr (buf, "/libexec/");
36b189
+  if (p != NULL)
36b189
+    {
36b189
+      while (1)
36b189
+	{
36b189
+	  char *q = strstr (p + 8, "/libexec/");
36b189
+	  if (q == NULL)
36b189
+	    break;
36b189
+	  p = q;
36b189
+	}
36b189
+      memmove (p + 4, p + 8, len - (p + 8 - buf));
36b189
+      h = dlopen (buf, RTLD_LAZY);
36b189
+      if (h == NULL)
36b189
+	{
36b189
+	  len = progname - toplev_main_argv[0];
36b189
+	  memcpy (buf, toplev_main_argv[0], len);
36b189
+	  strcpy (buf + len, "libisl.so.15");
36b189
+	}
36b189
+    }
36b189
+  if (h == NULL)
36b189
+    h = dlopen (buf, RTLD_LAZY);
36b189
   isl_pointers__.h = h;
36b189
   if (h == NULL)
36b189
     return false;