This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: ld doesn't relocate sysroot if called as tooldir/bin/ld


On Tue, Feb 25, 2003 at 01:53:24AM -0300, Alexandre Oliva wrote:
> On Feb 20, 2003, Daniel Jacobowitz <drow at mvista dot com> wrote:
> 
> > Hmm, you're doing a duplicate stat; could you try to avoid that?  It's
> > easy, just means a little more indentation.
> 
> Sure, how about this?
> 
> > I also just want to throw out another thought: with the patch I posted
> > to gcc-patches earlier today, if we made the version in TOOLBINDIR a
> > symlink to the one in BINDIR instead of a hardlink, it would work
> > automatically.
> 
> Unless someone actually added toolbindir to their path and ran it by
> hand, right?  Besides, there are systems that still don't support soft
> links, so we'd fail on those.

No, it'd work there too - it would find and resolve the symlink.  I
don't really care though.

> Index: ld/ChangeLog
> from  Alexandre Oliva  <aoliva at redhat dot com>
> 
> 	* Makefile.am (ldmain.o): Define TOOLBINDIR.
> 	* Makefile.in: Rebuilt.
> 	* ldmain.c (ld_sysroot): Try to set from TOOLBINDIR too.

This patch is fine with me (although I can't approve ld patches).
Thanks for updating it!

> 
> Index: ld/Makefile.am
> ===================================================================
> RCS file: /cvs/uberbaum/ld/Makefile.am,v
> retrieving revision 1.123
> diff -u -p -r1.123 Makefile.am
> --- ld/Makefile.am 18 Feb 2003 06:05:06 -0000 1.123
> +++ ld/Makefile.am 20 Feb 2003 10:05:35 -0000
> @@ -397,6 +397,7 @@ po/POTFILES.in: @MAINT@ Makefile
>  ldmain.o: ldmain.c config.status
>  	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
>  	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
> +	  -DTOOLBINDIR='"$(tooldir)/bin"' \
>  	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
>  	  $(srcdir)/ldmain.c
>  
> Index: ld/ldmain.c
> ===================================================================
> RCS file: /cvs/uberbaum/ld/ldmain.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 ldmain.c
> --- ld/ldmain.c 17 Feb 2003 18:24:37 -0000 1.62
> +++ ld/ldmain.c 25 Feb 2003 04:48:30 -0000
> @@ -199,6 +199,7 @@ main (argc, argv)
>  #ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
>    ld_sysroot = make_relative_prefix (program_name, BINDIR,
>  				     TARGET_SYSTEM_ROOT);
> +
>    if (ld_sysroot)
>      {
>        struct stat s;
> @@ -206,10 +207,28 @@ main (argc, argv)
>        if (!res)
>  	{
>  	  free (ld_sysroot);
> -	  ld_sysroot = TARGET_SYSTEM_ROOT;
> +	  ld_sysroot = NULL;
>  	}
>      }
> -  else
> +
> +  if (! ld_sysroot)
> +    {
> +      ld_sysroot = make_relative_prefix (program_name, TOOLBINDIR,
> +					 TARGET_SYSTEM_ROOT);
> +
> +      if (ld_sysroot)
> +	{
> +	  struct stat s;
> +	  int res = stat (ld_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
> +	  if (!res)
> +	    {
> +	      free (ld_sysroot);
> +	      ld_sysroot = NULL;
> +	    }
> +	}
> +    }
> +
> +  if (! ld_sysroot)
>      ld_sysroot = TARGET_SYSTEM_ROOT;
>  #else
>    ld_sysroot = TARGET_SYSTEM_ROOT;

> 
> -- 
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
> CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
> Free Software Evangelist                Professional serial bug killer


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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