diff mbox

Fix up gcc-{ar,nm,ranlib}

Message ID 20130619132033.GQ2336@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek June 19, 2013, 1:20 p.m. UTC
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.


	Jakub

Comments

Andi Kleen June 19, 2013, 2:17 p.m. UTC | #1
On Wed, Jun 19, 2013 at 03:20:33PM +0200, Jakub Jelinek wrote:
> 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:

Looks good. Thanks for fixing.

-Andi
Matthias Klose June 19, 2013, 2:24 p.m. UTC | #2
Am 19.06.2013 15:20, schrieb Jakub Jelinek:
> 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)?

works for me, checked with a 4.8 native build and install.

  Matthias
diff mbox

Patch

--- 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 */