Blame SOURCES/gcc11-isl-dl2.patch

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