This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add --with-arch-32 etc. configure options
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 3 Jun 2008 15:50:17 +0000 (UTC)
- Subject: Add --with-arch-32 etc. configure options
This patch adds configure options --with-arch-32 --with-arch-64
--with-cpu-32 --with-cpu-64 --with-tune-32 --with-tune-64, similar to
--with-arch etc. but controlling the defaults separately for 32-bit
and 64-bit code generation. The option names follow the preferences
expressed at
<http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00257.html>; that thread
also provides further rationale for when this sort of configuration is
of use (if you wish to have a toolchain with a minimum 32-bit CPU that
isn't 64-bit capable, but also with 64-bit support, for example).
This patch only provides an implementation for x86/x86_64;
implementations for each additional target would be essentially
independent.
Tested i686-pc-linux-gnu with these options in use. OK to commit?
2008-06-03 Joseph Myers <joseph@codesourcery.com>
* config.gcc (all_defaults): Add arch_32 arch_64 cpu_32 cpu_64
tune_32 tune_64.
(i[34567]86-*-* | x86_64-*-*): Add arch_32 arch_64 cpu_32 cpu_64
tune_32 tune_64 to supported_defaults. Allow values not
supporting 64-bit mode for arch_32, cpu_32 and tune_32 for
x86_64. Do not override cpu_32 or cpu_64 values from target name.
(i[34567]86-*-linux*, i[34567]86-*-solaris2.1[0-9]*): Only default
with_cpu_64 to generic for 64-bit-supporting configurations, not
with_cpu. Remove FIXMEs.
* doc/install.texi (--with-cpu-32, --with-cpu-64, --with-arch-32,
--with-arch-64, --with-tune-32, --with-tune-64): Document.
* config/i386/i386.h (OPT_ARCH32, OPT_ARCH64): Define.
(OPTION_DEFAULT_SPECS): Add tune_32, tune_64, cpu_32, cpu_64,
arch_32 and arch_64.
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi (revision 136297)
+++ gcc/doc/install.texi (working copy)
@@ -1019,14 +1019,23 @@
This is an alias for @option{--enable-tls=no}.
@item --with-cpu=@var{cpu}
+@itemx --with-cpu-32=@var{cpu}
+@itemx --with-cpu-64=@var{cpu}
Specify which cpu variant the compiler should generate code for by default.
@var{cpu} will be used as the default value of the @option{-mcpu=} switch.
This option is only supported on some targets, including ARM, i386, M68k,
-PowerPC, and SPARC@.
+PowerPC, and SPARC@. The @option{--with-cpu-32} and
+@option{--with-cpu-64} options specify separate default CPUs for
+32-bit and 64-bit modes; these options are only supported for i386 and
+x86-64.
@item --with-schedule=@var{cpu}
@itemx --with-arch=@var{cpu}
+@itemx --with-arch-32=@var{cpu}
+@itemx --with-arch-64=@var{cpu}
@itemx --with-tune=@var{cpu}
+@itemx --with-tune-32=@var{cpu}
+@itemx --with-tune-64=@var{cpu}
@itemx --with-abi=@var{abi}
@itemx --with-fpu=@var{type}
@itemx --with-float=@var{type}
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc (revision 136297)
+++ gcc/config.gcc (working copy)
@@ -1179,13 +1179,13 @@
tm_defines="${tm_defines} TARGET_BI_ARCH=1"
tmake_file="${tmake_file} i386/t-linux64 i386/t-fprules-softfp64 soft-fp/t-softfp"
need_64bit_hwint=yes
- # FIXME: -m64 for i[34567]86-*-* should be allowed just
- # like -m32 for x86_64-*-*.
case X"${with_cpu}" in
Xgeneric|Xcore2|Xnocona|Xx86-64|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx)
;;
X)
- with_cpu=generic
+ if test x$with_cpu_64 = x; then
+ with_cpu_64=generic
+ fi
;;
*)
echo "Unsupported CPU used in --with-cpu=$with_cpu, supported values:" 1>&2
@@ -1308,13 +1308,13 @@
tm_defines="${tm_defines} TARGET_BI_ARCH=1"
tmake_file="$tmake_file i386/t-crtstuff i386/t-sol2-10"
need_64bit_hwint=yes
- # FIXME: -m64 for i[34567]86-*-* should be allowed just
- # like -m32 for x86_64-*-*.
case X"${with_cpu}" in
Xgeneric|Xcore2|Xnocona|Xx86-64|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx)
;;
X)
- with_cpu=generic
+ if test x$with_cpu_64 = x; then
+ with_cpu_64=generic
+ fi
;;
*)
echo "Unsupported CPU used in --with-cpu=$with_cpu, supported values:" 1>&2
@@ -2842,6 +2842,23 @@
with_cpu="`echo ${target} | sed 's/-.*$//'`"
;;
esac
+
+ # Avoid overriding --with-cpu-32 and --with-cpu-64 values.
+ case ${target} in
+ i[34567]86-*-*|x86_64-*-*)
+ if test x$with_cpu != x; then
+ if test x$with_cpu_32 != x || test x$with_cpu_64 != x; then
+ if test x$with_cpu_32 = x; then
+ with_cpu_32=$with_cpu
+ fi
+ if test x$with_cpu_64 = x; then
+ with_cpu_64=$with_cpu
+ fi
+ with_cpu=
+ fi
+ fi
+ ;;
+ esac
fi
# Similarly for --with-float
@@ -3052,8 +3069,8 @@
;;
i[34567]86-*-* | x86_64-*-*)
- supported_defaults="arch cpu tune"
- for which in arch cpu tune; do
+ supported_defaults="arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64"
+ for which in arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64; do
eval "val=\$with_$which"
case ${val} in
i386 | i486 \
@@ -3064,8 +3081,14 @@
| prescott | pentium-m | pentium4m | pentium3m)
case "${target}" in
x86_64-*-*)
- echo "CPU given in --with-$which=$val doesn't support 64bit mode." 1>&2
- exit 1
+ case "x$which" in
+ *_32)
+ ;;
+ *)
+ echo "CPU given in --with-$which=$val doesn't support 64bit mode." 1>&2
+ exit 1
+ ;;
+ esac
;;
esac
# OK
@@ -3392,7 +3415,7 @@
esac
t=
-all_defaults="abi cpu arch tune schedule float mode fpu divide llsc"
+all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu divide llsc"
for option in $all_defaults
do
eval "val=\$with_$option"
Index: gcc/config/i386/i386.h
===================================================================
--- gcc/config/i386/i386.h (revision 136297)
+++ gcc/config/i386/i386.h (working copy)
@@ -478,13 +478,27 @@
#define HAVE_LOCAL_CPU_DETECT
#endif
+#if TARGET_64BIT_DEFAULT
+#define OPT_ARCH64 "!m32"
+#define OPT_ARCH32 "m32"
+#else
+#define OPT_ARCH64 "m64"
+#define OPT_ARCH32 "!m64"
+#endif
+
/* Support for configure-time defaults of some command line options.
The order here is important so that -march doesn't squash the
tune or cpu values. */
#define OPTION_DEFAULT_SPECS \
{"tune", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, \
+ {"tune_32", "%{" OPT_ARCH32 ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, \
+ {"tune_64", "%{" OPT_ARCH64 ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, \
{"cpu", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, \
- {"arch", "%{!march=*:-march=%(VALUE)}"}
+ {"cpu_32", "%{" OPT_ARCH32 ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, \
+ {"cpu_64", "%{" OPT_ARCH64 ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, \
+ {"arch", "%{!march=*:-march=%(VALUE)}"}, \
+ {"arch_32", "%{" OPT_ARCH32 ":%{!march=*:-march=%(VALUE)}}"}, \
+ {"arch_64", "%{" OPT_ARCH64 ":%{!march=*:-march=%(VALUE)}}"},
/* Specs for the compiler proper */
--
Joseph S. Myers
joseph@codesourcery.com