Blame SOURCES/gcc11-isl-dl2.patch

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