Blame SOURCES/gcc12-isl-dl2.patch

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