This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix up gcc-{ar,nm,ranlib}


Hi!

If say /usr/bin/gcc-ar doesn't find /usr/<target>/bin/ar (and a few others),
it gives up unless CROSS_DIRECTORY_STRUCTURE, while e.g. collect2 looks for
ld, nm etc. in $PATH.  The collect2.c snippet is:

  /* Search the compiler directories for `ld'.  We have protection against
     recursive calls in find_a_file.  */
  if (ld_file_name == 0)
    ld_file_name = find_a_file (&cpath, ld_suffixes[selected_linker]);
  /* Search the ordinary system bin directories
     for `ld' (if native linking) or `TARGET-ld' (if cross).  */
  if (ld_file_name == 0)
    ld_file_name = find_a_file (&path, full_ld_suffixes[selected_linker]);
where the difference between full_ld_suffixes and ld_suffixes is
exactly a concat (target_machine, "-", ld_suffixes[xxx], NULL);

Here is so far untested attempt to do that in gcc-{ar,nm,ranlib} too, ok if
bootstrap/regtest passes and testing shows it works (for 4.8 too, in 4.7 it
worked)?

2013-06-19  Jakub Jelinek  <jakub@redhat.com>

	* gcc-ar.c (main): If not CROSS_DIRECTORY_STRUCTURE, look for
	PERSONALITY in $PATH derived prefixes.

--- gcc/gcc-ar.c.jj	2013-01-11 09:02:55.000000000 +0100
+++ gcc/gcc-ar.c	2013-06-19 15:09:08.314935157 +0200
@@ -147,21 +147,17 @@ main(int ac, char **av)
   exe_name = find_a_file (&target_path, PERSONALITY);
   if (!exe_name)
     {
+      const char *real_exe_name = PERSONALITY;
 #ifdef CROSS_DIRECTORY_STRUCTURE
-      const char *cross_exe_name;
-
-      cross_exe_name = concat (target_machine, "-", PERSONALITY, NULL);
-      exe_name = find_a_file (&path, cross_exe_name);
+      real_exe_name = concat (target_machine, "-", PERSONALITY, NULL);
+#endif
+      exe_name = find_a_file (&path, real_exe_name);
       if (!exe_name)
 	{
 	  fprintf (stderr, "%s: Cannot find binary '%s'\n", av[0],
-		   cross_exe_name);
+		   real_exe_name);
 	  exit (1);
 	}
-#else
-      fprintf (stderr, "%s: Cannot find binary '%s'\n", av[0], PERSONALITY);
-      exit (1);
-#endif
     }
 
   /* Create new command line with plugin */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]