Blame SOURCES/gcc12-isl-dl2.patch

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