Blame SOURCES/gcc12-isl-dl2.patch

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