diff mbox

WORD_SWITCH_TAKES_ARG cleanup

Message ID Pine.LNX.4.64.1010272051240.13568@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Oct. 27, 2010, 8:52 p.m. UTC
This patch, relative to a tree with
<http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02102.html> (pending
review) applied, cleans up uses of WORD_SWITCH_TAKES_ARG.

With this patch applied, all options taking a single separate argument
are now known to .opt files; WORD_SWITCH_TAKES_ARG remains solely for
those Darwin options taking more than one argument, until the .opt
machinery has support for such options added.

FreeBSD accepted several options (passed through to the linker by
specs), which go in a new freebsd.opt file.  The FreeBSD
-dynamic-linker option, which was accepted by the
WORD_SWITCH_TAKES_ARG, had no corresponding spec to pass it through to
the linker, so I did not include it in the .opt file.

(There are a lot of *broken* specs for different targets of the form
"%{!dynamic-linker:-dynamic-linker /lib/ld.so}".  These treat
-dynamic-linker as a no-argument option whose effect is to disable the
passing of a -dynamic-linker option to the linker.  The intended
effect is clearly to avoid passing such an option if the user
specified a dynamic linker explicitly - but it doesn't have that
effect as there are no specs to pass through an explicit
-dynamic-linker option and its argument.  Thus, all these specs should
be simplified in a subsequent cleanup to remove the
"%{!dynamic-linker:}" parts.)

Some targets, including FreeBSD, accepted -rpath in
WORD_SWITCH_TAKES_ARG.  These were made to use a new rpath.opt.  For
the definition in alpha.h, alpha-dec-osf5.1 appeared to be the
relevant target, since the only Alpha targets with relevant specs are
FreeBSD and OSF.

Three Darwin options -arch, -arch_only, -precomp-trustfile had no
corresponding specs that would accept them; thus they are not added to
darwin.opt.  I suppose the inclusion in WORD_SWITCH_TAKES_ARG was
mistakenly added to the FSF tree without the actual implementations of
those options.

There was some CRIS code to deal with a -target option, apparently
working around some problem with Sun make.  It makes no sense for such
a workaround to go in architecture-specific code; in some cases we
accept options for compatibility with a system compiler, but that's
OS-specific and the concept of such a system compiler to be compatible
with doesn't make sense for CRIS.  Thus, this workaround is removed by
this patch.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
tested building cc1 for crosses to: alpha-dec-osf5.1 i686-interix3
mips-sgi-irix6.5 i686-freebsd8.1 cris-elf i686-darwin.  (As with the
previous patch, i686-interix3 fails for unrelated reasons.)  OK to
commit?

2010-10-27  Joseph Myers  <joseph@codesourcery.com>

	* config/alpha/alpha.h (WORD_SWITCH_TAKES_ARG): Remove.
	* config/cris/cris.h (WORD_SWITCH_TAKES_ARG): Remove.
	(CC1_SPEC): Don't handle -target.
	* config/darwin.h (WORD_SWITCH_TAKES_ARG): Remove single-argument
	options.
	* config/darwin.opt (Zallowable_client, Zbundle_loader,
	Zdylib_file, Zexported_symbols_list, Zfn_seg_addr_table_filename,
	Zimage_base, Zinit, Zinstall_name, Zmultiply_defined,
	Zmultiplydefinedunused, Zseg_addr_table, Zsegs_read_only_addr,
	Zsegs_read_write_addr, Zumbrella, Zunexported_symbols_list,
	Zweak_reference_mismatches, client_name, compatibility_version,
	current_version, dylinker_install_name, pagezero_size,
	read_only_relocs, seg1addr, segs_read_only_addr,
	segs_read_write_addr, sub_library, sub_umbrella): New.
	* config/freebsd-spec.h (BSD_WORD_SWITCH_TAKES_ARG): Remove.
	* config/freebsd.h (WORD_SWITCH_TAKES_ARG): Remove.
	* config/freebsd.opt: New.
	* config/interix.h (WORD_SWITCH_TAKES_ARG): Remove.
	* config/mips/iris6.h (WORD_SWITCH_TAKES_ARG): Remove.
	* config/rpath.opt: New.
	* config.gcc (*-*-freebsd*): Use rpath.opt and freebsd.opt.
	(alpha*-dec-osf5.1*, i[34567]86-*-interix3*, mips-sgi-irix6.5*):
	Use rpath.opt.

Comments

Rainer Orth Oct. 28, 2010, 9:26 a.m. UTC | #1
"Joseph S. Myers" <joseph@codesourcery.com> writes:

> Some targets, including FreeBSD, accepted -rpath in
> WORD_SWITCH_TAKES_ARG.  These were made to use a new rpath.opt.  For
> the definition in alpha.h, alpha-dec-osf5.1 appeared to be the
> relevant target, since the only Alpha targets with relevant specs are
> FreeBSD and OSF.
[...]
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
> tested building cc1 for crosses to: alpha-dec-osf5.1 i686-interix3
> mips-sgi-irix6.5 i686-freebsd8.1 cris-elf i686-darwin.  (As with the
> previous patch, i686-interix3 fails for unrelated reasons.)  OK to
> commit?

The IRIX 6.5 and Tru64 UNIX parts look good.

> diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/rpath.opt gcc-mainline/gcc/config/rpath.opt
> --- gcc-mainline-0/gcc/config/rpath.opt	1969-12-31 16:00:00.000000000 -0800
> +++ gcc-mainline/gcc/config/rpath.opt	2010-10-27 10:11:13.000000000 -0700
> @@ -0,0 +1,29 @@
> +; -rpath option to the driver.

Incomplete sentence?

> +; See the GCC internals manual (options.texi) for a description of this file's format.

Line too long.

Thanks.
        Rainer
Joseph Myers Oct. 28, 2010, 11:55 a.m. UTC | #2
On Thu, 28 Oct 2010, Rainer Orth wrote:

> > diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/rpath.opt gcc-mainline/gcc/config/rpath.opt
> > --- gcc-mainline-0/gcc/config/rpath.opt	1969-12-31 16:00:00.000000000 -0800
> > +++ gcc-mainline/gcc/config/rpath.opt	2010-10-27 10:11:13.000000000 -0700
> > @@ -0,0 +1,29 @@
> > +; -rpath option to the driver.
> 
> Incomplete sentence?

I don't see any use in making this more of a sentence than "Options for 
the language- and target-independent parts of the compiler." in common.opt 
(which is the model for such files), or "FreeBSD options." - that is, I 
don't see a problem with not having a verb here.
diff mbox

Patch

diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/alpha/alpha.h gcc-mainline/gcc/config/alpha/alpha.h
--- gcc-mainline-0/gcc/config/alpha/alpha.h	2010-10-24 08:35:22.000000000 -0700
+++ gcc-mainline/gcc/config/alpha/alpha.h	2010-10-27 10:03:07.000000000 -0700
@@ -96,9 +96,6 @@  along with GCC; see the file COPYING3.  
   while (0)
 #endif
 
-#define WORD_SWITCH_TAKES_ARG(STR)		\
- (!strcmp (STR, "rpath") || DEFAULT_WORD_SWITCH_TAKES_ARG(STR))
-
 /* Print subsidiary information on the compiler version in use.  */
 #define TARGET_VERSION
 
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/cris/cris.h gcc-mainline/gcc/config/cris/cris.h
--- gcc-mainline-0/gcc/config/cris/cris.h	2010-10-04 04:47:05.000000000 -0700
+++ gcc-mainline/gcc/config/cris/cris.h	2010-10-27 10:04:19.000000000 -0700
@@ -96,14 +96,6 @@  extern int cris_cpu_version;
 
 /* Node: Driver */
 
-/* When using make with defaults.mak for Sun this will handily remove
-   any "-target sun*" switches.  */
-/* We need to override any previous definitions (linux.h) */
-#undef WORD_SWITCH_TAKES_ARG
-#define WORD_SWITCH_TAKES_ARG(STR)		\
- (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)		\
-  || !strcmp (STR, "target"))
-
 /* Also provide canonical vN definitions when user specifies an alias.
    Note that -melf overrides -maout.  */
 
@@ -168,12 +160,10 @@  extern int cris_cpu_version;
     " -D__CRIS_arch_tune=" CRIS_DEFAULT_TUNE "}}}}}"\
  CRIS_ARCH_CPP_DEFAULT
 
-/* Remove those Sun-make "target" switches.  */
 /* Override previous definitions (linux.h).  */
 #undef CC1_SPEC
 #define CC1_SPEC \
- "%{target*:}\
-  %{metrax4:-march=v3}\
+ "%{metrax4:-march=v3}\
   %{metrax100:-march=v8}\
   %(cc1_subtarget)"
 
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/darwin.h gcc-mainline/gcc/config/darwin.h
--- gcc-mainline-0/gcc/config/darwin.h	2010-10-24 09:57:10.000000000 -0700
+++ gcc-mainline/gcc/config/darwin.h	2010-10-27 10:22:14.000000000 -0700
@@ -198,43 +198,13 @@  extern GTY(()) int darwin_ms_struct;
 #undef  WORD_SWITCH_TAKES_ARG
 #define WORD_SWITCH_TAKES_ARG(STR)              \
   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) ? 1 :    \
-   !strcmp (STR, "Zallowable_client") ? 1 :     \
-   !strcmp (STR, "arch") ? 1 :                  \
-   !strcmp (STR, "arch_only") ? 1 :             \
-   !strcmp (STR, "Zbundle_loader") ? 1 :        \
-   !strcmp (STR, "client_name") ? 1 :           \
-   !strcmp (STR, "compatibility_version") ? 1 : \
-   !strcmp (STR, "current_version") ? 1 :       \
-   !strcmp (STR, "Zdylib_file") ? 1 :           \
-   !strcmp (STR, "Zexported_symbols_list") ? 1 : \
-   !strcmp (STR, "Zimage_base") ? 1 :           \
-   !strcmp (STR, "Zinit") ? 1 :                 \
-   !strcmp (STR, "Zinstall_name") ? 1 :         \
-   !strcmp (STR, "Zmultiplydefinedunused") ? 1 : \
-   !strcmp (STR, "Zmultiply_defined") ? 1 :     \
-   !strcmp (STR, "precomp-trustfile") ? 1 :     \
-   !strcmp (STR, "read_only_relocs") ? 1 :      \
    !strcmp (STR, "sectcreate") ? 3 :            \
    !strcmp (STR, "sectorder") ? 3 :             \
    !strcmp (STR, "Zsegaddr") ? 2 :              \
-   !strcmp (STR, "Zsegs_read_only_addr") ? 1 :  \
-   !strcmp (STR, "Zsegs_read_write_addr") ? 1 : \
-   !strcmp (STR, "Zseg_addr_table") ? 1 :       \
-   !strcmp (STR, "Zfn_seg_addr_table_filename") ? 1 :\
-   !strcmp (STR, "seg1addr") ? 1 :              \
    !strcmp (STR, "segprot") ? 3 :               \
-   !strcmp (STR, "sub_library") ? 1 :           \
-   !strcmp (STR, "sub_umbrella") ? 1 :          \
-   !strcmp (STR, "Zumbrella") ? 1 :             \
-   !strcmp (STR, "Zunexported_symbols_list") ? 1 : \
-   !strcmp (STR, "Zweak_reference_mismatches") ? 1 : \
-   !strcmp (STR, "pagezero_size") ? 1 :         \
-   !strcmp (STR, "segs_read_only_addr") ? 1 :   \
-   !strcmp (STR, "segs_read_write_addr") ? 1 :  \
    !strcmp (STR, "sectalign") ? 3 :             \
    !strcmp (STR, "sectobjectsymbols") ? 2 :     \
    !strcmp (STR, "segcreate") ? 3 :             \
-   !strcmp (STR, "dylinker_install_name") ? 1 : \
    0)
 
 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do {                        \
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/darwin.opt gcc-mainline/gcc/config/darwin.opt
--- gcc-mainline-0/gcc/config/darwin.opt	2010-10-22 05:11:04.000000000 -0700
+++ gcc-mainline/gcc/config/darwin.opt	2010-10-27 10:28:02.000000000 -0700
@@ -1,6 +1,6 @@ 
 ; Processor-independent options for Darwin.
 
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -54,5 +54,86 @@  iframework
 Target RejectNegative C ObjC C++ ObjC++ Joined Separate 
 -iframework <dir>	Add <dir> to the end of the system framework include path
 
+Zallowable_client
+Driver Separate
+
+Zbundle_loader
+Driver Separate
+
+Zdylib_file
+Driver Separate
+
+Zexported_symbols_list
+Driver Separate
+
+Zfn_seg_addr_table_filename
+Driver Separate
+
+Zimage_base
+Driver Separate
+
+Zinit
+Driver Separate
+
+Zinstall_name
+Driver Separate
+
+Zmultiply_defined
+Driver Separate
+
+Zmultiplydefinedunused
+Driver Separate
+
+Zseg_addr_table
+Driver Separate
+
+Zsegs_read_only_addr
+Driver Separate
+
+Zsegs_read_write_addr
+Driver Separate
+
+Zumbrella
+Driver Separate
+
+Zunexported_symbols_list
+Driver Separate
+
+Zweak_reference_mismatches
+Driver Separate
+
+client_name
+Driver Separate
+
+compatibility_version
+Driver Separate
+
+current_version
+Driver Separate
+
+dylinker_install_name
+Driver Separate
+
+pagezero_size
+Driver Separate
+
+read_only_relocs
+Driver Separate
+
+seg1addr
+Driver Separate
+
+segs_read_only_addr
+Driver Separate
+
+segs_read_write_addr
+Driver Separate
+
+sub_library
+Driver Separate
+
+sub_umbrella
+Driver Separate
+
 undefined
 Driver Separate
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/freebsd-spec.h gcc-mainline/gcc/config/freebsd-spec.h
--- gcc-mainline-0/gcc/config/freebsd-spec.h	2010-10-24 09:39:23.000000000 -0700
+++ gcc-mainline/gcc/config/freebsd-spec.h	2010-10-27 10:00:24.000000000 -0700
@@ -34,14 +34,6 @@  see the files COPYING3 and COPYING.RUNTI
 /* In case we need to know.  */
 #define USING_CONFIG_FREEBSD_SPEC 1
 
-/* This defines which multi-letter switches take arguments.  */
-
-#define FBSD_WORD_SWITCH_TAKES_ARG(STR)					\
-  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
-   || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")		\
-   || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") 		\
-   || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
-
 #define FBSD_TARGET_OS_CPP_BUILTINS()					\
   do									\
     {									\
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/freebsd.h gcc-mainline/gcc/config/freebsd.h
--- gcc-mainline-0/gcc/config/freebsd.h	2010-10-24 09:40:04.000000000 -0700
+++ gcc-mainline/gcc/config/freebsd.h	2010-10-27 10:00:35.000000000 -0700
@@ -30,12 +30,6 @@  along with GCC; see the file COPYING3.  
 /* In case we need to know.  */
 #define USING_CONFIG_FREEBSD 1
 
-/* This defines which switch words take arguments.
-   We have --assert etc.  */
-
-#undef  WORD_SWITCH_TAKES_ARG
-#define WORD_SWITCH_TAKES_ARG(STR) (FBSD_WORD_SWITCH_TAKES_ARG(STR))
-
 #undef  TARGET_OS_CPP_BUILTINS
 #define TARGET_OS_CPP_BUILTINS() FBSD_TARGET_OS_CPP_BUILTINS()
 
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/freebsd.opt gcc-mainline/gcc/config/freebsd.opt
--- gcc-mainline-0/gcc/config/freebsd.opt	1969-12-31 16:00:00.000000000 -0800
+++ gcc-mainline/gcc/config/freebsd.opt	2010-10-27 10:11:59.000000000 -0700
@@ -0,0 +1,38 @@ 
+; FreeBSD options.
+
+; Copyright (C) 2010
+; Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+; See the GCC internals manual (options.texi) for a description of this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+assert
+Driver Separate
+
+defsym
+Driver Separate
+
+rpath-link
+Driver Separate
+
+soname
+Driver Separate
+
+; This comment is to ensure we retain the blank line above.
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/interix.h gcc-mainline/gcc/config/interix.h
--- gcc-mainline-0/gcc/config/interix.h	2010-10-24 11:06:04.000000000 -0700
+++ gcc-mainline/gcc/config/interix.h	2010-10-27 10:12:28.000000000 -0700
@@ -58,11 +58,6 @@  for windows/multi thread */
 #define STARTFILE_SPEC  \
   "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}} %{shared:crti%O%s}"
 
-#undef WORD_SWITCH_TAKES_ARG
-#define WORD_SWITCH_TAKES_ARG(STR)		\
- (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)		\
-  || !strcmp(STR, "rpath"))
-
 
 #define STDC_0_IN_SYSTEM_HEADERS 1
 
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/mips/iris6.h gcc-mainline/gcc/config/mips/iris6.h
--- gcc-mainline-0/gcc/config/mips/iris6.h	2010-05-08 08:55:15.000000000 -0700
+++ gcc-mainline/gcc/config/mips/iris6.h	2010-10-27 10:06:05.000000000 -0700
@@ -146,10 +146,6 @@  along with GCC; see the file COPYING3.  
 #undef DEFAULT_SIGNED_CHAR
 #define DEFAULT_SIGNED_CHAR 0
 
-#define WORD_SWITCH_TAKES_ARG(STR)			\
-  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)			\
-   || strcmp (STR, "rpath") == 0)
-
 #define TARGET_OS_CPP_BUILTINS()				\
   do								\
     {								\
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config/rpath.opt gcc-mainline/gcc/config/rpath.opt
--- gcc-mainline-0/gcc/config/rpath.opt	1969-12-31 16:00:00.000000000 -0800
+++ gcc-mainline/gcc/config/rpath.opt	2010-10-27 10:11:13.000000000 -0700
@@ -0,0 +1,29 @@ 
+; -rpath option to the driver.
+
+; Copyright (C) 2010
+; Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+; See the GCC internals manual (options.texi) for a description of this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+rpath
+Driver Separate
+
+; This comment is to ensure we retain the blank line above.
diff -rupN --exclude=.svn gcc-mainline-0/gcc/config.gcc gcc-mainline/gcc/config.gcc
--- gcc-mainline-0/gcc/config.gcc	2010-10-15 05:43:58.000000000 -0700
+++ gcc-mainline/gcc/config.gcc	2010-10-27 10:12:17.000000000 -0700
@@ -528,6 +528,7 @@  case ${target} in
       ;;
   esac
   fbsd_tm_file="${fbsd_tm_file} freebsd-spec.h freebsd.h freebsd-stdint.h"
+  extra_options="$extra_options rpath.opt freebsd.opt"
   case ${target} in
     *-*-freebsd[345].*)
       :;;
@@ -727,6 +728,7 @@  alpha*-dec-osf5.1*)
 	tmake_file="alpha/t-alpha alpha/t-ieee alpha/t-crtfm alpha/t-osf5"
 	tm_file="${tm_file} alpha/osf5.h"
 	tm_defines="${tm_defines} TARGET_SUPPORT_ARCH=1"
+	extra_options="${extra_options} rpath.opt"
 	extra_headers=va_list.h
 	use_gcc_stdint=provide
 	case ${enable_threads} in
@@ -1518,6 +1520,7 @@  i[34567]86-*-mingw* | x86_64-*-mingw*)
 i[34567]86-*-interix3*)
 	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/i386-interix.h i386/i386-interix3.h interix.h interix3.h"
 	tmake_file="${tmake_file} i386/t-interix"
+	extra_options="${extra_options} rpath.opt"
 	extra_objs=winnt.o
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
 	if test x$enable_threads = xyes ; then
@@ -1784,6 +1787,7 @@  microblaze*-*-*)
 mips-sgi-irix6.5*)
 	tm_file="elfos.h ${tm_file} mips/iris6.h"
 	tmake_file="mips/t-iris mips/t-iris6 mips/t-slibgcc-irix"
+	extra_options="${extra_options} rpath.opt"
 	target_cpu_default="MASK_ABICALLS"
 	tm_defines="${tm_defines} MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_N32"
 	# Only IRIX Development Foundation 1.3 for IRIX 6.5 provides stdint.h.