diff mbox series

[RFC] support --with-multilib-list=@/path/name

Message ID orbm6yz3vp.fsf@lxoliva.fsfla.org
State New
Headers show
Series [RFC] support --with-multilib-list=@/path/name | expand

Commit Message

Alexandre Oliva Nov. 9, 2018, 3:07 p.m. UTC
Richard,

Olivier tells me he talked to you briefly at the Cauldron about allowing
custom multilib sets to be configured from custom Makefile fragments
supplied at configure time, and that you was somewhat receptive to the
idea.  I have implemented this as follows, for ARM targets only so far,
using "@/path/name" in the argument to --with-multilib-list to mean
/path/name is to be used as a multilib-list Makefile fragment.

Does this look like an acceptable interface?  Is it ok as far as ARM
maintainers are concerned?

Any objections from maintainers of other targets that support
--with-multilib-list (or from anyone else) to the syntax, to the
implementation, or to extending this possibility to their ports?

for  gcc/ChangeLog

	* config.gcc (tmake_file): Add /path/name to tmake_file for
        each @/path/name in --with-multilib-list on arm-*-* targets.
	* configure.ac: Accept full pathnames in tmake_file.
	* configure: Rebuilt.
	* doc/install.texi (with-multilib-list): Document it.
---
 gcc/config.gcc       |   13 +++++++++++++
 gcc/configure        |    9 ++++++---
 gcc/configure.ac     |    5 ++++-
 gcc/doc/install.texi |   22 +++++++++++++++-------
 4 files changed, 38 insertions(+), 11 deletions(-)

Comments

Richard Earnshaw (lists) Nov. 9, 2018, 3:43 p.m. UTC | #1
On 09/11/2018 15:07, Alexandre Oliva wrote:
> Richard,
> 
> Olivier tells me he talked to you briefly at the Cauldron about allowing
> custom multilib sets to be configured from custom Makefile fragments
> supplied at configure time, and that you was somewhat receptive to the
> idea.  I have implemented this as follows, for ARM targets only so far,
> using "@/path/name" in the argument to --with-multilib-list to mean
> /path/name is to be used as a multilib-list Makefile fragment.
> 
> Does this look like an acceptable interface?  Is it ok as far as ARM
> maintainers are concerned?
> 
> Any objections from maintainers of other targets that support
> --with-multilib-list (or from anyone else) to the syntax, to the
> implementation, or to extending this possibility to their ports?
> 
> for  gcc/ChangeLog
> 
> 	* config.gcc (tmake_file): Add /path/name to tmake_file for
>         each @/path/name in --with-multilib-list on arm-*-* targets.
> 	* configure.ac: Accept full pathnames in tmake_file.
> 	* configure: Rebuilt.
> 	* doc/install.texi (with-multilib-list): Document it.

I'm not opposed to such an extension, but I do have some caveats on the
current implementation (mostly on the implied contract between the
compiler and the person building GCC):

- I'm not sure if we really want to allow combinations of an arbitrary
multilib config with the builtin configurations.  Those are tricky
enough to get right as it is, and requests to support additional libs as
well as those with changes to these makefile fragments might be an
issue.  As such, I think I'd want to say that you either use the builtin
lists *or* you supply your own fragment.

- I'd also be concerned about implying that this interface into the
compiler build system is in any way stable, so I think we'd want to
document explicitly that makefile fragments supplied this way may have
to be tailored to a specific release of GCC.

Given the second point, there's nothing to stop a user copying the
internal makefile fragments into their own fragment and then adjusting
it to work with their additional features; so I don't think the first
restriction is too onerous.

R.

> ---
>  gcc/config.gcc       |   13 +++++++++++++
>  gcc/configure        |    9 ++++++---
>  gcc/configure.ac     |    5 ++++-
>  gcc/doc/install.texi |   22 +++++++++++++++-------
>  4 files changed, 38 insertions(+), 11 deletions(-)
> 
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 7578ff03825e..f1363c41f989 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -3998,6 +3998,19 @@ case "${target}" in
>  					aprofile|rmprofile)
>  						tmake_profile_file="arm/t-multilib"
>  						;;
> +					@/*)
> +						ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`
> +						if test -f "${ml}"; then
> +							tmake_file="${tmake_file} ${ml}"
> +						else
> +							echo "Error: ${ml} does not exist" >&2
> +							exit 1
> +						fi
> +						;;
> +					@*)
> +						echo "Error: multilib config file must start with /" >&2
> +						exit 1
> +						;;
>  					*)
>  						echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
>  						exit 1
> diff --git a/gcc/configure b/gcc/configure
> index b814484ea25b..5f15c7a1ff02 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -12244,7 +12244,10 @@ done
>  tmake_file_=
>  for f in ${tmake_file}
>  do
> -	if test -f ${srcdir}/config/$f
> +	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
> +	then
> +		tmake_file_="${tmake_file_} $f"
> +	elif test -f ${srcdir}/config/$f
>  	then
>  		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
>  	fi
> @@ -18572,7 +18575,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18575 "configure"
> +#line 18578 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -18678,7 +18681,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18681 "configure"
> +#line 18684 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 59585912556b..99a3e6f8f52f 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -1940,7 +1940,10 @@ done
>  tmake_file_=
>  for f in ${tmake_file}
>  do
> -	if test -f ${srcdir}/config/$f
> +	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
> +	then
> +		tmake_file_="${tmake_file_} $f"
> +	elif test -f ${srcdir}/config/$f
>  	then
>  		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
>  	fi
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index be9b07b5d23b..fd19fc590ec8 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -1078,13 +1078,21 @@ values and meaning for each target is given below.
>  
>  @table @code
>  @item arm*-*-*
> -@var{list} is a comma separated list of @code{aprofile} and @code{rmprofile}
> -to build multilibs for A or R and M architecture profiles respectively.  Note
> -that, due to some limitation of the current multilib framework, using the
> -combined @code{aprofile,rmprofile} multilibs selects in some cases a less
> -optimal multilib than when using the multilib profile for the architecture
> -targetted.  The special value @code{default} is also accepted and is equivalent
> -to omitting the option, ie. only the default run-time library will be enabled.
> +@var{list} is a comma separated list of @code{aprofile} and
> +@code{rmprofile} to build multilibs for A or R and M architecture
> +profiles respectively.  Note that, due to some limitation of the current
> +multilib framework, using the combined @code{aprofile,rmprofile}
> +multilibs selects in some cases a less optimal multilib than when using
> +the multilib profile for the architecture targetted.  The special value
> +@code{default} is also accepted and is equivalent to omitting the
> +option, ie. only the default run-time library will be enabled.
> +
> +@var{list} may also contain @code{@@/path/name}, to use the multilib
> +configuration Makefile fragment @file{/path/name}.  Such files enable
> +custom, user-chosen multilib lists to be configured.  Whether multiple
> +such files can be used together depends on the contents of the supplied
> +files.  See @file{gcc/config/arm/t-*profile} for examples of what such
> +Makefile fragments ought to look like.
>  
>  The table below gives the combination of ISAs, architectures, FPUs and
>  floating-point ABIs for which multilibs are built for each accepted value.
>
Palmer Dabbelt Nov. 9, 2018, 8:09 p.m. UTC | #2
On Fri, 09 Nov 2018 07:07:06 PST (-0800), oliva@adacore.com wrote:
> Richard,
>
> Olivier tells me he talked to you briefly at the Cauldron about allowing
> custom multilib sets to be configured from custom Makefile fragments
> supplied at configure time, and that you was somewhat receptive to the
> idea.  I have implemented this as follows, for ARM targets only so far,
> using "@/path/name" in the argument to --with-multilib-list to mean
> /path/name is to be used as a multilib-list Makefile fragment.
>
> Does this look like an acceptable interface?  Is it ok as far as ARM
> maintainers are concerned?
>
> Any objections from maintainers of other targets that support
> --with-multilib-list (or from anyone else) to the syntax, to the
> implementation, or to extending this possibility to their ports?

We've had requests for this feature from users of the RISC-V port, but haven't 
had time to look into it.  One wrinkle in RISC-V land is that we have a script 
in GCC that generates our fragments, so I'm not sure if this is exactly what we 
want.  It's certainly better than our current "just patch GCC" flow, though!

> for  gcc/ChangeLog
>
> 	* config.gcc (tmake_file): Add /path/name to tmake_file for
>         each @/path/name in --with-multilib-list on arm-*-* targets.
> 	* configure.ac: Accept full pathnames in tmake_file.
> 	* configure: Rebuilt.
> 	* doc/install.texi (with-multilib-list): Document it.
> ---
>  gcc/config.gcc       |   13 +++++++++++++
>  gcc/configure        |    9 ++++++---
>  gcc/configure.ac     |    5 ++++-
>  gcc/doc/install.texi |   22 +++++++++++++++-------
>  4 files changed, 38 insertions(+), 11 deletions(-)
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 7578ff03825e..f1363c41f989 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -3998,6 +3998,19 @@ case "${target}" in
>  					aprofile|rmprofile)
>  						tmake_profile_file="arm/t-multilib"
>  						;;
> +					@/*)
> +						ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`
> +						if test -f "${ml}"; then
> +							tmake_file="${tmake_file} ${ml}"
> +						else
> +							echo "Error: ${ml} does not exist" >&2
> +							exit 1
> +						fi
> +						;;
> +					@*)
> +						echo "Error: multilib config file must start with /" >&2
> +						exit 1
> +						;;
>  					*)
>  						echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
>  						exit 1
> diff --git a/gcc/configure b/gcc/configure
> index b814484ea25b..5f15c7a1ff02 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -12244,7 +12244,10 @@ done
>  tmake_file_=
>  for f in ${tmake_file}
>  do
> -	if test -f ${srcdir}/config/$f
> +	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
> +	then
> +		tmake_file_="${tmake_file_} $f"
> +	elif test -f ${srcdir}/config/$f
>  	then
>  		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
>  	fi
> @@ -18572,7 +18575,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18575 "configure"
> +#line 18578 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -18678,7 +18681,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 18681 "configure"
> +#line 18684 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 59585912556b..99a3e6f8f52f 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -1940,7 +1940,10 @@ done
>  tmake_file_=
>  for f in ${tmake_file}
>  do
> -	if test -f ${srcdir}/config/$f
> +	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
> +	then
> +		tmake_file_="${tmake_file_} $f"
> +	elif test -f ${srcdir}/config/$f
>  	then
>  		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
>  	fi
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index be9b07b5d23b..fd19fc590ec8 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -1078,13 +1078,21 @@ values and meaning for each target is given below.
>  
>  @table @code
>  @item arm*-*-*
> -@var{list} is a comma separated list of @code{aprofile} and @code{rmprofile}
> -to build multilibs for A or R and M architecture profiles respectively.  Note
> -that, due to some limitation of the current multilib framework, using the
> -combined @code{aprofile,rmprofile} multilibs selects in some cases a less
> -optimal multilib than when using the multilib profile for the architecture
> -targetted.  The special value @code{default} is also accepted and is equivalent
> -to omitting the option, ie. only the default run-time library will be enabled.
> +@var{list} is a comma separated list of @code{aprofile} and
> +@code{rmprofile} to build multilibs for A or R and M architecture
> +profiles respectively.  Note that, due to some limitation of the current
> +multilib framework, using the combined @code{aprofile,rmprofile}
> +multilibs selects in some cases a less optimal multilib than when using
> +the multilib profile for the architecture targetted.  The special value
> +@code{default} is also accepted and is equivalent to omitting the
> +option, ie. only the default run-time library will be enabled.
> +
> +@var{list} may also contain @code{@@/path/name}, to use the multilib
> +configuration Makefile fragment @file{/path/name}.  Such files enable
> +custom, user-chosen multilib lists to be configured.  Whether multiple
> +such files can be used together depends on the contents of the supplied
> +files.  See @file{gcc/config/arm/t-*profile} for examples of what such
> +Makefile fragments ought to look like.
>  
>  The table below gives the combination of ISAs, architectures, FPUs and
>  floating-point ABIs for which multilibs are built for each accepted value.
>
> -- 
> Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
> Be the change, be Free!         FSF Latin America board member
> GNU Toolchain Engineer                Free Software Evangelist
> Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe
Alexandre Oliva Nov. 12, 2018, 8:50 a.m. UTC | #3
On Nov  9, 2018, "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com> wrote:

> - I'm not sure if we really want to allow combinations of an arbitrary
> multilib config with the builtin configurations.  Those are tricky
> enough to get right as it is, and requests to support additional libs as
> well as those with changes to these makefile fragments might be an
> issue.  As such, I think I'd want to say that you either use the builtin
> lists *or* you supply your own fragment.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index f1363c41f989..20c2765d186f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3991,6 +3991,7 @@ case "${target}" in
 
 		# Add extra multilibs
 		if test "x$with_multilib_list" != x; then
+			ml=
 			arm_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
 			if test "x${arm_multilibs}" != xdefault ; then
 				for arm_multilib in ${arm_multilibs}; do
@@ -4031,6 +4032,9 @@ case "${target}" in
 				    || test "x$with_mode" != x ; then
 				    echo "Error: You cannot use any of --with-arch/cpu/fpu/float/mode with --with-multilib-list=${with_multilib_list}" 1>&2
 				    exit 1
+				elif test "x$ml" != x ; then
+				    echo "Error: You cannot use builtin multilib profiles along with custom ones" 1>&2
+				    exit 1
 				fi
 				# But pass the default value for float-abi
 				# through to the multilib selector


> - I'd also be concerned about implying that this interface into the
> compiler build system is in any way stable, so I think we'd want to
> document explicitly that makefile fragments supplied this way may have
> to be tailored to a specific release of GCC.

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index fd19fc590ec8..925a120ae7f4 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1087,12 +1087,23 @@ the multilib profile for the architecture targetted.  The special value
 @code{default} is also accepted and is equivalent to omitting the
 option, ie. only the default run-time library will be enabled.
 
-@var{list} may also contain @code{@@/path/name}, to use the multilib
+@var{list} may instead contain @code{@@/path/name}, to use the multilib
 configuration Makefile fragment @file{/path/name}.  Such files enable
 custom, user-chosen multilib lists to be configured.  Whether multiple
 such files can be used together depends on the contents of the supplied
-files.  See @file{gcc/config/arm/t-*profile} for examples of what such
-Makefile fragments ought to look like.
+files.  See @file{gcc/config/arm/t-multilib} and
+@file{gcc/config/arm/t-*profile} for examples of what such Makefile
+fragments might look like for this version of GCC.  The macros expected
+to be defined in these fragments are not stable across GCC releases, so
+make sure they define the @code{MULTILIB}-related macros expected by
+the version of GCC you are building.
+@ifnothtml
+@xref{Target Fragment,, Target Makefile Fragments, gccint, GNU Compiler
+Collection (GCC) Internals}.
+@end ifnothtml
+@ifhtml
+See ``Target Makefile Fragments'' in the internals manual.
+@end ifhtml
 
 The table below gives the combination of ISAs, architectures, FPUs and
 floating-point ABIs for which multilibs are built for each accepted value.


> Given the second point, there's nothing to stop a user copying the
> internal makefile fragments into their own fragment and then adjusting
> it to work with their additional features; so I don't think the first
> restriction is too onerous.

*nod*.  I'm having second thoughts on specifying external files with a
full pathname, though, as it might lead to accidental GPL violations.
Having the fragments in the source tree won't guarantee they are
included in corresponding sources, but at least for some workflows it
won't require significant procedural changes to get them included in
corresponding sources.


for  gcc/ChangeLog

	* config.gcc (tmake_file): Add /path/name to tmake_file for
        each @/path/name in --with-multilib-list on arm-*-* targets.
	* configure.ac: Accept full pathnames in tmake_file.
	* configure: Rebuilt.
	* doc/install.texi (with-multilib-list): Document it.
---
 gcc/config.gcc       |   17 +++++++++++++++++
 gcc/configure        |    9 ++++++---
 gcc/configure.ac     |    5 ++++-
 gcc/doc/install.texi |   33 ++++++++++++++++++++++++++-------
 4 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7578ff03825e..20c2765d186f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3991,6 +3991,7 @@ case "${target}" in
 
 		# Add extra multilibs
 		if test "x$with_multilib_list" != x; then
+			ml=
 			arm_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
 			if test "x${arm_multilibs}" != xdefault ; then
 				for arm_multilib in ${arm_multilibs}; do
@@ -3998,6 +3999,19 @@ case "${target}" in
 					aprofile|rmprofile)
 						tmake_profile_file="arm/t-multilib"
 						;;
+					@/*)
+						ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`
+						if test -f "${ml}"; then
+							tmake_file="${tmake_file} ${ml}"
+						else
+							echo "Error: ${ml} does not exist" >&2
+							exit 1
+						fi
+						;;
+					@*)
+						echo "Error: multilib config file must start with /" >&2
+						exit 1
+						;;
 					*)
 						echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
 						exit 1
@@ -4018,6 +4032,9 @@ case "${target}" in
 				    || test "x$with_mode" != x ; then
 				    echo "Error: You cannot use any of --with-arch/cpu/fpu/float/mode with --with-multilib-list=${with_multilib_list}" 1>&2
 				    exit 1
+				elif test "x$ml" != x ; then
+				    echo "Error: You cannot use builtin multilib profiles along with custom ones" 1>&2
+				    exit 1
 				fi
 				# But pass the default value for float-abi
 				# through to the multilib selector
diff --git a/gcc/configure b/gcc/configure
index b814484ea25b..5f15c7a1ff02 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12244,7 +12244,10 @@ done
 tmake_file_=
 for f in ${tmake_file}
 do
-	if test -f ${srcdir}/config/$f
+	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
+	then
+		tmake_file_="${tmake_file_} $f"
+	elif test -f ${srcdir}/config/$f
 	then
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
@@ -18572,7 +18575,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18575 "configure"
+#line 18578 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18678,7 +18681,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18681 "configure"
+#line 18684 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 59585912556b..99a3e6f8f52f 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1940,7 +1940,10 @@ done
 tmake_file_=
 for f in ${tmake_file}
 do
-	if test -f ${srcdir}/config/$f
+	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
+	then
+		tmake_file_="${tmake_file_} $f"
+	elif test -f ${srcdir}/config/$f
 	then
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index be9b07b5d23b..925a120ae7f4 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1078,13 +1078,32 @@ values and meaning for each target is given below.
 
 @table @code
 @item arm*-*-*
-@var{list} is a comma separated list of @code{aprofile} and @code{rmprofile}
-to build multilibs for A or R and M architecture profiles respectively.  Note
-that, due to some limitation of the current multilib framework, using the
-combined @code{aprofile,rmprofile} multilibs selects in some cases a less
-optimal multilib than when using the multilib profile for the architecture
-targetted.  The special value @code{default} is also accepted and is equivalent
-to omitting the option, ie. only the default run-time library will be enabled.
+@var{list} is a comma separated list of @code{aprofile} and
+@code{rmprofile} to build multilibs for A or R and M architecture
+profiles respectively.  Note that, due to some limitation of the current
+multilib framework, using the combined @code{aprofile,rmprofile}
+multilibs selects in some cases a less optimal multilib than when using
+the multilib profile for the architecture targetted.  The special value
+@code{default} is also accepted and is equivalent to omitting the
+option, ie. only the default run-time library will be enabled.
+
+@var{list} may instead contain @code{@@/path/name}, to use the multilib
+configuration Makefile fragment @file{/path/name}.  Such files enable
+custom, user-chosen multilib lists to be configured.  Whether multiple
+such files can be used together depends on the contents of the supplied
+files.  See @file{gcc/config/arm/t-multilib} and
+@file{gcc/config/arm/t-*profile} for examples of what such Makefile
+fragments might look like for this version of GCC.  The macros expected
+to be defined in these fragments are not stable across GCC releases, so
+make sure they define the @code{MULTILIB}-related macros expected by
+the version of GCC you are building.
+@ifnothtml
+@xref{Target Fragment,, Target Makefile Fragments, gccint, GNU Compiler
+Collection (GCC) Internals}.
+@end ifnothtml
+@ifhtml
+See ``Target Makefile Fragments'' in the internals manual.
+@end ifhtml
 
 The table below gives the combination of ISAs, architectures, FPUs and
 floating-point ABIs for which multilibs are built for each accepted value.
Alexandre Oliva Dec. 7, 2018, 9:22 p.m. UTC | #4
On Nov 12, 2018, Alexandre Oliva <oliva@adacore.com> wrote:

> I'm having second thoughts on specifying external files with a
> full pathname, though, as it might lead to accidental GPL violations.

Here's a patch that takes the multilib list file from gcc/config/arm.

Any objections, further requests or advice, before I put it in and
proceed to extend it to other targets?


support --with-multilib-list=@name for ARM

Introduce @name as a means to specify alternate multilib profiles as
arguments to --with-multilib-list.

So far this is only implemented for ARM.

Tested on x86_64-linux-gnu-x-arm-eabi, comparing multilib.h before and
after the patch after configuring with preexisting profiles, and also 
@name with and without preexisting profiles.


for  gcc/ChangeLog

	* config.gcc (tmake_file): Add name to tmake_file for
        each @name in --with-multilib-list on arm-*-* targets.
	* doc/install.texi (with-multilib-list): Document it.
---
 gcc/config.gcc       |   13 +++++++++++++
 gcc/doc/install.texi |   43 +++++++++++++++++++++++++++++++++----------
 2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 71f083555a44..2f10b73f525b 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4040,6 +4040,7 @@ case "${target}" in
 
 		# Add extra multilibs
 		if test "x$with_multilib_list" != x; then
+			ml=
 			arm_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
 			if test "x${arm_multilibs}" != xdefault ; then
 				for arm_multilib in ${arm_multilibs}; do
@@ -4047,6 +4048,15 @@ case "${target}" in
 					aprofile|rmprofile)
 						tmake_profile_file="arm/t-multilib"
 						;;
+					@*)
+						ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`
+						if test -f "${srcdir}/config/arm/${ml}"; then
+							tmake_file="${tmake_file} arm/${ml}"
+						else
+							echo "Error: ${ml} does not exist in ${srcdir}/config/arm" >&2
+							exit 1
+						fi
+						;;
 					*)
 						echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
 						exit 1
@@ -4067,6 +4077,9 @@ case "${target}" in
 				    || test "x$with_mode" != x ; then
 				    echo "Error: You cannot use any of --with-arch/cpu/fpu/float/mode with --with-multilib-list=${with_multilib_list}" 1>&2
 				    exit 1
+				elif test "x$ml" != x ; then
+				    echo "Error: You cannot use builtin multilib profiles along with custom ones" 1>&2
+				    exit 1
 				fi
 				# But pass the default value for float-abi
 				# through to the multilib selector
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 19adb7ef8705..443003b0fde6 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1078,18 +1078,41 @@ values and meaning for each target is given below.
 
 @table @code
 @item arm*-*-*
-@var{list} is a comma separated list of @code{aprofile} and @code{rmprofile}
-to build multilibs for A or R and M architecture profiles respectively.  Note
-that, due to some limitation of the current multilib framework, using the
-combined @code{aprofile,rmprofile} multilibs selects in some cases a less
-optimal multilib than when using the multilib profile for the architecture
-targetted.  The special value @code{default} is also accepted and is equivalent
-to omitting the option, ie. only the default run-time library will be enabled.
+@var{list} is a comma separated list of @code{aprofile} and
+@code{rmprofile} to build multilibs for A or R and M architecture
+profiles respectively.  Note that, due to some limitation of the current
+multilib framework, using the combined @code{aprofile,rmprofile}
+multilibs selects in some cases a less optimal multilib than when using
+the multilib profile for the architecture targetted.  The special value
+@code{default} is also accepted and is equivalent to omitting the
+option, i.e., only the default run-time library will be enabled.
+
+@var{list} may instead contain @code{@@name}, to use the multilib
+configuration Makefile fragment @file{name} in @file{gcc/config/arm} in
+the source tree (it is part of the corresponding sources, after all).
+It is recommended, but not required, that files used for this purpose to
+be named starting with @file{t-ml-}, to make their intended purpose
+self-evident, in line with GCC conventions.  Such files enable custom,
+user-chosen multilib lists to be configured.  Whether multiple such
+files can be used together depends on the contents of the supplied
+files.  See @file{gcc/config/arm/t-multilib} and its supplementary
+@file{gcc/config/arm/t-*profile} files for an example of what such
+Makefile fragments might look like for this version of GCC.  The macros
+expected to be defined in these fragments are not stable across GCC
+releases, so make sure they define the @code{MULTILIB}-related macros
+expected by the version of GCC you are building.
+@ifnothtml
+@xref{Target Fragment,, Target Makefile Fragments, gccint, GNU Compiler
+Collection (GCC) Internals}.
+@end ifnothtml
+@ifhtml
+See ``Target Makefile Fragments'' in the internals manual.
+@end ifhtml
 
 The table below gives the combination of ISAs, architectures, FPUs and
-floating-point ABIs for which multilibs are built for each accepted value.
-The union of these options is considered when specifying both @code{aprofile}
-and @code{rmprofile}.
+floating-point ABIs for which multilibs are built for each predefined
+profile.  The union of these options is considered when specifying both
+@code{aprofile} and @code{rmprofile}.
 
 @multitable @columnfractions .15 .28 .30
 @item Option @tab aprofile @tab rmprofile
Alexandre Oliva Dec. 21, 2018, 6 a.m. UTC | #5
On Dec  7, 2018, Alexandre Oliva <oliva@adacore.com> wrote:

> Any objections, further requests or advice, before I put it in and

FTR, I've just checked it in.
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7578ff03825e..f1363c41f989 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3998,6 +3998,19 @@  case "${target}" in
 					aprofile|rmprofile)
 						tmake_profile_file="arm/t-multilib"
 						;;
+					@/*)
+						ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`
+						if test -f "${ml}"; then
+							tmake_file="${tmake_file} ${ml}"
+						else
+							echo "Error: ${ml} does not exist" >&2
+							exit 1
+						fi
+						;;
+					@*)
+						echo "Error: multilib config file must start with /" >&2
+						exit 1
+						;;
 					*)
 						echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
 						exit 1
diff --git a/gcc/configure b/gcc/configure
index b814484ea25b..5f15c7a1ff02 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12244,7 +12244,10 @@  done
 tmake_file_=
 for f in ${tmake_file}
 do
-	if test -f ${srcdir}/config/$f
+	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
+	then
+		tmake_file_="${tmake_file_} $f"
+	elif test -f ${srcdir}/config/$f
 	then
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
@@ -18572,7 +18575,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18575 "configure"
+#line 18578 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18678,7 +18681,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18681 "configure"
+#line 18684 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 59585912556b..99a3e6f8f52f 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1940,7 +1940,10 @@  done
 tmake_file_=
 for f in ${tmake_file}
 do
-	if test -f ${srcdir}/config/$f
+	if test -n `echo "X$f" | sed -n '1s,^X/.*,/,p` && test -f "$f"
+	then
+		tmake_file_="${tmake_file_} $f"
+	elif test -f ${srcdir}/config/$f
 	then
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index be9b07b5d23b..fd19fc590ec8 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1078,13 +1078,21 @@  values and meaning for each target is given below.
 
 @table @code
 @item arm*-*-*
-@var{list} is a comma separated list of @code{aprofile} and @code{rmprofile}
-to build multilibs for A or R and M architecture profiles respectively.  Note
-that, due to some limitation of the current multilib framework, using the
-combined @code{aprofile,rmprofile} multilibs selects in some cases a less
-optimal multilib than when using the multilib profile for the architecture
-targetted.  The special value @code{default} is also accepted and is equivalent
-to omitting the option, ie. only the default run-time library will be enabled.
+@var{list} is a comma separated list of @code{aprofile} and
+@code{rmprofile} to build multilibs for A or R and M architecture
+profiles respectively.  Note that, due to some limitation of the current
+multilib framework, using the combined @code{aprofile,rmprofile}
+multilibs selects in some cases a less optimal multilib than when using
+the multilib profile for the architecture targetted.  The special value
+@code{default} is also accepted and is equivalent to omitting the
+option, ie. only the default run-time library will be enabled.
+
+@var{list} may also contain @code{@@/path/name}, to use the multilib
+configuration Makefile fragment @file{/path/name}.  Such files enable
+custom, user-chosen multilib lists to be configured.  Whether multiple
+such files can be used together depends on the contents of the supplied
+files.  See @file{gcc/config/arm/t-*profile} for examples of what such
+Makefile fragments ought to look like.
 
 The table below gives the combination of ISAs, architectures, FPUs and
 floating-point ABIs for which multilibs are built for each accepted value.