Blame SOURCES/gcc12-isl-dl2.patch

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