Blame SOURCES/gcc11-isl-dl2.patch

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