diff mbox

[google] Set default prefix canonicalization behaviour with configure option

Message ID 20110211105721.B7ACD1C63E0@hpgntab-ubiq73.eem.corp.google.com
State New
Headers show

Commit Message

Simon Baldwin Feb. 11, 2011, 10:57 a.m. UTC
Set default prefix canonicalization behaviour with configure option.

Gcc offers -no-canonical-prefixes to turn off realpath() for prefixes
generated from the path used to address the gcc driver.  This allows gcc to
work in "symlink farm" installations, where every file in gcc is actually a
symlink to its real contents.  However, the flag generally has to be given
explicitly.  If not, the default is to use realpath() to create prefixes
and the result is usually failure to find cc1[plus], f951, etc.

An earlier patch added auto-detection, but it is fragile.  This patch
replaces auto-detection with a simpler configure option.  Configuring gcc
with --disable-canonical-prefixes sets the default to -no-canonical-prefixes.
Without the configure option, the gcc default is to canonicalize prefixes,
retaining the behaviour of the past.

Tested both with and without configure --disable-canonical-prefixes for
gcc bootstrap.

Primarily needed for google/integration.  OK?

Secondarily, may be applicable to trunk.  Thoughts? 

gcc/ChangeLog.google:
2011-02-11  Simon Baldwin  <simonb@google.com>

	* doc/install.texi: Add --disable-canonical-prefixes documentation.
	* configure.ac: Add --disable-canonical-prefixes option.
	* configure: Rebuild.
	* config.in: Rebuild.
	* gcc.c (process_command): Remove auto-detection, set default
	prefix canonicalization mode from configure flag.

Google ref: 40029, 38719

Comments

Diego Novillo Feb. 11, 2011, 2:12 p.m. UTC | #1
On Fri, Feb 11, 2011 at 05:57, Simon Baldwin <simonb@google.com> wrote:

> gcc/ChangeLog.google:
> 2011-02-11  Simon Baldwin  <simonb@google.com>
>
>        * doc/install.texi: Add --disable-canonical-prefixes documentation.
>        * configure.ac: Add --disable-canonical-prefixes option.
>        * configure: Rebuild.
>        * config.in: Rebuild.
>        * gcc.c (process_command): Remove auto-detection, set default
>        prefix canonicalization mode from configure flag.

Much simpler, thanks.  This is OK for google/integration.

I'm inclined to say this should be OK for 4.7, but I would prefer our
configury maintainers to make the final decision.

Simon, for google/integration it may make sense to flip the sign of
the default for this flag.


Diego.
Joseph Myers Feb. 11, 2011, 5:37 p.m. UTC | #2
On Fri, 11 Feb 2011, Simon Baldwin wrote:

> Secondarily, may be applicable to trunk.  Thoughts? 

A patch for trunk would need to be submitted in self-contained form 
relative to trunk, not relative to a branch with the non-trunk code you 
are removing in this patch.
Simon Baldwin Feb. 11, 2011, 5:51 p.m. UTC | #3
On 11 February 2011 18:37, Joseph S. Myers <joseph@codesourcery.com> wrote:
>
> On Fri, 11 Feb 2011, Simon Baldwin wrote:
>
> > Secondarily, may be applicable to trunk.  Thoughts?
>
> A patch for trunk would need to be submitted in self-contained form
> relative to trunk, not relative to a branch with the non-trunk code you
> are removing in this patch.

Thanks, yes.  I have such a patch.

I was really asking if the method rather than this actual patch would
be useful in trunk.  If yes, I'll mail out the self-contained version
of it that applies cleanly and directly to trunk.

--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902
Ralf Wildenhues Feb. 11, 2011, 6:40 p.m. UTC | #4
* Simon Baldwin wrote on Fri, Feb 11, 2011 at 11:57:21AM CET:
> Secondarily, may be applicable to trunk.  Thoughts? 

I think others are better positioned to decide whether this is
desirable.  So only a couple of nits below.

> gcc/ChangeLog.google:
> 2011-02-11  Simon Baldwin  <simonb@google.com>
> 
> 	* doc/install.texi: Add --disable-canonical-prefixes documentation.
> 	* configure.ac: Add --disable-canonical-prefixes option.
> 	* configure: Rebuild.
> 	* config.in: Rebuild.
> 	* gcc.c (process_command): Remove auto-detection, set default
> 	prefix canonicalization mode from configure flag.

> --- gcc/doc/install.texi	(revision 169914)
> +++ gcc/doc/install.texi	(working copy)
> @@ -1697,6 +1697,16 @@ enabled together with @option{--enable-l
>  plugin for gold that allows the link-time optimizer to extract object
>  files with LTO information out of library archives.  See
>  @option{-flto} and @option{-fwhopr} for details.
> +
> +@item --enable-canonical-prefixes
> +@itemx --disable-canonical-prefixes
> +Enable prefix canonicalization for GCC files that the GCC driver locates
> +relative to its own path.  Canonicalized prefixes have any @code{/x/../}

@file{/x/../}

> +elements removed and symbolic links expanded.  This is enabled by default,
> +and may be disabled using @option{--disable-canonical-prefixes}.
> +See @option{-canonical-prefixes} or @option{-no-canonical-prefixes} for
> +more details, including how to override this configuration option when
> +compiling.
>  @end table

> --- gcc/configure.ac	(revision 169914)
> +++ gcc/configure.ac	(working copy)
> @@ -4684,6 +4684,18 @@ else
>  fi)
>  AC_SUBST(slibdir)
>  
> +# Set default prefix canonicalization.
> +
> +AC_ARG_ENABLE(canonical-prefixes,
> +[  --enable-canonical-prefixes
> +                          enable or disable prefix canonicalization],

Please use help string pretty printing, and document the default:

AC_ARG_ENABLE([canonical-prefixes],
  [AS_HELP_STRING([--disable-canonical-prefixes],
     [disable prefix canonicalization (enabled by default)])],
  [...]

> +[],
> +enable_canonical_prefixes=yes)
> +if test x"$enable_canonical_prefixes" = xyes; then
> +  AC_DEFINE(ENABLE_CANONICAL_PREFIXES,
> +            1, [Define to enable prefix canonicalization.])
> +fi

Thanks,
Ralf
Andreas Schwab Feb. 11, 2011, 7:44 p.m. UTC | #5
Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:

> Please use help string pretty printing, and document the default:
>
> AC_ARG_ENABLE([canonical-prefixes],
>   [AS_HELP_STRING([--disable-canonical-prefixes],
>      [disable prefix canonicalization (enabled by default)])],

IMHO by using --disable-canonical-prefixes the default is already
documented.

Andreas.
diff mbox

Patch

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 169914)
+++ gcc/doc/install.texi	(working copy)
@@ -1697,6 +1697,16 @@  enabled together with @option{--enable-l
 plugin for gold that allows the link-time optimizer to extract object
 files with LTO information out of library archives.  See
 @option{-flto} and @option{-fwhopr} for details.
+
+@item --enable-canonical-prefixes
+@itemx --disable-canonical-prefixes
+Enable prefix canonicalization for GCC files that the GCC driver locates
+relative to its own path.  Canonicalized prefixes have any @code{/x/../}
+elements removed and symbolic links expanded.  This is enabled by default,
+and may be disabled using @option{--disable-canonical-prefixes}.
+See @option{-canonical-prefixes} or @option{-no-canonical-prefixes} for
+more details, including how to override this configuration option when
+compiling.
 @end table
 
 @subheading Cross-Compiler-Specific Options
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 169914)
+++ gcc/configure	(working copy)
@@ -916,6 +916,7 @@  with_system_zlib
 enable_maintainer_mode
 enable_version_specific_runtime_libs
 with_slibdir
+enable_canonical_prefixes
 enable_plugin
 enable_libquadmath_support
 '
@@ -1627,6 +1628,8 @@  Optional Features:
   --enable-version-specific-runtime-libs
                           specify that runtime libraries should be
                           installed in a compiler-specific directory
+  --enable-canonical-prefixes
+                          enable or disable prefix canonicalization
   --enable-plugin         enable plugin support
   --disable-libquadmath-support
                           disable libquadmath support for Fortran
@@ -17583,7 +17586,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17586 "configure"
+#line 17589 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17689,7 +17692,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17692 "configure"
+#line 17695 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -26156,6 +26159,21 @@  fi
 
 
 
+# Set default prefix canonicalization.
+
+# Check whether --enable-canonical-prefixes was given.
+if test "${enable_canonical_prefixes+set}" = set; then :
+  enableval=$enable_canonical_prefixes;
+else
+  enable_canonical_prefixes=yes
+fi
+
+if test x"$enable_canonical_prefixes" = xyes; then
+
+$as_echo "#define ENABLE_CANONICAL_PREFIXES 1" >>confdefs.h
+
+fi
+
 # Substitute configuration variables
 
 
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c	(revision 169914)
+++ gcc/gcc.c	(working copy)
@@ -3537,33 +3537,11 @@  process_command (unsigned int decoded_op
     }
   if (! get_relative_prefix)
     {
-      /* If no canonical prefixes flags, try to set a suitable default.
-
-	 If the gcc driver is a symlink we differentiate two cases: a single
-	 symlink to the driver needing canonicalization; and a symlink farm
-	 with every file in the gcc installation a symlink to its actual
-	 content, for which we don't want canonicalization.  To choose, we
-	 check for a target-specific file relative to the canonicalized path
-	 to the gcc driver.  If found, assume canonicalizing is appropriate,
-	 otherwise don't canonicalize.
-
-	 If the driver is not a symlink, make_relative_prefix_ignore_links
-	 and make_relative_prefix act equivalently.  */
-
-      char *search_prefix = make_relative_prefix (decoded_options[0].arg,
-						  standard_bindir_prefix,
-						  standard_exec_prefix);
-      if (search_prefix)
-	{
-	  char *search = concat (search_prefix, spec_machine, NULL);
-	  if (access (search, R_OK) == 0)
-	    get_relative_prefix = make_relative_prefix;
-	  free (search);
-	  free (search_prefix);
-	}
-
-      if (! get_relative_prefix)
-	get_relative_prefix = make_relative_prefix_ignore_links;
+#ifdef ENABLE_CANONICAL_PREFIXES
+      get_relative_prefix = make_relative_prefix;
+#else
+      get_relative_prefix = make_relative_prefix_ignore_links;
+#endif
     }
 
   /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,
Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 169914)
+++ gcc/config.in	(working copy)
@@ -51,6 +51,12 @@ 
 #endif
 
 
+/* Define to enable prefix canonicalization. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_CANONICAL_PREFIXES
+#endif
+
+
 /* Define if you want more run-time sanity checks. This one gets a grab bag of
    miscellaneous but relatively cheap checks. */
 #ifndef USED_FOR_TARGET
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 169914)
+++ gcc/configure.ac	(working copy)
@@ -4684,6 +4684,18 @@  else
 fi)
 AC_SUBST(slibdir)
 
+# Set default prefix canonicalization.
+
+AC_ARG_ENABLE(canonical-prefixes,
+[  --enable-canonical-prefixes
+                          enable or disable prefix canonicalization],
+[],
+enable_canonical_prefixes=yes)
+if test x"$enable_canonical_prefixes" = xyes; then
+  AC_DEFINE(ENABLE_CANONICAL_PREFIXES,
+            1, [Define to enable prefix canonicalization.])
+fi
+
 # Substitute configuration variables
 AC_SUBST(subdirs)
 AC_SUBST(srcdir)