Blame SOURCES/gcc12-isl-dl2.patch

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