diff mbox

[RFC,Multilib] Make GCC more easier for user to select and build extra libraries for ARM targets.

Message ID 003601cc704b$3c115a10$b4340e30$@guo@arm.com
State New
Headers show

Commit Message

Terry Guo Sept. 11, 2011, 6:22 a.m. UTC
Hello,

This patch intends to implement a convenient interface for user to customize
the final Multilibs according to their real requirements. There is no
intention to override the default Multilib set, instead it only build
"extra" libraries besides them. Specifically the extra Multilibs can be
selected by user through a new configure option
"--with-extra-multilibs=A-COMMA-SEPARATED-TARGET-LIST". For example if user
want to build extra library for cortex-m0, cortex-m3 and cortex-m4, the
configure option would be
"--with-extra-multilibs=armv6s-m,armv7-m,armv7e-m".

This patch has been in ARM/embedded-4_6-branch. Any comments for applying it
on trunk?

BR,
Terry

2011-09-08  Terry Guo  <terry.guo@arm.com>
 
	* config.gcc: Support --with-extra-multilibs option for ARM EABI.
	* configure.ac: Handle --with-extra-multilibs option.
	* configure: Add help message and support for that option. 
	* doc/install.texi: Document that option.
	* config/arm/t-arm-elf (MULTILIB_OSDIRNAMES): Added to support
	build extra multilibs with user-specified directory name.
	* config/arm/t-armv6s-m: New fragment for building extra multilib
for
	ARM armv6s-m architecture.
	* config/arm/t-armv7-m: New fragment for building extra multilib for
	ARM armv7-m architecture.
	* config/arm/t-armv7e-m: New fragment for building extra multilib
for
	ARM armv7e-m architecture.
	* config/arm/t-thumb1: New fragment for building extra multilib for
	ARM Thumb-1.
	* config/arm/t-thumb2: New fragment for building extra multilib for
	ARM Thumb-2.

Comments

Joseph Myers Sept. 11, 2011, 10:58 a.m. UTC | #1
On Sun, 11 Sep 2011, Terry Guo wrote:

> This patch intends to implement a convenient interface for user to customize
> the final Multilibs according to their real requirements. There is no
> intention to override the default Multilib set, instead it only build
> "extra" libraries besides them. Specifically the extra Multilibs can be
> selected by user through a new configure option
> "--with-extra-multilibs=A-COMMA-SEPARATED-TARGET-LIST". For example if user
> want to build extra library for cortex-m0, cortex-m3 and cortex-m4, the
> configure option would be
> "--with-extra-multilibs=armv6s-m,armv7-m,armv7e-m".

This seems very similar to the --with-multilib-list option for SH and 
x86_64.  I think you should use the same name and share the same 
implementation as far as possible - certainly, you need to explain how 
what you have done compares to that option and justify differences.  If 
the difference is whether the multilibs add to or replace the default 
list, maybe allow "default," to appear in the argument to 
--with-multilib-list to indicate that the default list is added to rather 
than replaced.

> +@item --with-extra-multilibs=@var{list} @itemx 
> +--without-extra-multilibs Specify what extra multilibs to build besides 

You have @itemx on the wrong line here.

> Index: gcc/config/arm/t-armv7e-m
> ===================================================================
> --- gcc/config/arm/t-armv7e-m	(revision 0)
> +++ gcc/config/arm/t-armv7e-m	(revision 0)
> @@ -0,0 +1,16 @@
> +#Build below library for ARM armv7e-m architecture.
> +#  armv7e-m/     -mthumb -march=armv7e-m
> +
> +MULTILIB_OPTIONS      += march=armv7e-m
> +
> +MULTILIB_DIRNAMES     += armv7e-m
> +
> +MULTILIB_EXCEPTIONS   += march=armv7e-m*
> +MULTILIB_EXCEPTIONS   += marm*/march=armv7e-m*
> +MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv7e-m*
> +MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv7e-m*
> +MULTILIB_EXCEPTIONS   += m*/march=armv7e-m/march*
> +
> +MULTILIB_MATCHES      += march?armv7e-m=mcpu?cortex-m4
> +
> +MULTILIB_OSDIRNAMES   += mthumb/march.armv7e-m=!armv7e-m

I don't think having such massive manually maintained files for each 
architecture is sustainable.  Note that when the SH configure option was 
enhanced

2009-04-17  Andrew Stubbs  <ams@codesourcery.com>

it *removed* a load of such files.

m68k/t-mlibs uses awk to process .def files to work out appropriate 
multilib settings in different cases.  That seems a much more sustainable 
way of producing these settings than entering them all manually.
Terry Guo Nov. 17, 2011, 12:18 p.m. UTC | #2
Hello Joseph,

Thanks for your comments. When start to work on Multilib for ARM backend, I
do run into some limitations of GCC Multilib mechanism. The most important
one is just as what you said in thread
http://gcc.gnu.org/ml/gcc/2010-01/msg00063.html, e.g. the limitation of
MULTILIB_MATCHES. So I am very curious of the progress of your proposal. Is
it possible for you to share it? I am also very willing to provide help if
needed.

Best regards,
Terry

> -----Original Message-----
> From: Joseph Myers [mailto:joseph@codesourcery.com]
> Sent: Sunday, September 11, 2011 6:58 PM
> To: Terry Guo
> Cc: gcc-patches@gcc.gnu.org; Richard Earnshaw
> Subject: Re: [RFC][GCC, Multilib]Make GCC more easier for user to
> select and build extra libraries for ARM targets.
> 
> On Sun, 11 Sep 2011, Terry Guo wrote:
> 
> > This patch intends to implement a convenient interface for user to
> customize
> > the final Multilibs according to their real requirements. There is no
> > intention to override the default Multilib set, instead it only build
> > "extra" libraries besides them. Specifically the extra Multilibs can
> be
> > selected by user through a new configure option
> > "--with-extra-multilibs=A-COMMA-SEPARATED-TARGET-LIST". For example
> if user
> > want to build extra library for cortex-m0, cortex-m3 and cortex-m4,
> the
> > configure option would be
> > "--with-extra-multilibs=armv6s-m,armv7-m,armv7e-m".
> 
> This seems very similar to the --with-multilib-list option for SH and
> x86_64.  I think you should use the same name and share the same
> implementation as far as possible - certainly, you need to explain how
> what you have done compares to that option and justify differences.  If
> the difference is whether the multilibs add to or replace the default
> list, maybe allow "default," to appear in the argument to
> --with-multilib-list to indicate that the default list is added to
> rather
> than replaced.
> 
> > +@item --with-extra-multilibs=@var{list} @itemx
> > +--without-extra-multilibs Specify what extra multilibs to build
> besides
> 
> You have @itemx on the wrong line here.
> 
> > Index: gcc/config/arm/t-armv7e-m
> > ===================================================================
> > --- gcc/config/arm/t-armv7e-m	(revision 0)
> > +++ gcc/config/arm/t-armv7e-m	(revision 0)
> > @@ -0,0 +1,16 @@
> > +#Build below library for ARM armv7e-m architecture.
> > +#  armv7e-m/     -mthumb -march=armv7e-m
> > +
> > +MULTILIB_OPTIONS      += march=armv7e-m
> > +
> > +MULTILIB_DIRNAMES     += armv7e-m
> > +
> > +MULTILIB_EXCEPTIONS   += march=armv7e-m*
> > +MULTILIB_EXCEPTIONS   += marm*/march=armv7e-m*
> > +MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv7e-m*
> > +MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv7e-m*
> > +MULTILIB_EXCEPTIONS   += m*/march=armv7e-m/march*
> > +
> > +MULTILIB_MATCHES      += march?armv7e-m=mcpu?cortex-m4
> > +
> > +MULTILIB_OSDIRNAMES   += mthumb/march.armv7e-m=!armv7e-m
> 
> I don't think having such massive manually maintained files for each
> architecture is sustainable.  Note that when the SH configure option
> was
> enhanced
> 
> 2009-04-17  Andrew Stubbs  <ams@codesourcery.com>
> 
> it *removed* a load of such files.
> 
> m68k/t-mlibs uses awk to process .def files to work out appropriate
> multilib settings in different cases.  That seems a much more
> sustainable
> way of producing these settings than entering them all manually.
> 
> --
> Joseph S. Myers
> joseph@codesourcery.com
diff mbox

Patch

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 178754)
+++ gcc/doc/install.texi	(working copy)
@@ -1068,6 +1068,24 @@ 
 --with-multilib-list=sh4al,!mb/m4al
 @end smallexample
 
+@item --with-extra-multilibs=@var{list} @itemx 
+--without-extra-multilibs Specify what extra multilibs to build besides 
+the default library set.
+Currently only implemented for arm*-*-eabi.
+
+@var{list} is a comma separated list of ARM architecture names.
+Currently the available names are thumb1, thumb2, armv6s-m, armv7-m and 
+armv7e-m.
+
+If @option{--with-extra-multilibs} or @var{list} is not given, then no 
+extra multilibs will be built.
+
+Example: to configure a compiler for arm-none-eabi with additional 
+multilib support for thumb1, thumb2 and armv6s-m:
+@smallexample
+--target=arm-none-eabi --with-extra-multilibs=thumb1,thumb2,armv6s-m
+@end smallexample
+
 @item --with-endian=@var{endians}
 Specify what endians to use.
 Currently only implemented for sh*-*-*.
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 178754)
+++ gcc/configure	(working copy)
@@ -1650,6 +1650,7 @@ 
   --with-pkgversion=PKG   Use PKG in the version string in place of "GCC"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-multilib-list    Select multilibs (SH only)
+  --with-extra-multilibs  Select extra multilibs (ARM only)
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and
DIR/lib
   --without-libiconv-prefix     don't search for libiconv in includedir and
libdir
@@ -7198,6 +7199,12 @@ 
   with_multilib_list=default
 fi
 
+# Check whether --with-extra-multilibs was given.
+if test "${with_extra_multilibs+set}" = set; then :
+  withval=$with_extra_multilibs; :
+else
+  with_extra_multilibs=default
+fi
 
 # -------------------------
 # Checks for other programs
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 178754)
+++ gcc/configure.ac	(working copy)
@@ -790,6 +790,11 @@ 
 :,
 with_multilib_list=default)
 
+AC_ARG_WITH(extra-multilibs,
+[  --with-extra-multilibs    Select extra multilibs (ARM only)],
+:,
+with_extra_multilibs=default)
+
 # -------------------------
 # Checks for other programs
 # -------------------------
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 178754)
+++ gcc/config.gcc	(working copy)
@@ -883,6 +883,32 @@ 
 	arm*-*-eabi*)
 	  tm_file="$tm_file newlib-stdint.h"
 	  tmake_file="${tmake_file} arm/t-bpabi"
+	  arm_multilibs="${with_extra_multilibs}"
+	  if test $arm_multilibs != "default"; then
+		arm_multilibs=`echo $arm_multilibs | sed -e 's/,/ /g'`
+		for arm_multilib in ${arm_multilibs}; do
+		    case ${arm_multilib} in
+		    thumb1)
+			tmake_file="${tmake_file} arm/t-thumb1"
+			;;
+		    thumb2)
+			tmake_file="${tmake_file} arm/t-thumb2"
+			;;
+		    armv6s-m)
+			tmake_file="${tmake_file} arm/t-armv6s-m"
+			;;
+		    armv7-m)
+			tmake_file="${tmake_file} arm/t-armv7-m"
+			;;
+		    armv7e-m)
+			tmake_file="${tmake_file} arm/t-armv7e-m"
+			;;
+		    *)
+			echo "--with-extra-multilibs=${arm_multilib} not
supported."
+			exit 1
+		    esac
+		done
+	  fi
 	  use_gcc_stdint=wrap
 	  ;;
 	arm*-*-symbianelf*)
Index: gcc/config/arm/t-arm-elf
===================================================================
--- gcc/config/arm/t-arm-elf	(revision 178754)
+++ gcc/config/arm/t-arm-elf	(working copy)
@@ -35,6 +35,7 @@ 
 MULTILIB_DIRNAMES    = arm thumb
 MULTILIB_EXCEPTIONS  = 
 MULTILIB_MATCHES     =
+MULTILIB_OSDIRNAMES  = marm=!arm mthumb=!thumb
 
 #MULTILIB_OPTIONS     +=
mcpu=fa526/mcpu=fa626/mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te
 #MULTILIB_DIRNAMES    += fa526 fa626 fa606te fa626te fmp626 fa726te
@@ -56,6 +57,7 @@ 
 MULTILIB_OPTIONS       += mfloat-abi=hard
 MULTILIB_DIRNAMES      += fpu
 MULTILIB_EXCEPTIONS    += *mthumb/*mfloat-abi=hard*
+MULTILIB_OSDIRNAMES    += mfloat-abi.hard=!fpu
marm/mfloat-abi.hard=!arm/fpu
 #MULTILIB_EXCEPTIONS    += *mcpu=fa526/*mfloat-abi=hard*
 #MULTILIB_EXCEPTIONS    += *mcpu=fa626/*mfloat-abi=hard*
Index: gcc/config/arm/t-armv7e-m
===================================================================
--- gcc/config/arm/t-armv7e-m	(revision 0)
+++ gcc/config/arm/t-armv7e-m	(revision 0)
@@ -0,0 +1,16 @@ 
+#Build below library for ARM armv7e-m architecture.
+#  armv7e-m/     -mthumb -march=armv7e-m
+
+MULTILIB_OPTIONS      += march=armv7e-m
+
+MULTILIB_DIRNAMES     += armv7e-m
+
+MULTILIB_EXCEPTIONS   += march=armv7e-m*
+MULTILIB_EXCEPTIONS   += marm*/march=armv7e-m*
+MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv7e-m*
+MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv7e-m*
+MULTILIB_EXCEPTIONS   += m*/march=armv7e-m/march*
+
+MULTILIB_MATCHES      += march?armv7e-m=mcpu?cortex-m4
+
+MULTILIB_OSDIRNAMES   += mthumb/march.armv7e-m=!armv7e-m
Index: gcc/config/arm/t-thumb1
===================================================================
--- gcc/config/arm/t-thumb1	(revision 0)
+++ gcc/config/arm/t-thumb1	(revision 0)
@@ -0,0 +1,56 @@ 
+#Build below library for ARM Thumb-1.
+#  thumb1/      -mthumb -march=armv4t
+
+MULTILIB_OPTIONS      += march=armv4t
+
+MULTILIB_DIRNAMES     += thumb1
+
+MULTILIB_EXCEPTIONS   += march=armv4t*
+MULTILIB_EXCEPTIONS   += marm*/march=armv4t*
+MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv4t*
+MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv4t*
+MULTILIB_EXCEPTIONS   += m*/march=armv4t/march*
+
+MULTILIB_MATCHES      += march?armv4t=march?armv5
+MULTILIB_MATCHES      += march?armv4t=march?armv5t
+MULTILIB_MATCHES      += march?armv4t=march?armv5e
+MULTILIB_MATCHES      += march?armv4t=march?armv5te
+MULTILIB_MATCHES      += march?armv4t=march?armv6
+MULTILIB_MATCHES      += march?armv4t=march?armv6j
+MULTILIB_MATCHES      += march?armv4t=march?armv6z
+MULTILIB_MATCHES      += march?armv4t=march?armv6zk
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm7tdmi
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm7tdmi-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm710t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm720t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm740t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm9
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm9tdmi
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm920
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm920t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm922t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm940t
+MULTILIB_MATCHES      += march?armv4t=mcpu?ep9312
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm10tdmi
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1020t
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm9e
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm946e-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm966e-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm968e-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm10e
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1020e
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1022e
+MULTILIB_MATCHES      += march?armv4t=mcpu?xscale
+MULTILIB_MATCHES      += march?armv4t=mcpu?iwmmxt
+MULTILIB_MATCHES      += march?armv4t=mcpu?iwmmxt2
+MULTILIB_MATCHES      += march?armv4t=mcpu?fa606te
+MULTILIB_MATCHES      += march?armv4t=mcpu?fa626te
+MULTILIB_MATCHES      += march?armv4t=mcpu?fmp626
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm926ej-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1026ej-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1136j-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1136jf-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1176jz-s
+MULTILIB_MATCHES      += march?armv4t=mcpu?arm1176jzf-s
+
+MULTILIB_OSDIRNAMES   += mthumb/march.armv4t=!thumb1
Index: gcc/config/arm/t-thumb2
===================================================================
--- gcc/config/arm/t-thumb2	(revision 0)
+++ gcc/config/arm/t-thumb2	(revision 0)
@@ -0,0 +1,25 @@ 
+#Build below library for ARM Thumb-2.
+#  thumb2/      -mthumb -march=armv6t2
+
+MULTILIB_OPTIONS      += march=armv6t2
+
+MULTILIB_DIRNAMES     += thumb2
+
+MULTILIB_EXCEPTIONS   += march=armv6t2*
+MULTILIB_EXCEPTIONS   += marm*/march=armv6t2*
+MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv6t2*
+MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv6t2*
+MULTILIB_EXCEPTIONS   += m*/march=armv6t2/march*
+
+MULTILIB_MATCHES      += march?armv6t2=march?armv7
+MULTILIB_MATCHES      += march?armv6t2=march?armv7-a
+MULTILIB_MATCHES      += march?armv6t2=march?armv7-r
+MULTILIB_MATCHES      += march?armv6t2=mcpu?arm1156t2-s
+MULTILIB_MATCHES      += march?armv6t2=mcpu?arm1156t2f-s
+MULTILIB_MATCHES      += march?armv6t2=mcpu?cortex-a5
+MULTILIB_MATCHES      += march?armv6t2=mcpu?cortex-a8
+MULTILIB_MATCHES      += march?armv6t2=mcpu?cortex-a9
+MULTILIB_MATCHES      += march?armv6t2=mcpu?cortex-r4
+MULTILIB_MATCHES      += march?armv6t2=mcpu?cortex-r4f
+
+MULTILIB_OSDIRNAMES   += mthumb/march.armv6t2=!thumb2
Index: gcc/config/arm/t-armv7-m
===================================================================
--- gcc/config/arm/t-armv7-m	(revision 0)
+++ gcc/config/arm/t-armv7-m	(revision 0)
@@ -0,0 +1,16 @@ 
+#Build below library for ARM armv7-m architecture.
+#  armv7-m/     -mthumb -march=armv7-m
+
+MULTILIB_OPTIONS      += march=armv7-m
+
+MULTILIB_DIRNAMES     += armv7-m
+
+MULTILIB_EXCEPTIONS   += march=armv7-m*
+MULTILIB_EXCEPTIONS   += marm*/march=armv7-m*
+MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv7-m*
+MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv7-m*
+MULTILIB_EXCEPTIONS   += m*/march=armv7-m/march*
+
+MULTILIB_MATCHES      += march?armv7-m=mcpu?cortex-m3
+
+MULTILIB_OSDIRNAMES   += mthumb/march.armv7-m=!armv7-m
Index: gcc/config/arm/t-armv6s-m
===================================================================
--- gcc/config/arm/t-armv6s-m	(revision 0)
+++ gcc/config/arm/t-armv6s-m	(revision 0)
@@ -0,0 +1,18 @@ 
+#Build below library for ARM armv6s-m architecture.
+#  armv6s-m/    -mthumb -march=armv6s-m
+
+MULTILIB_OPTIONS      += march=armv6s-m
+
+MULTILIB_DIRNAMES     += armv6s-m
+
+MULTILIB_EXCEPTIONS   += march=armv6s-m*
+MULTILIB_EXCEPTIONS   += marm*/march=armv6s-m*
+MULTILIB_EXCEPTIONS   += mfloat-abi=hard/march=armv6s-m*
+MULTILIB_EXCEPTIONS   += mthumb/mfloat-abi=hard/march=armv6s-m*
+MULTILIB_EXCEPTIONS   += m*/march=armv6s-m/march*
+
+MULTILIB_MATCHES      += march?armv6s-m=march?armv6-m
+MULTILIB_MATCHES      += march?armv6s-m=mcpu?cortex-m1
+MULTILIB_MATCHES      += march?armv6s-m=mcpu?cortex-m0
+
+MULTILIB_OSDIRNAMES   += mthumb/march.armv6s-m=!armv6s-m