diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/Makefile.in | 11 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 64 | ||||
-rw-r--r-- | gcc/gcc.c | 70 |
4 files changed, 88 insertions, 66 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 670c818..a6299b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2002-06-09 Geoffrey Keating <geoffk@redhat.com> + + * Makefile.in (install-driver): Install driver as + $(target_alias)-gcc-$(version). + * gcc.c (spec_version): Make const. + (process_command): Handle -V and -b by using exec. + * doc/invoke.texi (Target Options): Restore -V option, + update docs for -b option. + 2002-06-10 Tim Josling <tej@melbpc.org.au> First steps to making treelang documentation compliant, based on diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 24b016f..5da6637 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2732,12 +2732,14 @@ install-common: native $(EXTRA_PARTS) lang.install-common fi $(INSTALL_SCRIPT) gccbug $(bindir)/$(GCCBUG_INSTALL_NAME) -# Install the driver program as $(target_alias)-gcc +# Install the driver program as $(target_alias)-gcc, +# $(target-alias)-gcc-$(version) # and also as either gcc (if native) or $(gcc_tooldir)/bin/gcc. install-driver: installdirs xgcc$(exeext) -if [ -f gcc-cross$(exeext) ] ; then \ rm -f $(bindir)/$(GCC_CROSS_NAME)$(exeext); \ $(INSTALL_PROGRAM) gcc-cross$(exeext) $(bindir)/$(GCC_CROSS_NAME)$(exeext); \ + $(LN) $(bindir)/$(GCC_CROSS_NAME)$(exeext) $(bindir)/$(target_alias)-gcc-$(version) ; \ if [ -d $(gcc_tooldir)/bin/. ] ; then \ rm -f $(gcc_tooldir)/bin/gcc$(exeext); \ $(INSTALL_PROGRAM) gcc-cross$(exeext) $(gcc_tooldir)/bin/gcc$(exeext); \ @@ -2745,9 +2747,10 @@ install-driver: installdirs xgcc$(exeext) else \ rm -f $(bindir)/$(GCC_INSTALL_NAME)$(exeext); \ $(INSTALL_PROGRAM) xgcc$(exeext) $(bindir)/$(GCC_INSTALL_NAME)$(exeext); \ - rm -f $(bindir)/$(target_alias)-gcc-1$(exeext); \ - $(LN) $(bindir)/$(GCC_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-gcc-1$(exeext); \ - mv $(bindir)/$(target_alias)-gcc-1$(exeext) $(bindir)/$(GCC_TARGET_INSTALL_NAME)$(exeext); \ + $(LN) $(bindir)/$(GCC_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-gcc-$(version) ; \ + rm -f $(bindir)/$(target_alias)-gcc-tmp$(exeext); \ + $(LN) $(bindir)/$(GCC_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-gcc-tmp$(exeext); \ + mv $(bindir)/$(target_alias)-gcc-tmp$(exeext) $(bindir)/$(GCC_TARGET_INSTALL_NAME)$(exeext); \ fi # Install the info files. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 38e03b1..8549bfb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -323,7 +323,7 @@ in the following sections. @c I wrote this xref this way to avoid overfull hbox. -- rms @xref{Target Options}. @gccoptlist{ --b @var{machine}} +-V @var{version} -b @var{machine}} @item Machine Dependent Options @xref{Submodel Options,,Hardware Models and Configurations}. @@ -4812,22 +4812,16 @@ proper position among the other output files. @cindex compiler version, specifying @cindex target machine, specifying -By default, GCC compiles code for the same type of machine that you -are using. However, it can also be installed as a cross-compiler, to -compile for some other type of machine. In fact, several different -configurations of GCC, for different target machines, can be -installed side by side. Then you specify which one to use with the -@option{-b} option. - -In addition, older and newer versions of GCC can be installed side -by side. One of them (probably the newest) will be the default, but -you may sometimes wish to use another. +The usual way to run GCC is to run the executable called @file{gcc}, or +@file{<machine>-gcc} when cross-compiling, or +@file{<machine>-gcc-<version>} to run a version other than the one that +was installed last. Sometimes this is inconvenient, so GCC provides +options that will switch to another cross-compiler or version. @table @gcctabopt @item -b @var{machine} @opindex b The argument @var{machine} specifies the target machine for compilation. -This is useful when you have installed GCC as a cross-compiler. The value to use for @var{machine} is the same as was specified as the machine type when configuring GCC as a cross-compiler. For @@ -4835,46 +4829,16 @@ example, if a cross-compiler was configured with @samp{configure i386v}, meaning to compile for an 80386 running System V, then you would specify @option{-b i386v} to run that cross compiler. -When you do not specify @option{-b}, it normally means to compile for -the same type of machine that you are using. +@item -V @var{version} +@opindex V +The argument @var{version} specifies which version of GCC to run. +This is useful when multiple versions are installed. For example, +@var{version} might be @samp{2.0}, meaning to run GCC version 2.0. @end table -The @option{-b} option actually works by controlling part of -the file name used for the executable files and libraries used for -compilation. A given version of GCC, for a given target machine, is -normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}. - -Thus, sites can customize the effect of @option{-b} either by -changing the names of these directories or adding alternate names (or -symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the -file @file{80386} is a link to the file @file{i386v}, then @option{-b -80386} becomes an alias for @option{-b i386v}. - -In one respect, @option{-b} does not completely change -to a different compiler: the top-level driver program @command{gcc} -that you originally invoked continues to run and invoke the other -executables (preprocessor, compiler per se, assembler and linker) -that do the real work. However, since no real work is done in the -driver program, it usually does not matter that the driver program -in use is not the one for the specified target. - -The only way that the driver program depends on the target machine is -in the parsing and handling of special machine-specific options. -However, this is controlled by a file which is found, along with the -other executables, in the directory for the specified version and -target machine. As a result, a single installed driver program adapts -to any specified target machine, and sufficiently similar compiler -versions. - -The driver program executable does control one significant thing, -however: the default version and target machine. Therefore, you can -install different instances of the driver program, compiled for -different targets or versions, under different names. - -For example, if the driver for version 2.0 is installed as @command{ogcc} -and that for version 2.1 is installed as @command{gcc}, then the command -@command{gcc} will use version 2.1 by default, while @command{ogcc} will use -2.0 by default. +The @option{-V} and @option{-b} options work by running the +@file{<machine>-gcc-<version>} executable, so there's no real reason to +use them if you can just run that directly. @node Submodel Options @section Hardware Models and Configurations @@ -213,7 +213,7 @@ static const char *compiler_version; /* The target version specified with -V */ -static const char *spec_version = DEFAULT_TARGET_VERSION; +static const char *const spec_version = DEFAULT_TARGET_VERSION; /* The target machine specified with -b. */ @@ -3185,6 +3185,60 @@ process_command (argc, argv) } } + /* If there is a -V or -b option (or both), process it now, before + trying to interpret the rest of the command line. */ + if (argc > 1 && argv[1][0] == '-' + && (argv[1][1] == 'V' || argv[1][1] == 'b')) + { + const char *new_version = DEFAULT_TARGET_VERSION; + const char *new_machine = DEFAULT_TARGET_MACHINE; + const char *const *new_argv = argv; + char *new_argv0; + int baselen; + + while (argc > 1 && new_argv[1][0] == '-' + && (new_argv[1][1] == 'V' || new_argv[1][1] == 'b')) + { + char opt = new_argv[1][1]; + const char *arg; + if (new_argv[1][2] != '\0') + { + arg = new_argv[1] + 2; + argc -= 1; + new_argv += 1; + } + else if (argc > 2) + { + arg = new_argv[2]; + argc -= 2; + new_argv += 2; + } + else + fatal ("`-%c' option must have argument", opt); + if (opt == 'V') + new_version = arg; + else + new_machine = arg; + } + + for (baselen = strlen (argv[0]); baselen > 0; baselen--) + if (IS_DIR_SEPARATOR (argv[0][baselen-1])) + break; + new_argv0 = xmemdup (argv[0], baselen, + baselen + concat_length (new_version, new_machine, + "-gcc-", NULL) + 1); + strcpy (new_argv0 + baselen, new_machine); + strcat (new_argv0, "-gcc-"); + strcat (new_argv0, new_version); + + new_argv = xmemdup (new_argv, (argc+1) * sizeof (new_argv0[0]), + (argc+1) * sizeof (new_argv0[0])); + new_argv[0] = new_argv0; + + execvp (new_argv0, new_argv); + fatal ("couldn't run `%s': %s", new_argv0, xstrerror(errno)); + } + /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, see if we can create it from the pathname specified in argv[0]. */ @@ -3332,7 +3386,6 @@ process_command (argc, argv) /* Scan argv twice. Here, the first time, just count how many switches there will be in their vector, and how many input files in theirs. - Also parse any switches that determine the configuration name, such as -b. Here we also parse the switches that cc itself uses (e.g. -v). */ for (i = 1; i < argc; i++) @@ -3531,15 +3584,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" switch (c) { case 'b': - n_switches++; - if (p[1] == 0 && i + 1 == argc) - fatal ("argument to `-b' is missing"); - if (p[1] == 0) - spec_machine = argv[++i]; - else - spec_machine = p + 1; - - warn_std_ptr = &warn_std; + case 'V': + fatal ("`-%c' must come at the start of the command line", c); break; case 'B': @@ -3972,7 +4018,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" else { char ch = switches[n_switches].part1[0]; - if (ch == 'b' || ch == 'B') + if (ch == 'B') switches[n_switches].validated = 1; } n_switches++; |