Patchwork Add --no-sysroot-suffix driver option

login
register
mail settings
Submitter Joseph S. Myers
Date Aug. 3, 2012, 3:22 p.m.
Message ID <Pine.LNX.4.64.1208031522160.25698@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/175006/
State New
Headers show

Comments

Joseph S. Myers - Aug. 3, 2012, 3:22 p.m.
Some GCC configurations use SYSROOT_SUFFIX_SPEC (generally generated
by gcc/config/print-sysroot-suffix.sh or a variant on that script) to
handle multilibs each of which uses its own sysroot to have its own
variant of the C library.  Usually such variants, built for different
-mcpu= or similar options, can share the same headers; where they
cannot (e.g. glibc and uClibc multilibs), SYSROOT_HEADERS_SUFFIX_SPEC
can be used to select the sysroot used for headers.

Although this sysroot suffix arrangement is convenient for building
tools with multiple C library variants, it's less convenient for a
user wishing to substitute their own sysroot using a --sysroot
option.  The --sysroot option refers to the toplevel sysroot
directory, and suffixes are added to it.  This is appropriate when
building GCC itself (a single --sysroot= option can be used when
building runtime libraries, and for each multilib it will end up using
the right subdirectory of the build-time toplevel sysroot
automatically).  But a user is more likely to have copied just the
subdirectory relevant to their system, and then maybe added extra
libraries to it, so in that case the automatic addition of the suffix
is inconvenient.

This patch adds a --no-sysroot-suffix option for use in the case where
a user has a single self-contained sysroot for a compiler configured
with sysroot suffixes.  Bootstrapped with no regressions on
x86_64-unknown-linux-gnu (as a sanity check, since that doesn't use
sysroots) and tested with a cross to sh-linux-gnu that the option does
have the desired effect of disabling suffixes and so allowing
single-sysroot copies to be used with --sysroot.  OK to commit?

2012-08-03  Joseph Myers  <joseph@codesourcery.com>

	* common.opt (--no-sysroot-suffix): New driver option.
	* doc/invoke.texi (--no-sysroot-suffix): Document.
	* gcc.c (driver_handle_option): Handle --no-sysroot-suffix as not
	needing spec processing.
	(main): Do not process sysroot suffixes if no_sysroot_suffix.
Joseph S. Myers - Aug. 9, 2012, 3:01 p.m.
Ping.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00182.html> is pending 
review.
Joseph S. Myers - Aug. 16, 2012, 3:45 p.m.
Ping^2.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00182.html> is still pending 
review.
Joseph S. Myers - Aug. 23, 2012, 2:43 p.m.
Ping^3.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00182.html> is still pending 
review.
Joseph S. Myers - Aug. 30, 2012, 7:49 p.m.
Ping^4.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00182.html> is still pending 
review.
Richard Guenther - Sept. 3, 2012, 10:49 a.m.
On Thu, Aug 23, 2012 at 4:43 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> Ping^3.  This patch
> <http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00182.html> is still pending
> review.

Ok.

Thanks,
Richard.

> --
> Joseph S. Myers
> joseph@codesourcery.com

Patch

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 190085)
+++ doc/invoke.texi	(working copy)
@@ -457,7 +457,7 @@  Objective-C and Objective-C++ Dialects}.
 @xref{Directory Options,,Options for Directory Search}.
 @gccoptlist{-B@var{prefix} -I@var{dir} -iplugindir=@var{dir} @gol
 -iquote@var{dir} -L@var{dir} -specs=@var{file} -I- @gol
---sysroot=@var{dir}}
+--sysroot=@var{dir} --no-sysroot-suffix}
 
 @item Machine Dependent Options
 @xref{Submodel Options,,Hardware Models and Configurations}.
@@ -9838,6 +9838,15 @@  for this option.  If your linker does not support
 header file aspect of @option{--sysroot} still works, but the
 library aspect does not.
 
+@item --no-sysroot-suffix
+@opindex no-sysroot-suffix
+For some targets, a suffix is added to the root directory specified
+with @option{--sysroot}, depending on the other options used, so that
+headers may for example be found in
+@file{@var{dir}/@var{suffix}/usr/include} instead of
+@file{@var{dir}/usr/include}.  This option disables the addition of
+such a suffix.
+
 @item -I-
 @opindex I-
 This option has been deprecated.  Please use @option{-iquote} instead for
Index: gcc.c
===================================================================
--- gcc.c	(revision 190085)
+++ gcc.c	(working copy)
@@ -3249,6 +3249,7 @@  driver_handle_option (struct gcc_options *opts,
       add_linker_option ("--target-help", 13);
       break;
 
+    case OPT__no_sysroot_suffix:
     case OPT_pass_exit_codes:
     case OPT_print_search_dirs:
     case OPT_print_file_name_:
@@ -6340,6 +6341,7 @@  main (int argc, char **argv)
 
   /* Process sysroot_suffix_spec.  */
   if (*sysroot_suffix_spec != 0
+      && !no_sysroot_suffix
       && do_spec_2 (sysroot_suffix_spec) == 0)
     {
       if (VEC_length (const_char_p, argbuf) > 1)
@@ -6363,6 +6365,7 @@  main (int argc, char **argv)
 
   /* Process sysroot_hdrs_suffix_spec.  */
   if (*sysroot_hdrs_suffix_spec != 0
+      && !no_sysroot_suffix
       && do_spec_2 (sysroot_hdrs_suffix_spec) == 0)
     {
       if (VEC_length (const_char_p, argbuf) > 1)
Index: common.opt
===================================================================
--- common.opt	(revision 190085)
+++ common.opt	(working copy)
@@ -291,6 +291,9 @@  Driver Alias(no-canonical-prefixes)
 -no-standard-libraries
 Driver Alias(nostdlib)
 
+-no-sysroot-suffix
+Driver Var(no_sysroot_suffix)
+
 -no-warnings
 Common Alias(w)