Re: moving gcc from the installation path: is it allowed?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 03, 2009 at 05:06:27PM -0500, Maurizio Vitale wrote:
> 
> I cannot find an answer in the documentation.
> 
> The scenario is a GCC compiled with configure --prefix=SOMEWHERE
> and then the entire tree installed by make install in
> SOMEWHERE is copied to SOMEWHERE_ELSE.
> 
> This is what happens when packaging a binary distribution (say rpm) and
> need the en user to be able to install in a directory he has enough
> rights to.
> 
> Running the compiled gcc with -print-search-dirs shows that programs and
> libraries are searched relative to the gcc binary.
> 
> Is this allowed? Note that is different (in a sense complementary) to
> the staged installation mentioned in the docs (using DESTDIR)
> 
> Best regards,
> 
>      Maurizio

As long as you move the whole tree, and execute the compiler via a full
pathname, it should work (and are not running under VMS).  Here the code in
gcc.c that does this:

  /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,
     see if we can create it from the pathname specified in argv[0].  */

  gcc_libexec_prefix = standard_libexec_prefix;
#ifndef VMS
  /* FIXME: make_relative_prefix doesn't yet work for VMS.  */
  if (!gcc_exec_prefix)
    {
      gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix,
					      standard_exec_prefix);
      gcc_libexec_prefix = make_relative_prefix (argv[0],
						 standard_bindir_prefix,
						 standard_libexec_prefix);
      if (gcc_exec_prefix)
	xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
    }
  else
    {
      /* 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);

      /* The path is unrelocated, so fallback to the original setting.  */
      if (!gcc_libexec_prefix)
	gcc_libexec_prefix = standard_libexec_prefix;

      free (tmp_prefix);
    }
#else
#endif
  /* From this point onward, gcc_exec_prefix is non-null if the toolchain
     is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX
     or an automatically created GCC_EXEC_PREFIX from argv[0].  */

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@xxxxxxxxxxxxxxxxxx

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux