Patch for -frepo with relocated toolchains

Joseph S. Myers joseph@codesourcery.com
Wed Apr 26 01:36:00 GMT 2006


This patch fixes a problem with -frepo with relocated toolchains
(i.e. those installed somewhere other than the configured --prefix).

Using -frepo with a relocated toolchain can give errors of the form

c++: error trying to exec 'cc1plus': execvp: No such file or directory

where the "c++" in question is called from collect2, which is called
from an outer c++.  The outer c++ driver sets GCC_EXEC_PREFIX to a
value /some/where/bin/../lib/gcc/, and the inner c++ driver then
processes it in process_command to derive the locations of other parts
of the toolchain using make_relative_prefix.  Normally, this
relocation is done using a program name from argv[0] (and
make_relative_prefix searches PATH if argv[0] is a program name only).
make_relative_prefix calls split_directories which ignores trailing
'/'.  Thus "c++" acts as if called as /some/where/lib/gcc (as opposed
to /some/where/lib/gcc/c++), and this causes a search for cc1plus
under /some/where/lib/../../libexec/gcc/ instead of
/some/where/lib/gcc/../../libexec/gcc/.

This patch adds a dummy program name to the argument passed to
make_relative_prefix to avoid the problem.  The test failures fixed
are:

FAIL: g++.dg/rtti/repo1.C (test for excess errors)
FAIL: g++.dg/template/repo1.C (test for excess errors)
FAIL: g++.dg/template/repo3.C (test for excess errors)
FAIL: g++.dg/template/repo4.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/instantiate4.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/instantiate6.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/repo1.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/repo2.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/repo3.C (test for excess errors)
FAIL: g++.old-deja/g++.pt/repo4.C (test for excess errors)

Tested i686-pc-linux-gnu.  OK to commit?

2006-04-26  Joseph S. Myers  <joseph@codesourcery.com>

	* gcc.c (process_command): Add program name to GCC_EXEC_PREFIX
	value before passing to make_relative_prefix.

Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c	(revision 113259)
+++ gcc/gcc.c	(working copy)
@@ -3376,9 +3376,17 @@
 	putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
     }
   else
-    gcc_libexec_prefix = make_relative_prefix (gcc_exec_prefix,
-					       standard_exec_prefix,
-					       standard_libexec_prefix);
+    {
+      /* make_relative_prefix requires a program name, but
+	 GCC_EXEC_PREFIX is typically a directory name with a trailing
+	 / (which is ignored by make_relative_prefix), so append a
+	 program name.  */
+      char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL);
+      gcc_libexec_prefix = make_relative_prefix (tmp_prefix,
+						 standard_exec_prefix,
+						 standard_libexec_prefix);
+      free (tmp_prefix);
+    }
 #else
 #endif
 

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)



More information about the Gcc-patches mailing list