Blame SOURCES/gcc12-isl-dl2.patch

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