public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add `--with-install-sysroot=' configuration option
@ 2019-11-14  2:47 Maciej W. Rozycki
  2019-11-14  3:06 ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2019-11-14  2:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: libffi-discuss, golang-dev, zlib

Provide means, in the form of a `--with-install-sysroot=' configuration 
option, to override the default installation directory for target 
libraries, otherwise known as $toolexeclibdir.  This is so that it is 
possible to get newly-built libraries, particularly the shared ones, 
installed in a common sysroot, so that they can be readily used by the 
target system as their host libraries, possibly over NFS, without a need 
to manually copy them over from the currently hardcoded location they 
would otherwise be installed in.

The name of the configuration option is chosen such as to give it a 
meaning, rather than referring to obscure $toolexeclibdir.  Arguments 
are interpreted as with the `--with-sysroot=' option.  The default is 
the current value of $toolexeclibdir, so in the absence of the option 
from the invocation of the `configure' script the installation location 
for target libraries remains unchanged from the current arrangement.  
In the presence of the `--enable-version-specific-runtime-libs' option 
and for configurations building native GCC the option is ignored.

	libada/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libatomic/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libffi/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libgcc/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libgfortran/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libgo/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libgomp/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libhsail-rt/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libitm/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libobjc/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	liboffloadmic/
	* plugin/configure.ac: Handle `--with-install-sysroot='.
	* plugin/configure: Regenerate.
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libphobos/
	* m4/druntime.m4: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libquadmath/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libsanitizer/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libssp/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libstdc++-v3/
	* acinclude.m4: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libvtv/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	zlib/
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.
---
Hi,

 It used to be a common problem throughout much of my toolchain 
development involvement that GCC target shared libraries are not installed 
in a common sysroot along with other shared libraries, such as ones coming 
from glibc built at an earlier stage in a multi-stage toolchain bootstrap.  

 So far the common solution used to be copying the GCC target shared 
libraries manually with a separate build stage once `make install' has 
completed, but that can be error prone, requiring one to remember to run 
that extra stage if it is not run automatically for some reason, and also 
it requires tracking any changes in the installation, such as the addition 
of a new library.  Also changes in the list of multilibs built may require 
a further attention.

 I have therefore decided to solve the problem at its source and add a 
configuration option to let one specify an alternative installation 
location for target shared libraries, rather than having $toolexeclibdir 
hardcoded to $toolexecdir/lib.  Typically the value for the 
`--with-install-sysroot=' option will be the same as or correlated to the 
`--with-sysroot=' option, e.g. I use `--with-sysroot=/path/to/sysroot 
--with-install-sysroot=/path/to/sysroot/usr' with my `riscv64-linux-gnu' 
toolchain hosted on `x86_64-linux-gnu' for a good working result.

 I think it would be reasonable to apply this change throughout the tree 
in one commit, so that the option is interpreted consistently and also 
have it present across all the subdirectories, even those that (currently) 
only build as host libraries, so that the risk of having a library escape 
the new option in the future is minimised.  This could be e.g. if a 
library is enabled to be built as a target library or a configuration 
script is copied to handle a newly-added library.

 Therefore I have decided to post this proposal as a single change, 
especially as the same pattern repeats thoroughout (with the exception of 
libgcc/ that has an extra part related to `--with-slibdir='), though I 
realise it may actually have to be split due to our code management 
policies.

 Questions, comments, OK to apply?

  Maciej
---
 libada/configure                  |   30 ++++++++++++++++++++++-
 libada/configure.ac               |   25 +++++++++++++++++++
 libatomic/configure               |   34 ++++++++++++++++++++++++--
 libatomic/configure.ac            |   25 +++++++++++++++++++
 libffi/configure                  |   34 ++++++++++++++++++++++++--
 libffi/configure.ac               |   25 +++++++++++++++++++
 libgcc/configure                  |   39 +++++++++++++++++++++++++++++-
 libgcc/configure.ac               |   38 ++++++++++++++++++++++++++----
 libgfortran/configure             |   34 ++++++++++++++++++++++++--
 libgfortran/configure.ac          |   25 +++++++++++++++++++
 libgo/configure                   |   34 ++++++++++++++++++++++++--
 libgo/configure.ac                |   25 +++++++++++++++++++
 libgomp/configure                 |   34 ++++++++++++++++++++++++--
 libgomp/configure.ac              |   25 +++++++++++++++++++
 libhsail-rt/configure             |   34 ++++++++++++++++++++++++--
 libhsail-rt/configure.ac          |   25 +++++++++++++++++++
 libitm/configure                  |   34 ++++++++++++++++++++++++--
 libitm/configure.ac               |   25 +++++++++++++++++++
 libobjc/configure                 |   34 ++++++++++++++++++++++++--
 libobjc/configure.ac              |   25 +++++++++++++++++++
 liboffloadmic/configure           |   34 ++++++++++++++++++++++++--
 liboffloadmic/configure.ac        |   25 +++++++++++++++++++
 liboffloadmic/plugin/configure    |   34 ++++++++++++++++++++++++--
 liboffloadmic/plugin/configure.ac |   25 +++++++++++++++++++
 libphobos/configure               |   34 ++++++++++++++++++++++++--
 libphobos/m4/druntime.m4          |   25 +++++++++++++++++++
 libquadmath/configure             |   34 ++++++++++++++++++++++++--
 libquadmath/configure.ac          |   25 +++++++++++++++++++
 libsanitizer/configure            |   34 ++++++++++++++++++++++++--
 libsanitizer/configure.ac         |   25 +++++++++++++++++++
 libssp/configure                  |   34 ++++++++++++++++++++++++--
 libssp/configure.ac               |   25 +++++++++++++++++++
 libstdc++-v3/acinclude.m4         |   25 +++++++++++++++++++
 libstdc++-v3/configure            |   48 ++++++++++++++++++++++++++++++--------
 libvtv/configure                  |   34 ++++++++++++++++++++++++--
 libvtv/configure.ac               |   25 +++++++++++++++++++
 zlib/configure                    |   34 ++++++++++++++++++++++++--
 zlib/configure.ac                 |   25 +++++++++++++++++++
 38 files changed, 1066 insertions(+), 83 deletions(-)

gcc-install-sysroot.diff
Index: gcc/libada/configure
===================================================================
--- gcc.orig/libada/configure
+++ gcc/libada/configure
@@ -704,6 +704,7 @@ enable_option_checking
 with_build_libsubdir
 enable_version_specific_runtime_libs
 enable_maintainer_mode
+with_install_sysroot
 enable_multilib
 enable_shared
 with_system_libunwind
@@ -1339,6 +1340,8 @@ if test -n "$ac_init_help"; then
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-system-libunwind use installed libunwind
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
@@ -2249,6 +2252,24 @@ else
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Default to --enable-multilib
 # Check whether --enable-multilib was given.
 if test "${enable_multilib+set}" = set; then :
@@ -2301,7 +2322,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libada/configure.ac
===================================================================
--- gcc.orig/libada/configure.ac
+++ gcc/libada/configure.ac
@@ -67,6 +67,22 @@ AC_ARG_ENABLE([maintainer-mode],
   [MAINT='#'])
 AC_SUBST([MAINT])dnl
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 AM_ENABLE_MULTILIB(, ..)
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
@@ -83,7 +99,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libatomic/configure
===================================================================
--- gcc.orig/libatomic/configure
+++ gcc/libatomic/configure
@@ -794,6 +794,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1459,6 +1460,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3343,6 +3346,24 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3358,7 +3379,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11360,7 +11388,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11363 "configure"
+#line 11391 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11466,7 +11494,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11469 "configure"
+#line 11497 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libatomic/configure.ac
===================================================================
--- gcc.orig/libatomic/configure.ac
+++ gcc/libatomic/configure.ac
@@ -84,6 +84,22 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -99,7 +115,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libffi/configure
===================================================================
--- gcc.orig/libffi/configure
+++ gcc/libffi/configure
@@ -813,6 +813,7 @@ enable_debug
 enable_structs
 enable_raw_api
 enable_purify_safety
+with_install_sysroot
 enable_symvers
 with_gcc_major_version_only
 '
@@ -1476,6 +1477,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -11557,7 +11560,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11560 "configure"
+#line 11563 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11663,7 +11666,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11666 "configure"
+#line 11669 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16177,10 +16180,35 @@ $as_echo "#define USING_PURIFY 1" >>conf
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/libffi/configure.ac
===================================================================
--- gcc.orig/libffi/configure.ac
+++ gcc/libffi/configure.ac
@@ -332,10 +332,33 @@ AC_ARG_ENABLE(purify-safety,
     AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
   fi)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+                  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/libgcc/configure
===================================================================
--- gcc.orig/libgcc/configure
+++ gcc/libgcc/configure
@@ -705,6 +705,7 @@ enable_gcov
 enable_vtable_verify
 with_aix_soname
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_slibdir
 enable_maintainer_mode
 with_build_libsubdir
@@ -1369,6 +1370,8 @@ if test -n "$ac_init_help"; then
   --with-aix-soname=aix|svr4|both
                           shared library versioning (aka "SONAME") variant to
                           provide on AIX
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-slibdir=DIR      shared libraries in DIR LIBDIR
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-libunwind use installed libunwind
@@ -2464,6 +2467,24 @@ fi
 $as_echo "$version_specific_libs" >&6; }
 
 
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(host_noncanonical)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Check whether --with-slibdir was given.
 if test "${with_slibdir+set}" = set; then :
   withval=$with_slibdir; slibdir="$with_slibdir"
@@ -2471,7 +2492,14 @@ else
   if test "${version_specific_libs}" = yes; then
   slibdir='$(libsubdir)'
 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
-  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+  case ${with_install_sysroot} in
+    no)
+      slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+      ;;
+    *)
+      slibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   slibdir='$(libdir)'
 fi
@@ -2701,7 +2729,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgcc/configure.ac
===================================================================
--- gcc.orig/libgcc/configure.ac
+++ gcc/libgcc/configure.ac
@@ -113,16 +113,39 @@ AC_ARG_ENABLE(version-specific-runtime-l
 [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(host_noncanonical)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 AC_ARG_WITH(slibdir,
 [  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
 slibdir="$with_slibdir",
-if test "${version_specific_libs}" = yes; then
+[if test "${version_specific_libs}" = yes; then
   slibdir='$(libsubdir)'
 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
-  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+  case ${with_install_sysroot} in
+    no)
+      slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+      ;;
+    *)
+      slibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   slibdir='$(libdir)'
-fi)
+fi])
 AC_SUBST(slibdir)
 
 # Command-line options.
@@ -168,7 +191,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgfortran/configure
===================================================================
--- gcc.orig/libgfortran/configure
+++ gcc/libgfortran/configure
@@ -809,6 +809,7 @@ enable_silent_rules
 enable_maintainer_mode
 enable_multilib
 enable_dependency_tracking
+with_install_sysroot
 enable_cet
 enable_symvers
 with_gnu_ld
@@ -1480,6 +1481,8 @@ if test -n "$ac_init_help"; then
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
@@ -5173,6 +5176,24 @@ $as_echo "$ac_cv_safe_to_define___extens
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -5188,7 +5209,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12692,7 +12720,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12695 "configure"
+#line 12723 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12798,7 +12826,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12801 "configure"
+#line 12829 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libgfortran/configure.ac
===================================================================
--- gcc.orig/libgfortran/configure.ac
+++ gcc/libgfortran/configure.ac
@@ -86,6 +86,22 @@ fi
 
 AC_USE_SYSTEM_EXTENSIONS
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -101,7 +117,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgo/configure
===================================================================
--- gcc.orig/libgo/configure
+++ gcc/libgo/configure
@@ -849,6 +849,7 @@ enable_fast_install
 enable_libtool_lock
 enable_werror
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_libffi
 with_libatomic
 with_system_libunwind
@@ -1503,6 +1504,8 @@ if test -n "$ac_init_help"; then
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --without-libffi        don't use libffi
   --without-libatomic     don't use libatomic
   --with-system-libunwind use installed libunwind
@@ -11486,7 +11489,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11489 "configure"
+#line 11492 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11592,7 +11595,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11595 "configure"
+#line 11598 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13800,6 +13803,24 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Version-specific runtime libs processing.
 if test $version_specific_libs = yes; then
   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -13811,7 +13832,14 @@ fi
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
-  nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+  case ${with_install_sysroot} in
+    no)
+      nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+      ;;
+    *)
+      nover_glibgo_toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
   nover_glibgo_toolexeclibdir='${libdir}'
Index: gcc/libgo/configure.ac
===================================================================
--- gcc.orig/libgo/configure.ac
+++ gcc/libgo/configure.ac
@@ -80,6 +80,22 @@ AC_ARG_ENABLE([version-specific-runtime-
   [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+                  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Version-specific runtime libs processing.
 if test $version_specific_libs = yes; then
   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -91,7 +107,14 @@ fi
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
-  nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+  case ${with_install_sysroot} in
+    no)
+      nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+      ;;
+    *)
+      nover_glibgo_toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
   nover_glibgo_toolexeclibdir='${libdir}'
Index: gcc/libgomp/configure
===================================================================
--- gcc.orig/libgomp/configure
+++ gcc/libgomp/configure
@@ -826,6 +826,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1505,6 +1506,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3501,6 +3504,24 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3516,7 +3537,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11405,7 +11433,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11408 "configure"
+#line 11436 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11511,7 +11539,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11514 "configure"
+#line 11542 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libgomp/configure.ac
===================================================================
--- gcc.orig/libgomp/configure.ac
+++ gcc/libgomp/configure.ac
@@ -64,6 +64,22 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -79,7 +95,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libhsail-rt/configure
===================================================================
--- gcc.orig/libhsail-rt/configure
+++ gcc/libhsail-rt/configure
@@ -773,6 +773,7 @@ enable_silent_rules
 enable_maintainer_mode
 enable_dependency_tracking
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1435,6 +1436,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4653,6 +4656,24 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_version_specific_runtime_libs" >&5
 $as_echo "$enable_version_specific_runtime_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -4668,7 +4689,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11212,7 +11240,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11215 "configure"
+#line 11243 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11318,7 +11346,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11321 "configure"
+#line 11349 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libhsail-rt/configure.ac
===================================================================
--- gcc.orig/libhsail-rt/configure.ac
+++ gcc/libhsail-rt/configure.ac
@@ -69,6 +69,22 @@ ler-specific directory]),
   [enable_version_specific_runtime_libs=no])
 AC_MSG_RESULT($enable_version_specific_runtime_libs)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -84,7 +100,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libitm/configure
===================================================================
--- gcc.orig/libitm/configure
+++ gcc/libitm/configure
@@ -802,6 +802,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1472,6 +1473,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3527,6 +3530,24 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3542,7 +3563,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12037,7 +12065,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12040 "configure"
+#line 12068 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12143,7 +12171,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12146 "configure"
+#line 12174 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libitm/configure.ac
===================================================================
--- gcc.orig/libitm/configure.ac
+++ gcc/libitm/configure.ac
@@ -78,6 +78,22 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -93,7 +109,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libobjc/configure
===================================================================
--- gcc.orig/libobjc/configure
+++ gcc/libobjc/configure
@@ -746,6 +746,7 @@ with_target_subdir
 with_cross_host
 enable_version_specific_runtime_libs
 enable_multilib
+with_install_sysroot
 enable_cet
 enable_maintainer_mode
 enable_shared
@@ -1402,6 +1403,8 @@ if test -n "$ac_init_help"; then
   --with-target-subdir=SUBDIR
                            configuring in a subdirectory
   --with-cross-host=HOST  configuring with a cross compiler
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -2502,6 +2505,24 @@ case $srcdir in
 esac
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_noncanonical)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -2517,7 +2538,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
@@ -10748,7 +10776,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10751 "configure"
+#line 10779 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10854,7 +10882,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10857 "configure"
+#line 10885 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libobjc/configure.ac
===================================================================
--- gcc.orig/libobjc/configure.ac
+++ gcc/libobjc/configure.ac
@@ -76,6 +76,22 @@ case $srcdir in
 esac
 AC_SUBST(glibcpp_srcdir)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_noncanonical)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -91,7 +107,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/liboffloadmic/configure
===================================================================
--- gcc.orig/liboffloadmic/configure
+++ gcc/liboffloadmic/configure
@@ -775,6 +775,7 @@ enable_maintainer_mode
 enable_dependency_tracking
 enable_multilib
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1437,6 +1438,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -5293,6 +5296,24 @@ else
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -5308,7 +5329,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11403,7 +11431,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11406 "configure"
+#line 11434 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11509,7 +11537,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11512 "configure"
+#line 11540 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/liboffloadmic/configure.ac
===================================================================
--- gcc.orig/liboffloadmic/configure.ac
+++ gcc/liboffloadmic/configure.ac
@@ -79,6 +79,22 @@ case "$enable_liboffloadmic" in
 esac
 AM_CONDITIONAL(LIBOFFLOADMIC_HOST, [test x"$enable_liboffloadmic" = xhost])
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -94,7 +110,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/liboffloadmic/plugin/configure
===================================================================
--- gcc.orig/liboffloadmic/plugin/configure
+++ gcc/liboffloadmic/plugin/configure
@@ -771,6 +771,7 @@ enable_maintainer_mode
 enable_dependency_tracking
 enable_multilib
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1434,6 +1435,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4542,6 +4545,24 @@ fi
 $as_echo "$enable_version_specific_runtime_libs" >&6; }
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -4557,7 +4578,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11050,7 +11078,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11053 "configure"
+#line 11081 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11156,7 +11184,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11159 "configure"
+#line 11187 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/liboffloadmic/plugin/configure.ac
===================================================================
--- gcc.orig/liboffloadmic/plugin/configure.ac
+++ gcc/liboffloadmic/plugin/configure.ac
@@ -95,6 +95,22 @@ AC_ARG_ENABLE([version-specific-runtime-
 AC_MSG_RESULT($enable_version_specific_runtime_libs)
 
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -110,7 +126,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libphobos/configure
===================================================================
--- gcc.orig/libphobos/configure
+++ gcc/libphobos/configure
@@ -837,6 +837,7 @@ with_libbacktrace
 with_target_system_zlib
 with_cross_host
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_libphobos
 '
       ac_precious_vars='build_alias
@@ -1504,6 +1505,8 @@ if test -n "$ac_init_help"; then
   --with-target-system-zlib={yes,no,auto}
                           use installed libz (default: no)
   --with-cross-host=HOST  configuring with a cross compiler
+  --with-install-sysroot=DIR
+                          install libraries within DIR
 
 Some influential environment variables:
   CC          C compiler command
@@ -11640,7 +11643,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11643 "configure"
+#line 11646 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11746,7 +11749,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11749 "configure"
+#line 11752 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15237,6 +15240,24 @@ fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot;   case ${with_install_sysroot} in
+    /)
+      ;;
+    */)
+      with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+      ;;
+    yes)
+      with_install_sysroot='${exec_prefix}/${host_alias}/sys-root'
+      ;;
+  esac
+else
+  with_install_sysroot=no
+fi
+
+
   # Version-specific runtime libs processing.
   if test $version_specific_libs = yes; then
     libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -15246,7 +15267,14 @@ $as_echo "$version_specific_libs" >&6; }
     # Install a library built with a cross compiler in tooldir, not libdir.
     if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
       libphobos_toolexecdir='${exec_prefix}/${host_alias}'
-      libphobos_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  libphobos_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  libphobos_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
       libphobos_toolexeclibdir='${libdir}'
Index: gcc/libphobos/m4/druntime.m4
===================================================================
--- gcc.orig/libphobos/m4/druntime.m4
+++ gcc/libphobos/m4/druntime.m4
@@ -80,6 +80,22 @@ AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
     [version_specific_libs=no])
   AC_MSG_RESULT($version_specific_libs)
 
+  AC_ARG_WITH(install-sysroot,
+    [AS_HELP_STRING([--with-install-sysroot=DIR],
+		    [install libraries within DIR])],
+    [dnl
+  case ${with_install_sysroot} in
+    /)
+      ;;
+    */)
+      with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+      ;;
+    yes)
+      with_install_sysroot='${exec_prefix}/${host_alias}/sys-root'
+      ;;
+  esac],
+    [with_install_sysroot=no])
+
   # Version-specific runtime libs processing.
   if test $version_specific_libs = yes; then
     libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -89,7 +105,14 @@ AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
     # Install a library built with a cross compiler in tooldir, not libdir.
     if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
       libphobos_toolexecdir='${exec_prefix}/${host_alias}'
-      libphobos_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  libphobos_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  libphobos_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
       libphobos_toolexeclibdir='${libdir}'
Index: gcc/libquadmath/configure
===================================================================
--- gcc.orig/libquadmath/configure
+++ gcc/libquadmath/configure
@@ -786,6 +786,7 @@ enable_fast_install
 with_gnu_ld
 enable_libtool_lock
 enable_maintainer_mode
+with_install_sysroot
 enable_symvers
 enable_cet
 enable_generated_files_in_srcdir
@@ -1451,6 +1452,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -10810,7 +10813,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10813 "configure"
+#line 10816 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10916,7 +10919,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10919 "configure"
+#line 10922 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12088,6 +12091,24 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -12103,7 +12124,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libquadmath/configure.ac
===================================================================
--- gcc.orig/libquadmath/configure.ac
+++ gcc/libquadmath/configure.ac
@@ -82,6 +82,22 @@ if test "x$GCC" != "xyes"; then
 fi
 AC_PROG_CPP
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -97,7 +113,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libsanitizer/configure
===================================================================
--- gcc.orig/libsanitizer/configure
+++ gcc/libsanitizer/configure
@@ -806,6 +806,7 @@ enable_version_specific_runtime_libs
 enable_dependency_tracking
 enable_silent_rules
 enable_maintainer_mode
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1470,6 +1471,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -5012,6 +5015,24 @@ fi
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -5027,7 +5048,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12334,7 +12362,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12337 "configure"
+#line 12365 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12440,7 +12468,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12443 "configure"
+#line 12471 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libsanitizer/configure.ac
===================================================================
--- gcc.orig/libsanitizer/configure.ac
+++ gcc/libsanitizer/configure.ac
@@ -29,6 +29,22 @@ GCC_LIBSTDCXX_RAW_CXX_FLAGS
 AM_INIT_AUTOMAKE(foreign no-dist)
 AM_MAINTAINER_MODE
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -44,7 +60,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libssp/configure
===================================================================
--- gcc.orig/libssp/configure
+++ gcc/libssp/configure
@@ -781,6 +781,7 @@ with_pic
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+with_install_sysroot
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1432,6 +1433,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -10992,7 +10995,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10995 "configure"
+#line 10998 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11098,7 +11101,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11101 "configure"
+#line 11104 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11360,6 +11363,24 @@ esac
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -11375,7 +11396,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libssp/configure.ac
===================================================================
--- gcc.orig/libssp/configure.ac
+++ gcc/libssp/configure.ac
@@ -163,6 +163,22 @@ ACX_LT_HOST_FLAGS
 AC_SUBST(enable_shared)
 AC_SUBST(enable_static)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -178,7 +194,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libstdc++-v3/acinclude.m4
===================================================================
--- gcc.orig/libstdc++-v3/acinclude.m4
+++ gcc/libstdc++-v3/acinclude.m4
@@ -782,6 +782,22 @@ AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO],
     [version_specific_libs=no])
   AC_MSG_RESULT($version_specific_libs)
 
+  AC_ARG_WITH(install-sysroot,
+    [AS_HELP_STRING([--with-install-sysroot=DIR],
+		    [install libraries within DIR])],
+    [dnl
+  case ${with_install_sysroot} in
+    /)
+      ;;
+    */)
+      with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+      ;;
+    yes)
+      with_install_sysroot='${exec_prefix}/${host_alias}/sys-root'
+      ;;
+  esac],
+    [with_install_sysroot=no])
+
   # Default case for install directory for include files.
   if test $version_specific_libs = no && test $gxx_include_dir = no; then
     gxx_include_dir='include/c++/${gcc_version}'
@@ -812,7 +828,14 @@ AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO],
     if test -n "$with_cross_host" &&
        test x"$with_cross_host" != x"no"; then
       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
-      glibcxx_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  glibcxx_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  glibcxx_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
       glibcxx_toolexeclibdir='${libdir}'
Index: gcc/libstdc++-v3/configure
===================================================================
--- gcc.orig/libstdc++-v3/configure
+++ gcc/libstdc++-v3/configure
@@ -942,6 +942,7 @@ enable_libstdcxx_filesystem_ts
 enable_cet
 with_gxx_include_dir
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1669,6 +1670,8 @@ if test -n "$ac_init_help"; then
                           set the std::string ABI to use by default
   --with-gxx-include-dir=DIR
                           installation directory for include files
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -12053,7 +12056,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12056 "configure"
+#line 12059 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12159,7 +12162,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12162 "configure"
+#line 12165 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15851,7 +15854,7 @@ $as_echo "$glibcxx_cv_atomic_long_long"
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 15854 "configure"
+#line 15857 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15886,7 +15889,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6;
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15889 "configure"
+#line 15892 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -15921,7 +15924,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6;
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15924 "configure"
+#line 15927 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -15957,7 +15960,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15960 "configure"
+#line 15963 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16110,7 +16113,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16113 "configure"
+#line 16116 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16152,7 +16155,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16155 "configure"
+#line 16158 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -16186,7 +16189,7 @@ $as_echo "$enable_int128" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16189 "configure"
+#line 16192 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -76493,6 +76496,24 @@ fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot;   case ${with_install_sysroot} in
+    /)
+      ;;
+    */)
+      with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+      ;;
+    yes)
+      with_install_sysroot='${exec_prefix}/${host_alias}/sys-root'
+      ;;
+  esac
+else
+  with_install_sysroot=no
+fi
+
+
   # Default case for install directory for include files.
   if test $version_specific_libs = no && test $gxx_include_dir = no; then
     gxx_include_dir='include/c++/${gcc_version}'
@@ -76523,7 +76544,14 @@ $as_echo "$version_specific_libs" >&6; }
     if test -n "$with_cross_host" &&
        test x"$with_cross_host" != x"no"; then
       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
-      glibcxx_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  glibcxx_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  glibcxx_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
       glibcxx_toolexeclibdir='${libdir}'
Index: gcc/libvtv/configure
===================================================================
--- gcc.orig/libvtv/configure
+++ gcc/libvtv/configure
@@ -790,6 +790,7 @@ enable_vtable_verify
 enable_dependency_tracking
 enable_silent_rules
 enable_maintainer_mode
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1450,6 +1451,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4807,6 +4810,24 @@ fi
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -4822,7 +4843,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12235,7 +12263,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12238 "configure"
+#line 12266 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12341,7 +12369,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12344 "configure"
+#line 12372 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libvtv/configure.ac
===================================================================
--- gcc.orig/libvtv/configure.ac
+++ gcc/libvtv/configure.ac
@@ -78,6 +78,22 @@ AM_MAINTAINER_MODE
 
 LIBVTV_CONFIGURE
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -93,7 +109,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/zlib/configure
===================================================================
--- gcc.orig/zlib/configure
+++ gcc/zlib/configure
@@ -774,6 +774,7 @@ with_pic
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+with_install_sysroot
 enable_host_shared
 '
       ac_precious_vars='build_alias
@@ -1427,6 +1428,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
 
 Some influential environment variables:
   CC          C compiler command
@@ -10648,7 +10651,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10651 "configure"
+#line 10654 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10754,7 +10757,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10757 "configure"
+#line 10760 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11379,10 +11382,35 @@ fi
 done
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/zlib/configure.ac
===================================================================
--- gcc.orig/zlib/configure.ac
+++ gcc/zlib/configure.ac
@@ -81,10 +81,33 @@ fi
 
 AC_CHECK_HEADERS(unistd.h)
 
+AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+                  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add `--with-install-sysroot=' configuration option
  2019-11-14  2:47 [PATCH] Add `--with-install-sysroot=' configuration option Maciej W. Rozycki
@ 2019-11-14  3:06 ` Joseph Myers
  2019-11-18  2:04   ` [PATCH v2] " Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2019-11-14  3:06 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Thu, 14 Nov 2019, Maciej W. Rozycki wrote:

>  Questions, comments, OK to apply?

1. This needs documentation in install.texi.

2. A common macro in config/ would be better than duplicating code in each 
configure.ac file.

3. To confirm (this should be made clear in the documentation), this is 
nonsensical given --enable-version-specific-runtime-libs?  If so, maybe 
the configure macro should give an error for the combination if possible.

4. How does this interact with sysroot suffixes (again, this should be 
made clear in the documentation)?

5. With this option, does the multilib OS directory (e.g. "../lib64") get 
used for anything at all outside the sysroot?  If not, is it valid with 
this option to have the same value of that directory for more than one 
multilib (that use different sysroot suffixes)?

(The basic complication in configurations with multiple sysroots is that 
the multilib OS directory currently gets used outside the sysroot, so 
needs to be unique.  But you also want a version that's only unique inside 
the sysroot - if you have sysroots for different CPU variants, each should 
have libraries in e.g. lib64 inside that sysroot.  At present, in such 
cases, you need to set STARTFILE_PREFIX_SPEC for the libraries to be found 
at link time inside the sysroot; see 
<https://gcc.gnu.org/ml/gcc/2016-12/msg00013.html> for some commentary on 
that.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-14  3:06 ` Joseph Myers
@ 2019-11-18  2:04   ` Maciej W. Rozycki
  2019-11-19  0:11     ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2019-11-18  2:04 UTC (permalink / raw)
  To: Joseph Myers, gcc-patches; +Cc: libffi-discuss, golang-dev, zlib

Provide means, in the form of a `--with-install-sysroot=' configuration 
option, to override the default installation directory for target 
libraries, otherwise known as $toolexeclibdir.  This is so that it is 
possible to get newly-built libraries, particularly the shared ones, 
installed in a common sysroot, so that they can be readily used by the 
target system as their host libraries, possibly over NFS, without a need 
to manually copy them over from the currently hardcoded location they 
would otherwise be installed in.

The name of the configuration option is chosen such as to give it a 
meaning, rather than referring to obscure $toolexeclibdir.  Arguments 
are interpreted as with the `--with-sysroot=' option.  The default is 
the current value of $toolexeclibdir, so in the absence of the option 
from the invocation of the `configure' script the installation location 
for target libraries remains unchanged from the current arrangement.  
In the presence of the `--enable-version-specific-runtime-libs' option 
and for configurations building native GCC the option is ignored.

	config/
	* install-sysroot.m4: New file.

	gcc/
	* doc/install.texi (Cross-Compiler-Specific Options): Document 
	`--with-install-sysroot' option.

	libada/
	* Makefile.in (configure_deps): Add `install-sysroot.m4'.
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libatomic/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libffi/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* include/Makefile.in: Regenerate.
	* man/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libgcc/
	* Makefile.in (configure_deps): Add `install-sysroot.m4'.
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	libgfortran/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libgo/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libgomp/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libhsail-rt/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libitm/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libobjc/
	* Makefile.in (aclocal_deps): Add `install-sysroot.m4'.
	* aclocal.m4: Include `install-sysroot.m4'.
	* configure.ac: Handle `--with-install-sysroot='.
	* configure: Regenerate.

	liboffloadmic/
	* plugin/configure.ac: Handle `--with-install-sysroot='.
	* plugin/Makefile.in: Regenerate.
	* plugin/aclocal.m4: Regenerate.
	* plugin/configure: Regenerate.
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libphobos/
	* m4/druntime.m4: Handle `--with-install-sysroot='.
	* m4/Makefile.in: Regenerate.
	* libdruntime/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libquadmath/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libsanitizer/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* asan/Makefile.in: Regenerate.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

	libssp/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

	libstdc++-v3/
	* acinclude.m4: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libvtv/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	zlib/
	* configure.ac: Handle `--with-install-sysroot='.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
---
Hi Joseph,

 Thank you for your review.

On Thu, 14 Nov 2019, Joseph Myers wrote:

> >  Questions, comments, OK to apply?
> 
> 1. This needs documentation in install.texi.

 Good point, I forgot about that document.

> 2. A common macro in config/ would be better than duplicating code in each 
> configure.ac file.

 I guess at this point I could factor out the AC_ARG_WITH invocation.

 There is a minor issue with different subdirs using different ways to 
refer to the machine alias, specifically one of: $(target_noncanonical), 
$(target_alias), $(host_noncanonical), ${host_alias}.  As none of the 
libraries concerned has a notion of a target (possibly different from the 
host a library has been configured for; unlikely e.g. libbfd) and GCC's 
target becomes the host they get configured for, they should all really 
use $(host_noncanonical), and I gather the current inconsistency is 
historical baggage, possibly from someone's misunderstanding how the 
build/host/target concept has been formulated.

 That I think is however material for a separate clean-up, to be applied 
throughout the respective `configure' scripts and possibly other files 
(Makefiles).  So instead I have provided GCC_WITH_INSTALL_SYSROOT with an 
argument that passes the form consistent with the rest of the `configure' 
script in question down to the expansion.  When the time comes and the 
clean-up mentioned is done the argument can be removed.

 The rest of the code added is in the middle of existing mostly though not 
completely duplicated code.  I think it would benefit from a clean-up too, 
but I'd suggest it as a separate change.

> 3. To confirm (this should be made clear in the documentation), this is 
> nonsensical given --enable-version-specific-runtime-libs?  If so, maybe 
> the configure macro should give an error for the combination if possible.

 Now that you mention it I have given it some thought and it seems 
infeasible to me, specifically because we currently have mixed defaults 
for the `--enable-version-specific-runtime-libs' option; for historical 
reasons it defaults to `yes' for libada/ and to `no' for other subdirs.  
I think it makes sense to allow people changing the installation directory 
for subdirs that default to `no' without requiring them to flip the 
setting for libada/.

 NB documentation for the `--enable-version-specific-runtime-libs' option 
does not appear to be up to date WRT subdirs supported; I'll see if I can 
squeeze out some time to make a suitable change.

> 4. How does this interact with sysroot suffixes (again, this should be 
> made clear in the documentation)?

 There is no interaction, the patch merely changes where the libraries are 
installed.  If the installation sysroot directory chosen is not one known 
by the GCC driver, then the newly-installed target libraries won't be 
automatically used (that of course can be changed with the appropriate use 
of the `-B', `-L' and `--sysroot=' driver options).

> 5. With this option, does the multilib OS directory (e.g. "../lib64") get 
> used for anything at all outside the sysroot?  If not, is it valid with 
> this option to have the same value of that directory for more than one 
> multilib (that use different sysroot suffixes)?

 Again, the option does not affect the library search path used by the GCC 
driver; any multilib OS directory paths are applied as appropriate by the 
driver to the library paths chosen.

> (The basic complication in configurations with multiple sysroots is that 
> the multilib OS directory currently gets used outside the sysroot, so 
> needs to be unique.  But you also want a version that's only unique inside 
> the sysroot - if you have sysroots for different CPU variants, each should 
> have libraries in e.g. lib64 inside that sysroot.  At present, in such 
> cases, you need to set STARTFILE_PREFIX_SPEC for the libraries to be found 
> at link time inside the sysroot; see 
> <https://gcc.gnu.org/ml/gcc/2016-12/msg00013.html> for some commentary on 
> that.)

 I have given it all some thought and I have come to the conclusion that 
your questions #4 and #5 are really tangential to my proposed change, and 
I believe we need not consider them to move forward with the change.

 This is because in the `--enable-version-specific-runtime-libs=no' case 
our installation recipes for files that end up in $toolexeclibdir apply 
the same $multi_os_directory transformation whether $toolexeclibdir is 
derived from $(libdir) or $(exec_prefix)/$(target_noncanonical)/lib.  So 
either the GCC driver handles both of these cases right already (and I 
believe it does, as `for_each_path' appears to be consistently called 
throughout `gcc.c') or it does not, however my proposed change does not 
affect it, and therefore I think we need not determine it to proceed with 
the proposed change.

 Here's an updated change, beside verifying it to recreate the same 
installation directory structure as v1 did I have checked generated 
`gccinstall.info' and `gccinstall.pdf' files as well.

 Questions, comments, OK to apply?

  Maciej

Changes from v1:

- The handling of `--with-install-sysroot=' moved to install-sysroot.m4.

- Documentation added for `--with-install-sysroot=' to install.texi.
---
 config/install-sysroot.m4                 |   35 +++++++++++++++++++++
 gcc/doc/install.texi                      |   11 ++++++
 libada/Makefile.in                        |    1 
 libada/configure                          |   31 ++++++++++++++++++
 libada/configure.ac                       |   12 ++++++-
 libatomic/Makefile.in                     |    1 
 libatomic/aclocal.m4                      |    1 
 libatomic/configure                       |   35 +++++++++++++++++++--
 libatomic/configure.ac                    |   11 ++++++
 libatomic/testsuite/Makefile.in           |    1 
 libffi/Makefile.in                        |    1 
 libffi/aclocal.m4                         |    1 
 libffi/configure                          |   35 +++++++++++++++++++--
 libffi/configure.ac                       |   11 ++++++
 libffi/include/Makefile.in                |    1 
 libffi/man/Makefile.in                    |    1 
 libffi/testsuite/Makefile.in              |    1 
 libgcc/Makefile.in                        |    1 
 libgcc/configure                          |   40 +++++++++++++++++++++++-
 libgcc/configure.ac                       |   25 ++++++++++++---
 libgfortran/Makefile.in                   |    1 
 libgfortran/aclocal.m4                    |    1 
 libgfortran/configure                     |   35 +++++++++++++++++++--
 libgfortran/configure.ac                  |   11 ++++++
 libgo/Makefile.in                         |    1 
 libgo/aclocal.m4                          |    1 
 libgo/configure                           |   35 +++++++++++++++++++--
 libgo/configure.ac                        |   11 ++++++
 libgo/testsuite/Makefile.in               |    1 
 libgomp/Makefile.in                       |    1 
 libgomp/aclocal.m4                        |    1 
 libgomp/configure                         |   35 +++++++++++++++++++--
 libgomp/configure.ac                      |   11 ++++++
 libgomp/testsuite/Makefile.in             |    1 
 libhsail-rt/Makefile.in                   |    1 
 libhsail-rt/aclocal.m4                    |    1 
 libhsail-rt/configure                     |   35 +++++++++++++++++++--
 libhsail-rt/configure.ac                  |   11 ++++++
 libitm/Makefile.in                        |    1 
 libitm/aclocal.m4                         |    1 
 libitm/configure                          |   35 +++++++++++++++++++--
 libitm/configure.ac                       |   11 ++++++
 libitm/testsuite/Makefile.in              |    1 
 libobjc/Makefile.in                       |    1 
 libobjc/aclocal.m4                        |    1 
 libobjc/configure                         |   35 +++++++++++++++++++--
 libobjc/configure.ac                      |   11 ++++++
 liboffloadmic/Makefile.in                 |    1 
 liboffloadmic/aclocal.m4                  |    1 
 liboffloadmic/configure                   |   35 +++++++++++++++++++--
 liboffloadmic/configure.ac                |   11 ++++++
 liboffloadmic/plugin/Makefile.in          |    1 
 liboffloadmic/plugin/aclocal.m4           |    1 
 liboffloadmic/plugin/configure            |   35 +++++++++++++++++++--
 liboffloadmic/plugin/configure.ac         |   11 ++++++
 libphobos/Makefile.in                     |    1 
 libphobos/aclocal.m4                      |    1 
 libphobos/configure                       |   35 +++++++++++++++++++--
 libphobos/libdruntime/Makefile.in         |    1 
 libphobos/m4/druntime.m4                  |   11 ++++++
 libphobos/src/Makefile.in                 |    1 
 libphobos/testsuite/Makefile.in           |    1 
 libquadmath/Makefile.in                   |    1 
 libquadmath/aclocal.m4                    |    1 
 libquadmath/configure                     |   35 +++++++++++++++++++--
 libquadmath/configure.ac                  |   11 ++++++
 libsanitizer/Makefile.in                  |    1 
 libsanitizer/aclocal.m4                   |    1 
 libsanitizer/asan/Makefile.in             |    1 
 libsanitizer/configure                    |   35 +++++++++++++++++++--
 libsanitizer/configure.ac                 |   11 ++++++
 libsanitizer/interception/Makefile.in     |    1 
 libsanitizer/libbacktrace/Makefile.in     |    1 
 libsanitizer/lsan/Makefile.in             |    1 
 libsanitizer/sanitizer_common/Makefile.in |    1 
 libsanitizer/tsan/Makefile.in             |    1 
 libsanitizer/ubsan/Makefile.in            |    1 
 libssp/Makefile.in                        |    1 
 libssp/aclocal.m4                         |    1 
 libssp/configure                          |   35 +++++++++++++++++++--
 libssp/configure.ac                       |   11 ++++++
 libstdc++-v3/Makefile.in                  |    1 
 libstdc++-v3/acinclude.m4                 |   11 ++++++
 libstdc++-v3/aclocal.m4                   |    1 
 libstdc++-v3/configure                    |   49 +++++++++++++++++++++++-------
 libstdc++-v3/doc/Makefile.in              |    1 
 libstdc++-v3/include/Makefile.in          |    1 
 libstdc++-v3/libsupc++/Makefile.in        |    1 
 libstdc++-v3/po/Makefile.in               |    1 
 libstdc++-v3/python/Makefile.in           |    1 
 libstdc++-v3/src/Makefile.in              |    1 
 libstdc++-v3/src/c++11/Makefile.in        |    1 
 libstdc++-v3/src/c++17/Makefile.in        |    1 
 libstdc++-v3/src/c++98/Makefile.in        |    1 
 libstdc++-v3/src/filesystem/Makefile.in   |    1 
 libstdc++-v3/testsuite/Makefile.in        |    1 
 libvtv/Makefile.in                        |    1 
 libvtv/aclocal.m4                         |    1 
 libvtv/configure                          |   35 +++++++++++++++++++--
 libvtv/configure.ac                       |   11 ++++++
 libvtv/testsuite/Makefile.in              |    1 
 zlib/Makefile.in                          |    1 
 zlib/aclocal.m4                           |    1 
 zlib/configure                            |   35 +++++++++++++++++++--
 zlib/configure.ac                         |   11 ++++++
 105 files changed, 932 insertions(+), 83 deletions(-)

gcc-install-sysroot.diff
Index: gcc/config/install-sysroot.m4
===================================================================
--- /dev/null
+++ gcc/config/install-sysroot.m4
@@ -0,0 +1,35 @@
+dnl Install sysroot support.
+dnl Copyright (C) 2019  Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+
+# GCC_WITH_INSTALL_SYSROOT([machine-alias])
+AC_DEFUN([GCC_WITH_INSTALL_SYSROOT],
+[AC_ARG_WITH(install-sysroot,
+  [AS_HELP_STRING([--with-install-sysroot=DIR],
+		  [install libraries within DIR])],
+  [dnl
+case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$1/sys-root'
+    ;;
+esac],
+  [with_install_sysroot=no])
+])
Index: gcc/gcc/doc/install.texi
===================================================================
--- gcc.orig/gcc/doc/install.texi
+++ gcc/gcc/doc/install.texi
@@ -2245,6 +2245,17 @@ If you specify the @option{--with-native
 option then the compiler will search that directory within @var{dirname} for
 native system headers rather than the default @file{/usr/include}.
 
+@item --with-install-sysroot
+@itemx --with-install-sysroot=@var{dir}
+Tells GCC to install target libraries in @var{dir} rather than
+@option{$@{gcc_tooldir@}/lib} except where the use of a compiler-specific
+subdirectory has been selected, either with
+@option{--enable-version-specific-runtime-libs}, or defaulted.  This
+option does not however itself make newly-built GCC search the specified
+directory for libraries.  The default value, in case
+@option{--with-install-sysroot} is not given an argument, is
+@option{$@{gcc_tooldir@}/sys-root}.
+
 @item --with-headers
 @itemx --with-headers=@var{dir}
 Deprecated in favor of @option{--with-sysroot}.
Index: gcc/libada/Makefile.in
===================================================================
--- gcc.orig/libada/Makefile.in
+++ gcc/libada/Makefile.in
@@ -183,6 +183,7 @@ AUTOCONF = autoconf
 configure_deps = \
 	$(srcdir)/configure.ac \
 	$(srcdir)/../config/acx.m4 \
+	$(srcdir)/../config/install-sysroot.m4 \
 	$(srcdir)/../config/multi.m4 \
 	$(srcdir)/../config/override.m4 \
 	$(srcdir)/../config/picflag.m4 \
Index: gcc/libada/configure
===================================================================
--- gcc.orig/libada/configure
+++ gcc/libada/configure
@@ -704,6 +704,7 @@ enable_option_checking
 with_build_libsubdir
 enable_version_specific_runtime_libs
 enable_maintainer_mode
+with_install_sysroot
 enable_multilib
 enable_shared
 with_system_libunwind
@@ -1339,6 +1340,8 @@ if test -n "$ac_init_help"; then
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-system-libunwind use installed libunwind
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
@@ -2249,6 +2252,25 @@ else
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Default to --enable-multilib
 # Check whether --enable-multilib was given.
 if test "${enable_multilib+set}" = set; then :
@@ -2301,7 +2323,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libada/configure.ac
===================================================================
--- gcc.orig/libada/configure.ac
+++ gcc/libada/configure.ac
@@ -16,6 +16,7 @@
 # <http://www.gnu.org/licenses/>.
 
 sinclude(../config/acx.m4)
+sinclude(../config/install-sysroot.m4)
 sinclude(../config/multi.m4)
 sinclude(../config/override.m4)
 sinclude(../config/picflag.m4)
@@ -67,6 +68,8 @@ AC_ARG_ENABLE([maintainer-mode],
   [MAINT='#'])
 AC_SUBST([MAINT])dnl
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 AM_ENABLE_MULTILIB(, ..)
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
@@ -83,7 +86,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libatomic/Makefile.in
===================================================================
--- gcc.orig/libatomic/Makefile.in
+++ gcc/libatomic/Makefile.in
@@ -101,6 +101,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libatomic/aclocal.m4
===================================================================
--- gcc.orig/libatomic/aclocal.m4
+++ gcc/libatomic/aclocal.m4
@@ -1189,6 +1189,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
Index: gcc/libatomic/configure
===================================================================
--- gcc.orig/libatomic/configure
+++ gcc/libatomic/configure
@@ -794,6 +794,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1459,6 +1460,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3343,6 +3346,25 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3358,7 +3380,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11360,7 +11389,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11363 "configure"
+#line 11392 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11466,7 +11495,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11469 "configure"
+#line 11498 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libatomic/configure.ac
===================================================================
--- gcc.orig/libatomic/configure.ac
+++ gcc/libatomic/configure.ac
@@ -84,6 +84,8 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -99,7 +101,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libatomic/testsuite/Makefile.in
===================================================================
--- gcc.orig/libatomic/testsuite/Makefile.in
+++ gcc/libatomic/testsuite/Makefile.in
@@ -92,6 +92,7 @@ subdir = testsuite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libffi/Makefile.in
===================================================================
--- gcc.orig/libffi/Makefile.in
+++ gcc/libffi/Makefile.in
@@ -100,6 +100,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/asmcfi.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libffi/aclocal.m4
===================================================================
--- gcc.orig/libffi/aclocal.m4
+++ gcc/libffi/aclocal.m4
@@ -1190,6 +1190,7 @@ AC_SUBST([am__untar])
 m4_include([../config/acx.m4])
 m4_include([../config/asmcfi.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/libffi/configure
===================================================================
--- gcc.orig/libffi/configure
+++ gcc/libffi/configure
@@ -813,6 +813,7 @@ enable_debug
 enable_structs
 enable_raw_api
 enable_purify_safety
+with_install_sysroot
 enable_symvers
 with_gcc_major_version_only
 '
@@ -1476,6 +1477,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -11557,7 +11560,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11560 "configure"
+#line 11563 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11663,7 +11666,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11666 "configure"
+#line 11669 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16177,10 +16180,36 @@ $as_echo "#define USING_PURIFY 1" >>conf
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/libffi/configure.ac
===================================================================
--- gcc.orig/libffi/configure.ac
+++ gcc/libffi/configure.ac
@@ -332,10 +332,19 @@ AC_ARG_ENABLE(purify-safety,
     AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
   fi)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/libffi/include/Makefile.in
===================================================================
--- gcc.orig/libffi/include/Makefile.in
+++ gcc/libffi/include/Makefile.in
@@ -94,6 +94,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/asmcfi.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libffi/man/Makefile.in
===================================================================
--- gcc.orig/libffi/man/Makefile.in
+++ gcc/libffi/man/Makefile.in
@@ -93,6 +93,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/asmcfi.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libffi/testsuite/Makefile.in
===================================================================
--- gcc.orig/libffi/testsuite/Makefile.in
+++ gcc/libffi/testsuite/Makefile.in
@@ -93,6 +93,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/asmcfi.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libgcc/Makefile.in
===================================================================
--- gcc.orig/libgcc/Makefile.in
+++ gcc/libgcc/Makefile.in
@@ -164,6 +164,7 @@ config.status: $(srcdir)/configure $(src
 AUTOCONF = autoconf
 configure_deps = \
 	$(srcdir)/../config/enable.m4 \
+	$(srcdir)/../config/install-sysroot.m4 \
 	$(srcdir)/../config/tls.m4 \
 	$(srcdir)/../config/acx.m4 \
 	$(srcdir)/../config/no-executables.m4 \
Index: gcc/libgcc/configure
===================================================================
--- gcc.orig/libgcc/configure
+++ gcc/libgcc/configure
@@ -705,6 +705,7 @@ enable_gcov
 enable_vtable_verify
 with_aix_soname
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_slibdir
 enable_maintainer_mode
 with_build_libsubdir
@@ -1369,6 +1370,8 @@ if test -n "$ac_init_help"; then
   --with-aix-soname=aix|svr4|both
                           shared library versioning (aka "SONAME") variant to
                           provide on AIX
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-slibdir=DIR      shared libraries in DIR LIBDIR
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-libunwind use installed libunwind
@@ -2464,6 +2467,25 @@ fi
 $as_echo "$version_specific_libs" >&6; }
 
 
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(host_noncanonical)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
+
 # Check whether --with-slibdir was given.
 if test "${with_slibdir+set}" = set; then :
   withval=$with_slibdir; slibdir="$with_slibdir"
@@ -2471,7 +2493,14 @@ else
   if test "${version_specific_libs}" = yes; then
   slibdir='$(libsubdir)'
 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
-  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+  case ${with_install_sysroot} in
+    no)
+      slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+      ;;
+    *)
+      slibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   slibdir='$(libdir)'
 fi
@@ -2701,7 +2730,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgcc/configure.ac
===================================================================
--- gcc.orig/libgcc/configure.ac
+++ gcc/libgcc/configure.ac
@@ -1,6 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 sinclude(../config/enable.m4)
+sinclude(../config/install-sysroot.m4)
 sinclude(../config/tls.m4)
 sinclude(../config/acx.m4)
 sinclude(../config/no-executables.m4)
@@ -113,16 +114,25 @@ AC_ARG_ENABLE(version-specific-runtime-l
 [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
+GCC_WITH_INSTALL_SYSROOT([$(host_noncanonical)])
+
 AC_ARG_WITH(slibdir,
 [  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
 slibdir="$with_slibdir",
-if test "${version_specific_libs}" = yes; then
+[if test "${version_specific_libs}" = yes; then
   slibdir='$(libsubdir)'
 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
-  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+  case ${with_install_sysroot} in
+    no)
+      slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
+      ;;
+    *)
+      slibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   slibdir='$(libdir)'
-fi)
+fi])
 AC_SUBST(slibdir)
 
 # Command-line options.
@@ -168,7 +178,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgfortran/Makefile.in
===================================================================
--- gcc.orig/libgfortran/Makefile.in
+++ gcc/libgfortran/Makefile.in
@@ -162,6 +162,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libgfortran/aclocal.m4
===================================================================
--- gcc.orig/libgfortran/aclocal.m4
+++ gcc/libgfortran/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/depstand.m4])
 m4_include([../config/hwcaps.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
Index: gcc/libgfortran/configure
===================================================================
--- gcc.orig/libgfortran/configure
+++ gcc/libgfortran/configure
@@ -809,6 +809,7 @@ enable_silent_rules
 enable_maintainer_mode
 enable_multilib
 enable_dependency_tracking
+with_install_sysroot
 enable_cet
 enable_symvers
 with_gnu_ld
@@ -1480,6 +1481,8 @@ if test -n "$ac_init_help"; then
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
@@ -5173,6 +5176,25 @@ $as_echo "$ac_cv_safe_to_define___extens
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -5188,7 +5210,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12692,7 +12721,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12695 "configure"
+#line 12724 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12798,7 +12827,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12801 "configure"
+#line 12830 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libgfortran/configure.ac
===================================================================
--- gcc.orig/libgfortran/configure.ac
+++ gcc/libgfortran/configure.ac
@@ -86,6 +86,8 @@ fi
 
 AC_USE_SYSTEM_EXTENSIONS
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -101,7 +103,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgo/Makefile.in
===================================================================
--- gcc.orig/libgo/Makefile.in
+++ gcc/libgo/Makefile.in
@@ -110,6 +110,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libgo/aclocal.m4
===================================================================
--- gcc.orig/libgo/aclocal.m4
+++ gcc/libgo/aclocal.m4
@@ -1189,6 +1189,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/depstand.m4])
 m4_include([../config/hwcaps.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/libgo/configure
===================================================================
--- gcc.orig/libgo/configure
+++ gcc/libgo/configure
@@ -849,6 +849,7 @@ enable_fast_install
 enable_libtool_lock
 enable_werror
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_libffi
 with_libatomic
 with_system_libunwind
@@ -1503,6 +1504,8 @@ if test -n "$ac_init_help"; then
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --without-libffi        don't use libffi
   --without-libatomic     don't use libatomic
   --with-system-libunwind use installed libunwind
@@ -11486,7 +11489,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11489 "configure"
+#line 11492 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11592,7 +11595,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11595 "configure"
+#line 11598 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13800,6 +13803,25 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Version-specific runtime libs processing.
 if test $version_specific_libs = yes; then
   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -13811,7 +13833,14 @@ fi
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
-  nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+  case ${with_install_sysroot} in
+    no)
+      nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+      ;;
+    *)
+      nover_glibgo_toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
   nover_glibgo_toolexeclibdir='${libdir}'
Index: gcc/libgo/configure.ac
===================================================================
--- gcc.orig/libgo/configure.ac
+++ gcc/libgo/configure.ac
@@ -80,6 +80,8 @@ AC_ARG_ENABLE([version-specific-runtime-
   [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Version-specific runtime libs processing.
 if test $version_specific_libs = yes; then
   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -91,7 +93,14 @@ fi
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
-  nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+  case ${with_install_sysroot} in
+    no)
+      nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+      ;;
+    *)
+      nover_glibgo_toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
   nover_glibgo_toolexeclibdir='${libdir}'
Index: gcc/libgo/testsuite/Makefile.in
===================================================================
--- gcc.orig/libgo/testsuite/Makefile.in
+++ gcc/libgo/testsuite/Makefile.in
@@ -92,6 +92,7 @@ subdir = testsuite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libgomp/Makefile.in
===================================================================
--- gcc.orig/libgomp/Makefile.in
+++ gcc/libgomp/Makefile.in
@@ -129,6 +129,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/futex.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libgomp/aclocal.m4
===================================================================
--- gcc.orig/libgomp/aclocal.m4
+++ gcc/libgomp/aclocal.m4
@@ -1172,6 +1172,7 @@ m4_include([../config/ax_count_cpus.m4])
 m4_include([../config/depstand.m4])
 m4_include([../config/enable.m4])
 m4_include([../config/futex.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
Index: gcc/libgomp/configure
===================================================================
--- gcc.orig/libgomp/configure
+++ gcc/libgomp/configure
@@ -826,6 +826,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1505,6 +1506,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3501,6 +3504,25 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3516,7 +3538,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11405,7 +11434,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11408 "configure"
+#line 11437 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11511,7 +11540,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11514 "configure"
+#line 11543 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libgomp/configure.ac
===================================================================
--- gcc.orig/libgomp/configure.ac
+++ gcc/libgomp/configure.ac
@@ -64,6 +64,8 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -79,7 +81,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libgomp/testsuite/Makefile.in
===================================================================
--- gcc.orig/libgomp/testsuite/Makefile.in
+++ gcc/libgomp/testsuite/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/futex.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libhsail-rt/Makefile.in
===================================================================
--- gcc.orig/libhsail-rt/Makefile.in
+++ gcc/libhsail-rt/Makefile.in
@@ -137,6 +137,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
Index: gcc/libhsail-rt/aclocal.m4
===================================================================
--- gcc.orig/libhsail-rt/aclocal.m4
+++ gcc/libhsail-rt/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/override.m4])
 m4_include([../libtool.m4])
Index: gcc/libhsail-rt/configure
===================================================================
--- gcc.orig/libhsail-rt/configure
+++ gcc/libhsail-rt/configure
@@ -773,6 +773,7 @@ enable_silent_rules
 enable_maintainer_mode
 enable_dependency_tracking
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1435,6 +1436,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4653,6 +4656,25 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_version_specific_runtime_libs" >&5
 $as_echo "$enable_version_specific_runtime_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -4668,7 +4690,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11212,7 +11241,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11215 "configure"
+#line 11244 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11318,7 +11347,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11321 "configure"
+#line 11350 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libhsail-rt/configure.ac
===================================================================
--- gcc.orig/libhsail-rt/configure.ac
+++ gcc/libhsail-rt/configure.ac
@@ -69,6 +69,8 @@ ler-specific directory]),
   [enable_version_specific_runtime_libs=no])
 AC_MSG_RESULT($enable_version_specific_runtime_libs)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -84,7 +86,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libitm/Makefile.in
===================================================================
--- gcc.orig/libitm/Makefile.in
+++ gcc/libitm/Makefile.in
@@ -101,6 +101,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/mmap.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libitm/aclocal.m4
===================================================================
--- gcc.orig/libitm/aclocal.m4
+++ gcc/libitm/aclocal.m4
@@ -1193,6 +1193,7 @@ m4_include([../config/depstand.m4])
 m4_include([../config/enable.m4])
 m4_include([../config/futex.m4])
 m4_include([../config/hwcaps.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/mmap.m4])
 m4_include([../config/multi.m4])
Index: gcc/libitm/configure
===================================================================
--- gcc.orig/libitm/configure
+++ gcc/libitm/configure
@@ -802,6 +802,7 @@ enable_version_specific_runtime_libs
 enable_generated_files_in_srcdir
 enable_silent_rules
 enable_multilib
+with_install_sysroot
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1472,6 +1473,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3527,6 +3530,25 @@ fi
 ac_config_commands="$ac_config_commands default-1"
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -3542,7 +3564,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12037,7 +12066,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12040 "configure"
+#line 12069 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12143,7 +12172,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12146 "configure"
+#line 12175 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libitm/configure.ac
===================================================================
--- gcc.orig/libitm/configure.ac
+++ gcc/libitm/configure.ac
@@ -78,6 +78,8 @@ target_alias=${target_alias-$host_alias}
 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
 AM_ENABLE_MULTILIB(, ..)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${enable_version_specific_runtime_libs} in
@@ -93,7 +95,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libitm/testsuite/Makefile.in
===================================================================
--- gcc.orig/libitm/testsuite/Makefile.in
+++ gcc/libitm/testsuite/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/mmap.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libobjc/Makefile.in
===================================================================
--- gcc.orig/libobjc/Makefile.in
+++ gcc/libobjc/Makefile.in
@@ -290,6 +290,7 @@ AUTOCONF = autoconf
 ACLOCAL = aclocal
 ACLOCAL_AMFLAGS = -I ../config -I ..
 aclocal_deps = \
+	$(srcdir)/../config/install-sysroot.m4 \
 	$(srcdir)/../config/multi.m4 \
 	$(srcdir)/../config/override.m4 \
 	$(srcdir)/../config/proginstall.m4 \
Index: gcc/libobjc/aclocal.m4
===================================================================
--- gcc.orig/libobjc/aclocal.m4
+++ gcc/libobjc/aclocal.m4
@@ -150,6 +150,7 @@ m4_include([../ltsugar.m4])
 m4_include([../ltversion.m4])
 m4_include([../lt~obsolete.m4])
 m4_include([../config/cet.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/libobjc/configure
===================================================================
--- gcc.orig/libobjc/configure
+++ gcc/libobjc/configure
@@ -746,6 +746,7 @@ with_target_subdir
 with_cross_host
 enable_version_specific_runtime_libs
 enable_multilib
+with_install_sysroot
 enable_cet
 enable_maintainer_mode
 enable_shared
@@ -1402,6 +1403,8 @@ if test -n "$ac_init_help"; then
   --with-target-subdir=SUBDIR
                            configuring in a subdirectory
   --with-cross-host=HOST  configuring with a cross compiler
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -2502,6 +2505,25 @@ case $srcdir in
 esac
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_noncanonical)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -2517,7 +2539,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
@@ -10748,7 +10777,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10751 "configure"
+#line 10780 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10854,7 +10883,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10857 "configure"
+#line 10886 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libobjc/configure.ac
===================================================================
--- gcc.orig/libobjc/configure.ac
+++ gcc/libobjc/configure.ac
@@ -76,6 +76,8 @@ case $srcdir in
 esac
 AC_SUBST(glibcpp_srcdir)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_noncanonical)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -91,7 +93,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
       toolexeclibdir='$(libdir)'
Index: gcc/liboffloadmic/Makefile.in
===================================================================
--- gcc.orig/liboffloadmic/Makefile.in
+++ gcc/liboffloadmic/Makefile.in
@@ -123,6 +123,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/liboffloadmic/aclocal.m4
===================================================================
--- gcc.orig/liboffloadmic/aclocal.m4
+++ gcc/liboffloadmic/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/liboffloadmic/configure
===================================================================
--- gcc.orig/liboffloadmic/configure
+++ gcc/liboffloadmic/configure
@@ -775,6 +775,7 @@ enable_maintainer_mode
 enable_dependency_tracking
 enable_multilib
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1437,6 +1438,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -5293,6 +5296,25 @@ else
 fi
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -5308,7 +5330,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11403,7 +11432,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11406 "configure"
+#line 11435 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11509,7 +11538,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11512 "configure"
+#line 11541 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/liboffloadmic/configure.ac
===================================================================
--- gcc.orig/liboffloadmic/configure.ac
+++ gcc/liboffloadmic/configure.ac
@@ -79,6 +79,8 @@ case "$enable_liboffloadmic" in
 esac
 AM_CONDITIONAL(LIBOFFLOADMIC_HOST, [test x"$enable_liboffloadmic" = xhost])
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -94,7 +96,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/liboffloadmic/plugin/Makefile.in
===================================================================
--- gcc.orig/liboffloadmic/plugin/Makefile.in
+++ gcc/liboffloadmic/plugin/Makefile.in
@@ -123,6 +123,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../../config/acx.m4 \
 	$(top_srcdir)/../../config/depstand.m4 \
+	$(top_srcdir)/../../config/install-sysroot.m4 \
 	$(top_srcdir)/../../config/lead-dot.m4 \
 	$(top_srcdir)/../../config/multi.m4 \
 	$(top_srcdir)/../../config/override.m4 \
Index: gcc/liboffloadmic/plugin/aclocal.m4
===================================================================
--- gcc.orig/liboffloadmic/plugin/aclocal.m4
+++ gcc/liboffloadmic/plugin/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../../config/acx.m4])
 m4_include([../../config/depstand.m4])
+m4_include([../../config/install-sysroot.m4])
 m4_include([../../config/lead-dot.m4])
 m4_include([../../config/multi.m4])
 m4_include([../../config/override.m4])
Index: gcc/liboffloadmic/plugin/configure
===================================================================
--- gcc.orig/liboffloadmic/plugin/configure
+++ gcc/liboffloadmic/plugin/configure
@@ -771,6 +771,7 @@ enable_maintainer_mode
 enable_dependency_tracking
 enable_multilib
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1434,6 +1435,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4542,6 +4545,25 @@ fi
 $as_echo "$enable_version_specific_runtime_libs" >&6; }
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -4557,7 +4579,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -11050,7 +11079,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11053 "configure"
+#line 11082 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11156,7 +11185,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11159 "configure"
+#line 11188 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/liboffloadmic/plugin/configure.ac
===================================================================
--- gcc.orig/liboffloadmic/plugin/configure.ac
+++ gcc/liboffloadmic/plugin/configure.ac
@@ -95,6 +95,8 @@ AC_ARG_ENABLE([version-specific-runtime-
 AC_MSG_RESULT($enable_version_specific_runtime_libs)
 
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir.
 # Also toolexecdir, though it's only used in toolexeclibdir.
 case ${enable_version_specific_runtime_libs} in
@@ -110,7 +112,14 @@ case ${enable_version_specific_runtime_l
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libphobos/Makefile.in
===================================================================
--- gcc.orig/libphobos/Makefile.in
+++ gcc/libphobos/Makefile.in
@@ -108,6 +108,7 @@ target_triplet = @target@
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libphobos/aclocal.m4
===================================================================
--- gcc.orig/libphobos/aclocal.m4
+++ gcc/libphobos/aclocal.m4
@@ -873,6 +873,7 @@ AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
 m4_include([../config/acx.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/libphobos/configure
===================================================================
--- gcc.orig/libphobos/configure
+++ gcc/libphobos/configure
@@ -837,6 +837,7 @@ with_libbacktrace
 with_target_system_zlib
 with_cross_host
 enable_version_specific_runtime_libs
+with_install_sysroot
 enable_libphobos
 '
       ac_precious_vars='build_alias
@@ -1504,6 +1505,8 @@ if test -n "$ac_init_help"; then
   --with-target-system-zlib={yes,no,auto}
                           use installed libz (default: no)
   --with-cross-host=HOST  configuring with a cross compiler
+  --with-install-sysroot=DIR
+                          install libraries within DIR
 
 Some influential environment variables:
   CC          C compiler command
@@ -11640,7 +11643,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11643 "configure"
+#line 11646 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11746,7 +11749,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11749 "configure"
+#line 11752 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15237,6 +15240,25 @@ fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/${host_alias}/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
   # Version-specific runtime libs processing.
   if test $version_specific_libs = yes; then
     libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -15246,7 +15268,14 @@ $as_echo "$version_specific_libs" >&6; }
     # Install a library built with a cross compiler in tooldir, not libdir.
     if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
       libphobos_toolexecdir='${exec_prefix}/${host_alias}'
-      libphobos_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  libphobos_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  libphobos_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
       libphobos_toolexeclibdir='${libdir}'
Index: gcc/libphobos/libdruntime/Makefile.in
===================================================================
--- gcc.orig/libphobos/libdruntime/Makefile.in
+++ gcc/libphobos/libdruntime/Makefile.in
@@ -133,6 +133,7 @@ target_triplet = @target@
 subdir = libdruntime
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libphobos/m4/druntime.m4
===================================================================
--- gcc.orig/libphobos/m4/druntime.m4
+++ gcc/libphobos/m4/druntime.m4
@@ -80,6 +80,8 @@ AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
     [version_specific_libs=no])
   AC_MSG_RESULT($version_specific_libs)
 
+  GCC_WITH_INSTALL_SYSROOT([${host_alias}])
+
   # Version-specific runtime libs processing.
   if test $version_specific_libs = yes; then
     libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -89,7 +91,14 @@ AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
     # Install a library built with a cross compiler in tooldir, not libdir.
     if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
       libphobos_toolexecdir='${exec_prefix}/${host_alias}'
-      libphobos_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  libphobos_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  libphobos_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       libphobos_toolexecdir='${libdir}/gcc/${host_alias}'
       libphobos_toolexeclibdir='${libdir}'
Index: gcc/libphobos/src/Makefile.in
===================================================================
--- gcc.orig/libphobos/src/Makefile.in
+++ gcc/libphobos/src/Makefile.in
@@ -93,6 +93,7 @@ target_triplet = @target@
 subdir = src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libphobos/testsuite/Makefile.in
===================================================================
--- gcc.orig/libphobos/testsuite/Makefile.in
+++ gcc/libphobos/testsuite/Makefile.in
@@ -93,6 +93,7 @@ target_triplet = @target@
 subdir = testsuite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/libquadmath/Makefile.in
===================================================================
--- gcc.orig/libquadmath/Makefile.in
+++ gcc/libquadmath/Makefile.in
@@ -95,6 +95,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libquadmath/aclocal.m4
===================================================================
--- gcc.orig/libquadmath/aclocal.m4
+++ gcc/libquadmath/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
Index: gcc/libquadmath/configure
===================================================================
--- gcc.orig/libquadmath/configure
+++ gcc/libquadmath/configure
@@ -786,6 +786,7 @@ enable_fast_install
 with_gnu_ld
 enable_libtool_lock
 enable_maintainer_mode
+with_install_sysroot
 enable_symvers
 enable_cet
 enable_generated_files_in_srcdir
@@ -1451,6 +1452,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -10810,7 +10813,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10813 "configure"
+#line 10816 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10916,7 +10919,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10919 "configure"
+#line 10922 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12088,6 +12091,25 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -12103,7 +12125,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libquadmath/configure.ac
===================================================================
--- gcc.orig/libquadmath/configure.ac
+++ gcc/libquadmath/configure.ac
@@ -82,6 +82,8 @@ if test "x$GCC" != "xyes"; then
 fi
 AC_PROG_CPP
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -97,7 +99,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libsanitizer/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/Makefile.in
+++ gcc/libsanitizer/Makefile.in
@@ -100,6 +100,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/aclocal.m4
===================================================================
--- gcc.orig/libsanitizer/aclocal.m4
+++ gcc/libsanitizer/aclocal.m4
@@ -1189,6 +1189,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/libstdc++-raw-cxx.m4])
 m4_include([../config/multi.m4])
Index: gcc/libsanitizer/asan/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/asan/Makefile.in
+++ gcc/libsanitizer/asan/Makefile.in
@@ -97,6 +97,7 @@ subdir = asan
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/configure
===================================================================
--- gcc.orig/libsanitizer/configure
+++ gcc/libsanitizer/configure
@@ -806,6 +806,7 @@ enable_version_specific_runtime_libs
 enable_dependency_tracking
 enable_silent_rules
 enable_maintainer_mode
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1470,6 +1471,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -5012,6 +5015,25 @@ fi
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -5027,7 +5049,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12334,7 +12363,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12337 "configure"
+#line 12366 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12440,7 +12469,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12443 "configure"
+#line 12472 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libsanitizer/configure.ac
===================================================================
--- gcc.orig/libsanitizer/configure.ac
+++ gcc/libsanitizer/configure.ac
@@ -29,6 +29,8 @@ GCC_LIBSTDCXX_RAW_CXX_FLAGS
 AM_INIT_AUTOMAKE(foreign no-dist)
 AM_MAINTAINER_MODE
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -44,7 +46,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libsanitizer/interception/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/interception/Makefile.in
+++ gcc/libsanitizer/interception/Makefile.in
@@ -93,6 +93,7 @@ subdir = interception
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/libbacktrace/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/libbacktrace/Makefile.in
+++ gcc/libsanitizer/libbacktrace/Makefile.in
@@ -124,6 +124,7 @@ subdir = libbacktrace
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/lsan/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/lsan/Makefile.in
+++ gcc/libsanitizer/lsan/Makefile.in
@@ -95,6 +95,7 @@ subdir = lsan
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/sanitizer_common/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/sanitizer_common/Makefile.in
+++ gcc/libsanitizer/sanitizer_common/Makefile.in
@@ -99,6 +99,7 @@ subdir = sanitizer_common
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/tsan/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/tsan/Makefile.in
+++ gcc/libsanitizer/tsan/Makefile.in
@@ -96,6 +96,7 @@ subdir = tsan
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libsanitizer/ubsan/Makefile.in
===================================================================
--- gcc.orig/libsanitizer/ubsan/Makefile.in
+++ gcc/libsanitizer/ubsan/Makefile.in
@@ -95,6 +95,7 @@ subdir = ubsan
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libssp/Makefile.in
===================================================================
--- gcc.orig/libssp/Makefile.in
+++ gcc/libssp/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/cet.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/enable.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
 	$(top_srcdir)/../config/multi.m4 \
Index: gcc/libssp/aclocal.m4
===================================================================
--- gcc.orig/libssp/aclocal.m4
+++ gcc/libssp/aclocal.m4
@@ -1171,6 +1171,7 @@ m4_include([../config/acx.m4])
 m4_include([../config/cet.m4])
 m4_include([../config/depstand.m4])
 m4_include([../config/enable.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
Index: gcc/libssp/configure
===================================================================
--- gcc.orig/libssp/configure
+++ gcc/libssp/configure
@@ -781,6 +781,7 @@ with_pic
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+with_install_sysroot
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1432,6 +1433,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -10992,7 +10995,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10995 "configure"
+#line 10998 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11098,7 +11101,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11101 "configure"
+#line 11104 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11360,6 +11363,25 @@ esac
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -11375,7 +11397,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libssp/configure.ac
===================================================================
--- gcc.orig/libssp/configure.ac
+++ gcc/libssp/configure.ac
@@ -163,6 +163,8 @@ ACX_LT_HOST_FLAGS
 AC_SUBST(enable_shared)
 AC_SUBST(enable_static)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -178,7 +180,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libstdc++-v3/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/Makefile.in
+++ gcc/libstdc++-v3/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/acinclude.m4
===================================================================
--- gcc.orig/libstdc++-v3/acinclude.m4
+++ gcc/libstdc++-v3/acinclude.m4
@@ -782,6 +782,8 @@ AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO],
     [version_specific_libs=no])
   AC_MSG_RESULT($version_specific_libs)
 
+  GCC_WITH_INSTALL_SYSROOT([${host_alias}])
+
   # Default case for install directory for include files.
   if test $version_specific_libs = no && test $gxx_include_dir = no; then
     gxx_include_dir='include/c++/${gcc_version}'
@@ -812,7 +814,14 @@ AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO],
     if test -n "$with_cross_host" &&
        test x"$with_cross_host" != x"no"; then
       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
-      glibcxx_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  glibcxx_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  glibcxx_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
       glibcxx_toolexeclibdir='${libdir}'
Index: gcc/libstdc++-v3/aclocal.m4
===================================================================
--- gcc.orig/libstdc++-v3/aclocal.m4
+++ gcc/libstdc++-v3/aclocal.m4
@@ -857,6 +857,7 @@ m4_include([../config/enable.m4])
 m4_include([../config/futex.m4])
 m4_include([../config/hwcaps.m4])
 m4_include([../config/iconv.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lib-ld.m4])
 m4_include([../config/lib-link.m4])
Index: gcc/libstdc++-v3/configure
===================================================================
--- gcc.orig/libstdc++-v3/configure
+++ gcc/libstdc++-v3/configure
@@ -942,6 +942,7 @@ enable_libstdcxx_filesystem_ts
 enable_cet
 with_gxx_include_dir
 enable_version_specific_runtime_libs
+with_install_sysroot
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1669,6 +1670,8 @@ if test -n "$ac_init_help"; then
                           set the std::string ABI to use by default
   --with-gxx-include-dir=DIR
                           installation directory for include files
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -12053,7 +12056,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12056 "configure"
+#line 12059 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12159,7 +12162,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12162 "configure"
+#line 12165 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15851,7 +15854,7 @@ $as_echo "$glibcxx_cv_atomic_long_long"
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 15854 "configure"
+#line 15857 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15886,7 +15889,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6;
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15889 "configure"
+#line 15892 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -15921,7 +15924,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6;
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15924 "configure"
+#line 15927 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -15957,7 +15960,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15960 "configure"
+#line 15963 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16110,7 +16113,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16113 "configure"
+#line 16116 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16152,7 +16155,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16155 "configure"
+#line 16158 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -16186,7 +16189,7 @@ $as_echo "$enable_int128" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16189 "configure"
+#line 16192 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -76493,6 +76496,25 @@ fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
 $as_echo "$version_specific_libs" >&6; }
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/${host_alias}/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
   # Default case for install directory for include files.
   if test $version_specific_libs = no && test $gxx_include_dir = no; then
     gxx_include_dir='include/c++/${gcc_version}'
@@ -76523,7 +76545,14 @@ $as_echo "$version_specific_libs" >&6; }
     if test -n "$with_cross_host" &&
        test x"$with_cross_host" != x"no"; then
       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
-      glibcxx_toolexeclibdir='${toolexecdir}/lib'
+      case ${with_install_sysroot} in
+	no)
+	  glibcxx_toolexeclibdir='${toolexecdir}/lib'
+	  ;;
+	*)
+	  glibcxx_toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
       glibcxx_toolexeclibdir='${libdir}'
Index: gcc/libstdc++-v3/doc/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/doc/Makefile.in
+++ gcc/libstdc++-v3/doc/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/include/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/include/Makefile.in
+++ gcc/libstdc++-v3/include/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/libsupc++/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/libsupc++/Makefile.in
+++ gcc/libstdc++-v3/libsupc++/Makefile.in
@@ -97,6 +97,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/po/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/po/Makefile.in
+++ gcc/libstdc++-v3/po/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/python/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/python/Makefile.in
+++ gcc/libstdc++-v3/python/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/src/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/src/Makefile.in
+++ gcc/libstdc++-v3/src/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/src/c++11/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/src/c++11/Makefile.in
+++ gcc/libstdc++-v3/src/c++11/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/src/c++17/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/src/c++17/Makefile.in
+++ gcc/libstdc++-v3/src/c++17/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/src/c++98/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/src/c++98/Makefile.in
+++ gcc/libstdc++-v3/src/c++98/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/src/filesystem/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/src/filesystem/Makefile.in
+++ gcc/libstdc++-v3/src/filesystem/Makefile.in
@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libstdc++-v3/testsuite/Makefile.in
===================================================================
--- gcc.orig/libstdc++-v3/testsuite/Makefile.in
+++ gcc/libstdc++-v3/testsuite/Makefile.in
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../c
 	$(top_srcdir)/../config/futex.m4 \
 	$(top_srcdir)/../config/hwcaps.m4 \
 	$(top_srcdir)/../config/iconv.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/lib-ld.m4 \
 	$(top_srcdir)/../config/lib-link.m4 \
Index: gcc/libvtv/Makefile.in
===================================================================
--- gcc.orig/libvtv/Makefile.in
+++ gcc/libvtv/Makefile.in
@@ -96,6 +96,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
Index: gcc/libvtv/aclocal.m4
===================================================================
--- gcc.orig/libvtv/aclocal.m4
+++ gcc/libvtv/aclocal.m4
@@ -1169,6 +1169,7 @@ AC_SUBST([am__untar])
 
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/libstdc++-raw-cxx.m4])
 m4_include([../config/lthostflags.m4])
Index: gcc/libvtv/configure
===================================================================
--- gcc.orig/libvtv/configure
+++ gcc/libvtv/configure
@@ -790,6 +790,7 @@ enable_vtable_verify
 enable_dependency_tracking
 enable_silent_rules
 enable_maintainer_mode
+with_install_sysroot
 enable_shared
 enable_static
 with_pic
@@ -1450,6 +1451,8 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-install-sysroot=DIR
+                          install libraries within DIR
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -4807,6 +4810,25 @@ fi
 
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -4822,7 +4844,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
@@ -12235,7 +12264,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12238 "configure"
+#line 12267 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12341,7 +12370,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12344 "configure"
+#line 12373 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/libvtv/configure.ac
===================================================================
--- gcc.orig/libvtv/configure.ac
+++ gcc/libvtv/configure.ac
@@ -78,6 +78,8 @@ AM_MAINTAINER_MODE
 
 LIBVTV_CONFIGURE
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 # Calculate toolexeclibdir
 # Also toolexecdir, though it's only used in toolexeclibdir
 case ${version_specific_libs} in
@@ -93,7 +95,14 @@ case ${version_specific_libs} in
        test x"$with_cross_host" != x"no"; then
       # Install a library built with a cross compiler in tooldir, not libdir.
       toolexecdir='$(exec_prefix)/$(target_alias)'
-      toolexeclibdir='$(toolexecdir)/lib'
+      case ${with_install_sysroot} in
+	no)
+	  toolexeclibdir='$(toolexecdir)/lib'
+	  ;;
+	*)
+	  toolexeclibdir=${with_install_sysroot}/lib
+	  ;;
+      esac
     else
       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
       toolexeclibdir='$(libdir)'
Index: gcc/libvtv/testsuite/Makefile.in
===================================================================
--- gcc.orig/libvtv/testsuite/Makefile.in
+++ gcc/libvtv/testsuite/Makefile.in
@@ -92,6 +92,7 @@ subdir = testsuite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/libstdc++-raw-cxx.m4 \
 	$(top_srcdir)/../config/lthostflags.m4 \
Index: gcc/zlib/Makefile.in
===================================================================
--- gcc.orig/zlib/Makefile.in
+++ gcc/zlib/Makefile.in
@@ -93,6 +93,7 @@ target_triplet = @target@
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/install-sysroot.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
 	$(top_srcdir)/../config/multi.m4 \
 	$(top_srcdir)/../config/override.m4 \
Index: gcc/zlib/aclocal.m4
===================================================================
--- gcc.orig/zlib/aclocal.m4
+++ gcc/zlib/aclocal.m4
@@ -1168,6 +1168,7 @@ AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
 m4_include([../config/depstand.m4])
+m4_include([../config/install-sysroot.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
Index: gcc/zlib/configure
===================================================================
--- gcc.orig/zlib/configure
+++ gcc/zlib/configure
@@ -774,6 +774,7 @@ with_pic
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+with_install_sysroot
 enable_host_shared
 '
       ac_precious_vars='build_alias
@@ -1427,6 +1428,8 @@ if test -n "$ac_init_help"; then
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-install-sysroot=DIR
+                          install libraries within DIR
 
 Some influential environment variables:
   CC          C compiler command
@@ -10648,7 +10651,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10651 "configure"
+#line 10654 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10754,7 +10757,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10757 "configure"
+#line 10760 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11379,10 +11382,36 @@ fi
 done
 
 
+
+# Check whether --with-install-sysroot was given.
+if test "${with_install_sysroot+set}" = set; then :
+  withval=$with_install_sysroot; case ${with_install_sysroot} in
+  /)
+    ;;
+  */)
+    with_install_sysroot=`echo $with_install_sysroot | sed 's,/$,,'`
+    ;;
+  yes)
+    with_install_sysroot='$(exec_prefix)/$(target_alias)/sys-root'
+    ;;
+esac
+else
+  with_install_sysroot=no
+fi
+
+
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'
Index: gcc/zlib/configure.ac
===================================================================
--- gcc.orig/zlib/configure.ac
+++ gcc/zlib/configure.ac
@@ -81,10 +81,19 @@ fi
 
 AC_CHECK_HEADERS(unistd.h)
 
+GCC_WITH_INSTALL_SYSROOT([$(target_alias)])
+
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   toolexecdir='$(exec_prefix)/$(target_alias)'
-  toolexeclibdir='$(toolexecdir)/lib'
+  case ${with_install_sysroot} in
+    no)
+      toolexeclibdir='$(toolexecdir)/lib'
+      ;;
+    *)
+      toolexeclibdir=${with_install_sysroot}/lib
+      ;;
+  esac
 else
   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
   toolexeclibdir='$(libdir)'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-18  2:04   ` [PATCH v2] " Maciej W. Rozycki
@ 2019-11-19  0:11     ` Joseph Myers
  2019-11-20  2:39       ` Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2019-11-19  0:11 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Mon, 18 Nov 2019, Maciej W. Rozycki wrote:

> > 4. How does this interact with sysroot suffixes (again, this should be 
> > made clear in the documentation)?
> 
>  There is no interaction, the patch merely changes where the libraries are 
> installed.  If the installation sysroot directory chosen is not one known 
> by the GCC driver, then the newly-installed target libraries won't be 
> automatically used (that of course can be changed with the appropriate use 
> of the `-B', `-L' and `--sysroot=' driver options).

Perhaps the "sysroot" phrasing of the option name is confusing.

The documentation in install.texi says "@var{dir} rather than 
@option{$@{gcc_tooldir@}/lib}".  If that means, for example, that when 
"-print-multi-os-directory" prints "../lib64" the libraries are installed 
in $dir/../lib64 (so you'd pass --with-install-sysroot=/some/where/lib 
rather than --with-install-sysroot=/some/where), it's definitely not a 
sysroot.  If in fact $dir/lib/../lib64 would be used, the documentation 
should say so.

But even then, if you configure GCC using "--with-sysroot" or 
"--with-build-sysroot", both of those paths are the top-level sysroot, to 
which the sysroot suffix gets appended before GCC uses it for any purpose, 
unless you explicitly build using --no-sysroot-suffix.  So I still think 
it's natural for a user of GCC's configure scripts to expect the new 
option, like the other sysroot-related configure options, also to be one 
to which the per-multilib sysroot suffix gets appended before GCC uses it.  
And if it's not like that, the documentation needs to say so explicitly.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-19  0:11     ` Joseph Myers
@ 2019-11-20  2:39       ` Maciej W. Rozycki
  2019-11-20 17:46         ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2019-11-20  2:39 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Tue, 19 Nov 2019, Joseph Myers wrote:

> > > 4. How does this interact with sysroot suffixes (again, this should be 
> > > made clear in the documentation)?
> > 
> >  There is no interaction, the patch merely changes where the libraries are 
> > installed.  If the installation sysroot directory chosen is not one known 
> > by the GCC driver, then the newly-installed target libraries won't be 
> > automatically used (that of course can be changed with the appropriate use 
> > of the `-B', `-L' and `--sysroot=' driver options).
> 
> Perhaps the "sysroot" phrasing of the option name is confusing.
> 
> The documentation in install.texi says "@var{dir} rather than 
> @option{$@{gcc_tooldir@}/lib}".  If that means, for example, that when 
> "-print-multi-os-directory" prints "../lib64" the libraries are installed 
> in $dir/../lib64 (so you'd pass --with-install-sysroot=/some/where/lib 
> rather than --with-install-sysroot=/some/where), it's definitely not a 
> sysroot.  If in fact $dir/lib/../lib64 would be used, the documentation 
> should say so.

 Documentation thinko here, thanks for your meticulousness!  Indeed that 
has to read "@option{$@{gcc_tooldir@}}" as per example code:

      case ${with_install_sysroot} in
	no)
	  toolexeclibdir='$(toolexecdir)/lib'
	  ;;
	*)
	  toolexeclibdir=${with_install_sysroot}/lib
	  ;;
      esac

where "@var{dir}" does get interpreted as a sysroot (as was also 
previously shown by my use example).

> But even then, if you configure GCC using "--with-sysroot" or 
> "--with-build-sysroot", both of those paths are the top-level sysroot, to 
> which the sysroot suffix gets appended before GCC uses it for any purpose, 
> unless you explicitly build using --no-sysroot-suffix.  So I still think 
> it's natural for a user of GCC's configure scripts to expect the new 
> option, like the other sysroot-related configure options, also to be one 
> to which the per-multilib sysroot suffix gets appended before GCC uses it.  
> And if it's not like that, the documentation needs to say so explicitly.

 Thanks for your concern, however again, AFAICT this change is tangential 
to any sysroot suffix, which necessarily has to be already included in the 
multilib OS directory as given by `-print-multi-os-directory', so that it 
gets embedded within $toolexeclibdir for the purpose of target library 
installation across the relevant subdirs, as per this excerpt from 
`configure' code right after the assignments quoted in the example above:

    multi_os_directory=`$CC -print-multi-os-directory`
    case $multi_os_directory in
      .) ;; # Avoid trailing /.
      *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
    esac

or otherwise the existing arrangement where 
toolexeclibdir='$(toolexecdir)/lib' wouldn't have worked either (and 
neither would in the native case where toolexeclibdir='$(libdir)').

 Does this answer clear your concern?  OK to apply with the documentation 
thinko fixed?

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-20  2:39       ` Maciej W. Rozycki
@ 2019-11-20 17:46         ` Joseph Myers
  2019-11-22 23:41           ` Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2019-11-20 17:46 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Wed, 20 Nov 2019, Maciej W. Rozycki wrote:

> > But even then, if you configure GCC using "--with-sysroot" or 
> > "--with-build-sysroot", both of those paths are the top-level sysroot, to 
> > which the sysroot suffix gets appended before GCC uses it for any purpose, 
> > unless you explicitly build using --no-sysroot-suffix.  So I still think 
> > it's natural for a user of GCC's configure scripts to expect the new 
> > option, like the other sysroot-related configure options, also to be one 
> > to which the per-multilib sysroot suffix gets appended before GCC uses it.  
> > And if it's not like that, the documentation needs to say so explicitly.
> 
>  Thanks for your concern, however again, AFAICT this change is tangential 
> to any sysroot suffix, which necessarily has to be already included in the 
> multilib OS directory as given by `-print-multi-os-directory', so that it 
> gets embedded within $toolexeclibdir for the purpose of target library 
> installation across the relevant subdirs, as per this excerpt from 
> `configure' code right after the assignments quoted in the example above:
> 
>     multi_os_directory=`$CC -print-multi-os-directory`
>     case $multi_os_directory in
>       .) ;; # Avoid trailing /.
>       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
>     esac
> 
> or otherwise the existing arrangement where 
> toolexeclibdir='$(toolexecdir)/lib' wouldn't have worked either (and 
> neither would in the native case where toolexeclibdir='$(libdir)').
> 
>  Does this answer clear your concern?  OK to apply with the documentation 
> thinko fixed?

The answer explains the reasoning behind the design of the option (i.e., 
the design that means it's not particularly useful with sysroot suffixes, 
because the user would still need to relocate libraries manually to the 
correct suffixed sysroot).  It is indeed the case that making a version 
useful with sysroot suffixes would not simply be a configuration change 
but involve changes in the compiler driver to disentangle two different 
uses of multilib OS directory suffixes.

However, it's not enough to answer the question about the semantics of the 
option on the mailing list.  The question is a natural one for anyone who 
knows about sysroot suffixes and is reading the documentation of the 
option.  And so *the actual GCC documentation proposed to be committed*, 
not just explanations on the mailing list that people reading that 
documentation won't see, needs to say explicitly that the OS directory 
suffix is appended to lib/ in the *unsuffixed* sysroot, so that all 
libraries get installed in the same sysroot even if suffixes are in use.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-20 17:46         ` Joseph Myers
@ 2019-11-22 23:41           ` Maciej W. Rozycki
  2019-11-22 23:54             ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2019-11-22 23:41 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Wed, 20 Nov 2019, Joseph Myers wrote:

> >  Thanks for your concern, however again, AFAICT this change is tangential 
> > to any sysroot suffix, which necessarily has to be already included in the 
> > multilib OS directory as given by `-print-multi-os-directory', so that it 
> > gets embedded within $toolexeclibdir for the purpose of target library 
> > installation across the relevant subdirs, as per this excerpt from 
> > `configure' code right after the assignments quoted in the example above:
> > 
> >     multi_os_directory=`$CC -print-multi-os-directory`
> >     case $multi_os_directory in
> >       .) ;; # Avoid trailing /.
> >       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
> >     esac
> > 
> > or otherwise the existing arrangement where 
> > toolexeclibdir='$(toolexecdir)/lib' wouldn't have worked either (and 
> > neither would in the native case where toolexeclibdir='$(libdir)').
> > 
> >  Does this answer clear your concern?  OK to apply with the documentation 
> > thinko fixed?
> 
> The answer explains the reasoning behind the design of the option (i.e., 
> the design that means it's not particularly useful with sysroot suffixes, 
> because the user would still need to relocate libraries manually to the 
> correct suffixed sysroot).  It is indeed the case that making a version 
> useful with sysroot suffixes would not simply be a configuration change 
> but involve changes in the compiler driver to disentangle two different 
> uses of multilib OS directory suffixes.

 I think I am confused now about your mention of the existence of two 
different uses here.  This may be because it's been a while since I worked 
with a MIPS toolchain configuration and my memory may have started to 
fade.  So at this point I'll appreciate if you enlighten me a bit.

 As I recall the MIPS sysroot setup (please correct me if I got something 
wrong here) was like:

/path/to/somewhere/
                  +-> lib/
                  +-> lib32/
                  +-> lib64/
                  +-> usr/
                  |      +-> lib/
                  |      +-> lib32/
                  |      \-> lib64/
                  +-> el/
                  |     +-> lib/
                  |     +-> lib32/
                  |     +-> lib64/
                  |     \-> usr/
                  |            +-> lib/
                  |            +-> lib32/
                  |            \-> lib64/
                  +-> sof/
                  |      +-> lib/
                  |      +-> lib32/ 
                  |      +-> lib64/
                  |      +-> usr/
                  |      |      +-> lib/
                  |      |      +-> lib32/
                  |      |      \-> lib64/
		  |	 \-> el/
                  |            +-> lib/
                  |            +-> lib32/
                  |            +-> lib64/
                  |            \-> usr/
                  |                   +-> lib/
                  |                   +-> lib32/
                  |                   \-> lib64/
                  .
                  .
                  .

and the use of `--sysroot=/path/to/somewhere' combined with the required 
multilib selection options, such as `-EL -mabi=64 -msoft-float' would make 
the GCC driver point the linker at the right set of directories to use for 
libraries to be linked against.  For the options given here these would be 
/path/to/somewhere/sof/el/lib64 and /path/to/somewhere/sof/el/usr/lib64.

 For RISC-V targets the structure so far is much simpler and for the Linux 
target amounts to:

/path/to/somewhere/
                  +-> lib32/
                  |        +-> ilp32/
                  |        \-> ilp32d/
                  +-> lib64/
                  |        +-> ilp64/
                  |        \-> ilp64d/
                  \-> usr/
                         +-> lib32/
                         |        +-> ilp32/
                         |        \-> ilp32d/
                         \-> lib64/
                                  +-> ilp64/
                                  \-> ilp64d/

NB I have deliberately omitted header files from this consideration; these 
could or could not be shared among multilibs depending on the particular 
target although as I recall and agree with the desire was to have a single 
shared set of headers living under /path/to/somewhere/usr/include/.

 Then the right-hand side of /path/to/somewhere (except for usr/) is what 
gets printed by `-print-multi-directory' or the left-hand side of output 
from `-print-multi-lib', e.g. `sof/el/lib64' for the example above.  
Similarly `-print-multi-os-directory' prints a directory path relative to 
a lib/ subdirectory to the sysroot, so that would be `../sof/el/lib64' 
respectively.

 I have no immediate access to a MIPS toolchain (not at least one with 
multilib support configured), but I have made a quick experiment with my 
RISC-V toolchain (configured with the sysroot at `$prefix/sysroot') and 
things appear to work as I described, e.g.:

$ riscv64-linux-gnu-gcc -print-multi-lib
.;
lib32/ilp32;@march=rv32imac@mabi=ilp32
lib32/ilp32d;@march=rv32imafdc@mabi=ilp32d
lib64/lp64;@march=rv64imac@mabi=lp64
lib64/lp64d;@march=rv64imafdc@mabi=lp64d
$ riscv64-linux-gnu-gcc -print-multi-directory
lib64/lp64d
$ riscv64-linux-gnu-gcc -print-search-dirs | grep libraries | sed 's/.*=//;s/:/\n/g' | xargs readlink -f
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0/lib64/lp64d
$prefix/riscv64-linux-gnu/lib64/lp64d
$prefix/sysroot/lib64/lp64d
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0
$prefix/lib/gcc
$prefix/riscv64-linux-gnu/lib
$prefix/sysroot/lib64/lp64d
$prefix/sysroot/usr/lib64/lp64d
$prefix/sysroot/lib
$prefix/sysroot/usr/lib
$ 
$ riscv64-linux-gnu-gcc -march=rv32imafdc -mabi=ilp32d -print-search-dirs | grep libraries | sed 's/.*=//;s/:/\n/g' | xargs readlink -f
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0/lib32/ilp32d
$prefix/riscv64-linux-gnu/lib32/ilp32d
$prefix/sysroot/lib32/ilp32d
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0
$prefix/lib/gcc
$prefix/riscv64-linux-gnu/lib
$prefix/sysroot/lib32/ilp32d
$prefix/sysroot/usr/lib32/ilp32d
$prefix/sysroot/lib
$prefix/sysroot/usr/lib
$ 
$ riscv64-linux-gnu-gcc --sysroot=/tmp -march=rv32imafdc -mabi=ilp32d -print-search-dirs | grep libraries | sed 's/.*=//;s/:/\n/g' | xargs readlink -f
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0/lib32/ilp32d
$prefix/riscv64-linux-gnu/lib32/ilp32d
/tmp/lib32/ilp32d
/tmp/usr/lib32/ilp32d
$prefix/lib/gcc/riscv64-linux-gnu/10.0.0
$prefix/lib/gcc
$prefix/riscv64-linux-gnu/lib
/tmp/lib32/ilp32d
/tmp/usr/lib32/ilp32d
/tmp/lib
/tmp/usr/lib
$ 

 Now /path/to/somewhere might well be what we call the tooldir, i.e. 
$exec_prefix/$target_noncanonical, however this is somewhat inconvenient; 
first because it is hardcoded, and second because there is other stuff 
held there, starting from cross-executables for the host.  Which is how I 
came up with my change, whose intent is to separate /path/to/somewhere 
from the tooldir for the purpose of library installation at GCC build time 
and make it configurable.

 I am fairly sure I have described the directory structures quite 
accurately for one of the uses you have referred to.  So would you please 
remind me what the other use is and what exactly it is used for?

> However, it's not enough to answer the question about the semantics of the 
> option on the mailing list.  The question is a natural one for anyone who 
> knows about sysroot suffixes and is reading the documentation of the 
> option.  And so *the actual GCC documentation proposed to be committed*, 
> not just explanations on the mailing list that people reading that 
> documentation won't see, needs to say explicitly that the OS directory 
> suffix is appended to lib/ in the *unsuffixed* sysroot, so that all 
> libraries get installed in the same sysroot even if suffixes are in use.

 Well, I agree we need to have this stuff documented beyond what we 
currently have, but I think it applies equally to all the sysroot options 
we have, including both the `--sysroot=' GCC driver's option, and the 
`--with-sysroot=', `--with-build-sysroot=' and the newly-proposed 
`--with-install-sysroot=' `configure' script's options as well.  All we 
currently have is this paragraph:

"'--sysroot=DIR'
     Use DIR as the logical root directory for headers and libraries.
     For example, if the compiler normally searches for headers in
     '/usr/include' and libraries in '/usr/lib', it instead searches
     'DIR/usr/include' and 'DIR/usr/lib'."

in the GCC manual, which carefully omits the matter of multilibs and based 
on my experience is only ever accurate for configurations that do not use 
multilibs.

 So what I think we need is a section or a paragraph of a manual, probably 
the GCC manual or as a shared piece, that would describe what a sysroot is 
and how it drives library and header lookups in the presence of multilibs.  
Then we could refer to that part of the manual from the descriptions of 
the individual options, whose interpretation of the sysroot argument is 
supposed to be really the same (well, with the minor variation that 
`--with-install-sysroot=' does not have a separate usr/ subdirectory in 
addition to /, although in principle it could; cf. the `--with-slibdir=' 
option in libgcc/).  Having that embedded with the description of one of 
the relevant options only would IMO be quite odd.

 Also given my apparent confusion with how sysroots work I may not be the 
best person to try documenting them, or at least it looks like I will 
require considerable guidance with making a description that is actually 
accurate.

 And last but not least: do we want to hold my proposed change hostage to 
a sysroot handling documentation improvement?  It does not appear fair to 
me as the situation with said documentation is not a new problem nor one 
specific to this newly-added option, and the new option merely played the 
role of a trigger for the discovery of the lack of suitable sysroot 
documentation.  Unless you think there is actually a functional issue of 
any kind with the change itself that is.

 Questions, comments, thoughts?

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-22 23:41           ` Maciej W. Rozycki
@ 2019-11-22 23:54             ` Joseph Myers
  2019-11-28 20:45               ` Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2019-11-22 23:54 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Fri, 22 Nov 2019, Maciej W. Rozycki wrote:

>  As I recall the MIPS sysroot setup (please correct me if I got something 
> wrong here) was like:

Yes, that's the sort of layout you get with sysroot suffixes.  See 
gcc/config/mips/{st.h,t-st} for an example.

>  Then the right-hand side of /path/to/somewhere (except for usr/) is what 
> gets printed by `-print-multi-directory' or the left-hand side of output 
> from `-print-multi-lib', e.g. `sof/el/lib64' for the example above.  

Rather, it's a suffix (as in SYSROOT_SUFFIX_SPEC, no command-line option 
to print it), followed by a directory such as /lib64 that comes from 
STARTFILE_PREFIX_SPEC.  (Until MULTILIB_OSDIRNAMES / 
-print-multi-os-directory were added, I think STARTFILE_PREFIX_SPEC was 
the main mechanism for using directories such as /lib64; once the multilib 
OS directory mechanism was added, STARTFILE_PREFIX_SPEC was needed much 
less, but is still relevant for this sysroot use case, along with some 
linker configuration in binutils to teach it about such directories.)

> Similarly `-print-multi-os-directory' prints a directory path relative to 
> a lib/ subdirectory to the sysroot, so that would be `../sof/el/lib64' 
> respectively.

Rather, it's a path relative to the (non-sysroot, before your patch) 
directory where the compiler installs the libraries.  See e.g. t-st using 
paths such as ../lib64/2f.

>  Well, I agree we need to have this stuff documented beyond what we 
> currently have, but I think it applies equally to all the sysroot options 
> we have, including both the `--sysroot=' GCC driver's option, and the 
> `--with-sysroot=', `--with-build-sysroot=' and the newly-proposed 

All three of those refer to the top-level sysroot path, to which a sysroot 
suffix is appended based on SYSROOT_SUFFIX_SPEC (unless 
--no-sysroot-suffix is used).

> `--with-install-sysroot=' `configure' script's options as well.  All we 
> currently have is this paragraph:

But this is a path relative to which SYSROOT_SUFFIX_SPEC isn't used at 
all.

>  And last but not least: do we want to hold my proposed change hostage to 
> a sysroot handling documentation improvement?  It does not appear fair to 
> me as the situation with said documentation is not a new problem nor one 
> specific to this newly-added option, and the new option merely played the 

The proposed new option is, as far as I know, the first one introducing 
this new kind of sysroot option (one for which the suffix from 
SYSROOT_SUFFIX_SPEC is never added).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-22 23:54             ` Joseph Myers
@ 2019-11-28 20:45               ` Maciej W. Rozycki
  2019-11-28 21:06                 ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2019-11-28 20:45 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Fri, 22 Nov 2019, Joseph Myers wrote:

> >  As I recall the MIPS sysroot setup (please correct me if I got something 
> > wrong here) was like:
> 
> Yes, that's the sort of layout you get with sysroot suffixes.  See 
> gcc/config/mips/{st.h,t-st} for an example.

 Thanks for the pointer.

> >  Then the right-hand side of /path/to/somewhere (except for usr/) is what 
> > gets printed by `-print-multi-directory' or the left-hand side of output 
> > from `-print-multi-lib', e.g. `sof/el/lib64' for the example above.  
> 
> Rather, it's a suffix (as in SYSROOT_SUFFIX_SPEC, no command-line option 
> to print it),

 Do you mean that there's no option to print SYSROOT_SUFFIX_SPEC on its 
own or that no option prints it as a path component?  If the latter, then 
I think it's an awful shortcoming, because there's no reasonable way for 
a given GCC compilation to determine the layout expected.

> >  Well, I agree we need to have this stuff documented beyond what we 
> > currently have, but I think it applies equally to all the sysroot options 
> > we have, including both the `--sysroot=' GCC driver's option, and the 
> > `--with-sysroot=', `--with-build-sysroot=' and the newly-proposed 
> 
> All three of those refer to the top-level sysroot path, to which a sysroot 
> suffix is appended based on SYSROOT_SUFFIX_SPEC (unless 
> --no-sysroot-suffix is used).
> 
> > `--with-install-sysroot=' `configure' script's options as well.  All we 
> > currently have is this paragraph:
> 
> But this is a path relative to which SYSROOT_SUFFIX_SPEC isn't used at 
> all.

 Can you please show me the two directory layouts, one for `--sysroot=' 
and the other for `--with-install-sysroot=' aka $toolexeclibdir, say for 
the `mips64el-st-linux-gnu' target, and where exactly in GCC installation 
(if anywhere) the `--sysroot=' layout is used?

 Is it that with $toolexeclibdir we have say:

/usr/mips64el-st-linux-gnu/
                          +-> lib/
                          |      +-> 2e/
                          |      \-> 2f/
                          +-> lib32/
                          |        +-> 2e/
                          |        \-> 2f/
                          \-> lib64/
                                   +-> 2e/
                                   \-> 2f/

whereas `--sysroot=/path/to/sysroot' expects:

/path/to/sysroot/
                +-> 2e/
                |     +-> lib/
                |     +-> lib32/
                |     \-> lib64/
                \-> 2f/
                      +-> lib/
                      +-> lib32/
                      \-> lib64/

(and then GCC applies the former scheme to the directories pointed to by 
the `-B' and `-L' options and the latter scheme to the directory pointed 
to by the `--sysroot=' option)?

> >  And last but not least: do we want to hold my proposed change hostage to 
> > a sysroot handling documentation improvement?  It does not appear fair to 
> > me as the situation with said documentation is not a new problem nor one 
> > specific to this newly-added option, and the new option merely played the 
> 
> The proposed new option is, as far as I know, the first one introducing 
> this new kind of sysroot option (one for which the suffix from 
> SYSROOT_SUFFIX_SPEC is never added).

 Thank you for all your input.

 If my understanding as expressed above is correct, then I think the way 
to move forward with this change will be to rename the option to 
`--with-toolexeclibdir=' or suchlike (and adjust documentation 
accordingly) so that it avoids the ambiguity of "sysroot" and is in line 
with the usual `--bindir=', `--libdir=', etc. or less usual 
`--with-slibdir=' options where people can adjust the various installation 
directories according to their requirements or preferences.

 Then on top of this an option like `--enable-sysroot-for-toolexeclibdir' 
can be discussed in the future, that would switch $toolexeclibdir to the 
proper sysroot layout, whether `--with-toolexeclibdir=' has been used or 
not.  Such an option will necessarily have to rely on the presence of a 
GCC option to print SYSROOT_SUFFIX_SPEC/STARTFILE_PREFIX_SPEC for the 
multilib selected.

 If we agree on this plan, I'll post an update patch.

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add `--with-install-sysroot=' configuration option
  2019-11-28 20:45               ` Maciej W. Rozycki
@ 2019-11-28 21:06                 ` Joseph Myers
  0 siblings, 0 replies; 10+ messages in thread
From: Joseph Myers @ 2019-11-28 21:06 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev, zlib

On Thu, 28 Nov 2019, Maciej W. Rozycki wrote:

> > 
> > Rather, it's a suffix (as in SYSROOT_SUFFIX_SPEC, no command-line option 
> > to print it),
> 
>  Do you mean that there's no option to print SYSROOT_SUFFIX_SPEC on its 
> own or that no option prints it as a path component?  If the latter, then 
> I think it's an awful shortcoming, because there's no reasonable way for 
> a given GCC compilation to determine the layout expected.

There is no option to print the results of expanding SYSROOT_SUFFIX_SPEC 
on its own.  You can use -print-sysroot to print the full sysroot used, 
including the suffix.

>  Is it that with $toolexeclibdir we have say:
> 
> /usr/mips64el-st-linux-gnu/
>                           +-> lib/
>                           |      +-> 2e/
>                           |      \-> 2f/
>                           +-> lib32/
>                           |        +-> 2e/
>                           |        \-> 2f/
>                           \-> lib64/
>                                    +-> 2e/
>                                    \-> 2f/

Yes.

> whereas `--sysroot=/path/to/sysroot' expects:
> 
> /path/to/sysroot/
>                 +-> 2e/
>                 |     +-> lib/
>                 |     +-> lib32/
>                 |     \-> lib64/
>                 \-> 2f/
>                       +-> lib/
>                       +-> lib32/
>                       \-> lib64/

Yes.  This latter structure is currently one that GCC can *use* but never 
*installs* anything into.

>  If my understanding as expressed above is correct, then I think the way 
> to move forward with this change will be to rename the option to 
> `--with-toolexeclibdir=' or suchlike (and adjust documentation 
> accordingly) so that it avoids the ambiguity of "sysroot" and is in line 
> with the usual `--bindir=', `--libdir=', etc. or less usual 
> `--with-slibdir=' options where people can adjust the various installation 
> directories according to their requirements or preferences.

Yes, that seems a plausible approach.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-11-28 21:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14  2:47 [PATCH] Add `--with-install-sysroot=' configuration option Maciej W. Rozycki
2019-11-14  3:06 ` Joseph Myers
2019-11-18  2:04   ` [PATCH v2] " Maciej W. Rozycki
2019-11-19  0:11     ` Joseph Myers
2019-11-20  2:39       ` Maciej W. Rozycki
2019-11-20 17:46         ` Joseph Myers
2019-11-22 23:41           ` Maciej W. Rozycki
2019-11-22 23:54             ` Joseph Myers
2019-11-28 20:45               ` Maciej W. Rozycki
2019-11-28 21:06                 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).