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  <ja...@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

Reply via email to