Blame SOURCES/gcc12-isl-dl2.patch

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