Commit 49009afd by Jeff Law

gcc.c (do_spec_1): Implement %j spec flag.

	* gcc.c (do_spec_1): Implement %j spec flag.
	Remove dead comment.

	* gcc.texi (The Configuration File): Document HOST_BIT_BUCKET.
        * system.h (HOST_BIT_BUCKET): Default to "/dev/null".
        * config/i386/xm-dos.h (HOST_BIT_BUCKET): Define as "NUL".
        * config/i386/xm-os2.h, config/winnt/winnt.h: Likewise.
      * protoize.c (munge_compile_params): Use HOST_BIT_BUCKET (if
	writable) instead of hardcoded value.

	* toplev.c (compile_file): Output to a file even if -fsyntax-only.

        * gcc.c, config/i386/xm-dos.h, config/i386/xm-os2.h: Kill
        MKTEMP_EACH_FILE.

         * gcc.c (cc1_options): Do not process -o or
        run the assembler if -fsyntax-only.

From-SVN: r35849
parent dc13bad7
2000-08-05 Eli Zaretskii <eliz@is.elta.co.il> 2000-08-21 Nix <nix@esperi.demon.co.uk>
* gcc.c (do_spec_1): Implement %j spec flag.
Remove dead comment.
* gcc.texi (The Configuration File): Document HOST_BIT_BUCKET.
* system.h (HOST_BIT_BUCKET): Default to "/dev/null".
* config/i386/xm-dos.h (HOST_BIT_BUCKET): Define as "NUL".
* config/i386/xm-os2.h, config/winnt/winnt.h: Likewise.
* protoize.c (munge_compile_params): Use HOST_BIT_BUCKET (if
writable) instead of hardcoded value.
* toplev.c (compile_file): Output to a file even if -fsyntax-only.
* gcc.c, config/i386/xm-dos.h, config/i386/xm-os2.h: Kill
MKTEMP_EACH_FILE.
* gcc.c (cc1_options): Do not process -o or run the assembler if
-fsyntax-only.
2000-08-21 Eli Zaretskii <eliz@is.elta.co.il>
* fixinc/fixincl.c (fix_with_system): Pipe the output of * fixinc/fixincl.c (fix_with_system): Pipe the output of
"external" fixes through `cat', to avoid truncating the input "external" fixes through `cat', to avoid truncating the input
......
...@@ -33,6 +33,8 @@ Boston, MA 02111-1307, USA. */ ...@@ -33,6 +33,8 @@ Boston, MA 02111-1307, USA. */
/* Suffix for executable file names. */ /* Suffix for executable file names. */
#define EXECUTABLE_SUFFIX ".exe" #define EXECUTABLE_SUFFIX ".exe"
#define MKTEMP_EACH_FILE 1 /* Tell GCC about DOS's bit bucket. */
#define HOST_BIT_BUCKET "NUL"
#define NO_PRECOMPILES 1 #define NO_PRECOMPILES 1
...@@ -67,8 +67,8 @@ int spawnvp (int modeflag, char *path, char *argv[]); ...@@ -67,8 +67,8 @@ int spawnvp (int modeflag, char *path, char *argv[]);
#define OBJECT_SUFFIX ".obj" #define OBJECT_SUFFIX ".obj"
#endif #endif
/* This is required to make temporary file names unique on file /* Tell GCC about OS/2's bit bucket. */
systems which severely restrict the length of file names. */
#define MKTEMP_EACH_FILE #define HOST_BIT_BUCKET "NUL"
#include "i386/xm-i386.h" #include "i386/xm-i386.h"
...@@ -292,6 +292,12 @@ or with constant text in a single argument. ...@@ -292,6 +292,12 @@ or with constant text in a single argument.
for each `%g.s' and another for each `%U.s'. Previously, %U was for each `%g.s' and another for each `%U.s'. Previously, %U was
simply substituted with a file name chosen for the previous %u, simply substituted with a file name chosen for the previous %u,
without regard to any appended suffix. without regard to any appended suffix.
%jSUFFIX
substitutes the name of the HOST_BIT_BUCKET, if any, and if it is
writable, and if save-temps is off; otherwise, substitute the name
of a temporary file, just like %u. This temporary file is not
meant for communication between processes, but rather as a junk
disposal mechanism.
%d marks the argument containing or following the %d as a %d marks the argument containing or following the %d as a
temporary file name, so that that file will be deleted if CC exits temporary file name, so that that file will be deleted if CC exits
successfully. Unlike %g, this contributes no text to the argument. successfully. Unlike %g, this contributes no text to the argument.
...@@ -571,7 +577,8 @@ static const char *cc1_options = ...@@ -571,7 +577,8 @@ static const char *cc1_options =
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi}\
%{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
%{aux-info*} %{Qn:-fno-ident} %{--help:--help}\ %{aux-info*} %{Qn:-fno-ident} %{--help:--help}\
%{S:%W{o*}%{!o*:-o %b.s}}"; %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
%{fsyntax-only:-o %j}";
static const char *asm_options = static const char *asm_options =
"%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
...@@ -690,13 +697,13 @@ static struct compiler default_compilers[] = ...@@ -690,13 +697,13 @@ static struct compiler default_compilers[] =
#if USE_CPPLIB #if USE_CPPLIB
"%{E|M|MM:cpp0 -lang-c %{ansi:-std=c89} %(cpp_options)}\ "%{E|M|MM:cpp0 -lang-c %{ansi:-std=c89} %(cpp_options)}\
%{!E:%{!M:%{!MM:cc1 -lang-c %{ansi:-std=c89} %(cpp_options)\ %{!E:%{!M:%{!MM:cc1 -lang-c %{ansi:-std=c89} %(cpp_options)\
%(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\ %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
as %(asm_options) %{!pipe:%g.s} %A }}}}" as %(asm_options) %{!pipe:%g.s} %A }}}}}"
#else /* ! USE_CPPLIB */ #else /* ! USE_CPPLIB */
"%(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options) \ "%(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options) \
%{!M:%{!MM:%{!E:%{!pipe:%g.i} |\n\ %{!M:%{!MM:%{!E:%{!pipe:%g.i} |\n\
cc1 %{!pipe:%g.i} %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\ cc1 %{!pipe:%g.i} %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
as %(asm_options) %{!pipe:%g.s} %A }}}}\n" as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"
#endif /* ! USE_CPPLIB */ #endif /* ! USE_CPPLIB */
}, },
{"-", {"-",
...@@ -709,8 +716,8 @@ static struct compiler default_compilers[] = ...@@ -709,8 +716,8 @@ static struct compiler default_compilers[] =
{".i", "@cpp-output"}, {".i", "@cpp-output"},
{"@cpp-output", {"@cpp-output",
"%{!M:%{!MM:%{!E:\ "%{!M:%{!MM:%{!E:\
cc1 %i %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\ cc1 %i %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
as %(asm_options) %{!pipe:%g.s} %A }}}}"}, as %(asm_options) %{!pipe:%g.s} %A }}}}}"},
{".s", "@assembler"}, {".s", "@assembler"},
{"@assembler", {"@assembler",
"%{!M:%{!MM:%{!E:%{!S:as %(asm_options) %i %A }}}}"}, "%{!M:%{!MM:%{!E:%{!S:as %(asm_options) %i %A }}}}"},
...@@ -1226,13 +1233,9 @@ static int argbuf_length; ...@@ -1226,13 +1233,9 @@ static int argbuf_length;
static int argbuf_index; static int argbuf_index;
/* We want this on by default all the time now. */ /* This is the list of suffixes and codes (%g/%u/%U/%j) and the associated
#define MKTEMP_EACH_FILE temp file. If the HOST_BIT_BUCKET is used for %j, no entry is made for
it here. */
#ifdef MKTEMP_EACH_FILE
/* This is the list of suffixes and codes (%g/%u/%U) and the associated
temp file. */
static struct temp_name { static struct temp_name {
const char *suffix; /* suffix associated with the code. */ const char *suffix; /* suffix associated with the code. */
...@@ -1242,8 +1245,6 @@ static struct temp_name { ...@@ -1242,8 +1245,6 @@ static struct temp_name {
int filename_length; /* strlen (filename). */ int filename_length; /* strlen (filename). */
struct temp_name *next; struct temp_name *next;
} *temp_names; } *temp_names;
#endif
/* Number of commands executed so far. */ /* Number of commands executed so far. */
...@@ -1681,7 +1682,7 @@ read_specs (filename, main_p) ...@@ -1681,7 +1682,7 @@ read_specs (filename, main_p)
/* This is the common prefix we use to make temp file names. /* This is the common prefix we use to make temp file names.
It is chosen once for each run of this program. It is chosen once for each run of this program.
It is substituted into a spec by %g. It is substituted into a spec by %g or %j.
Thus, all temp file names contain this prefix. Thus, all temp file names contain this prefix.
In practice, all temp file names start with this prefix. In practice, all temp file names start with this prefix.
...@@ -3973,6 +3974,26 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -3973,6 +3974,26 @@ do_spec_1 (spec, inswitch, soft_matched_part)
} }
break; break;
case 'j':
{
struct stat st;
/* If save_temps_flag is off, and the HOST_BIT_BUCKET is defined,
and it is not a directory, and it is writable, use it.
Otherwise, fall through and treat this like any other
temporary file. */
if ((!save_temps_flag)
&& (stat (HOST_BIT_BUCKET, &st) == 0) && (!S_ISDIR (st.st_mode))
&& (access (HOST_BIT_BUCKET, W_OK) == 0))
{
obstack_grow (&obstack, HOST_BIT_BUCKET,
strlen (HOST_BIT_BUCKET));
delete_this_arg = 0;
arg_going = 1;
break;
}
}
case 'g': case 'g':
case 'u': case 'u':
case 'U': case 'U':
...@@ -3983,11 +4004,6 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -3983,11 +4004,6 @@ do_spec_1 (spec, inswitch, soft_matched_part)
} }
else else
{ {
#ifdef MKTEMP_EACH_FILE
/* ??? This has a problem: the total number of
values mktemp can return is limited.
That matters for the names of object files.
In 2.4, do something about that. */
struct temp_name *t; struct temp_name *t;
int suffix_length; int suffix_length;
const char *suffix = p; const char *suffix = p;
...@@ -4024,8 +4040,8 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4024,8 +4040,8 @@ do_spec_1 (spec, inswitch, soft_matched_part)
&& t->unique == (c != 'g')) && t->unique == (c != 'g'))
break; break;
/* Make a new association if needed. %u requires one. */ /* Make a new association if needed. %u and %j require one. */
if (t == 0 || c == 'u') if (t == 0 || c == 'u' || c == 'j')
{ {
if (t == 0) if (t == 0)
{ {
...@@ -4047,19 +4063,6 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -4047,19 +4063,6 @@ do_spec_1 (spec, inswitch, soft_matched_part)
obstack_grow (&obstack, t->filename, t->filename_length); obstack_grow (&obstack, t->filename, t->filename_length);
delete_this_arg = 1; delete_this_arg = 1;
#else
obstack_grow (&obstack, temp_filename, temp_filename_length);
if (c == 'u' || c == 'U')
{
static int unique;
char buff[9];
if (c == 'u')
unique++;
sprintf (buff, "%d", unique);
obstack_grow (&obstack, buff, strlen (buff));
}
#endif
delete_this_arg = 1;
} }
arg_going = 1; arg_going = 1;
break; break;
...@@ -5196,13 +5199,6 @@ main (argc, argv) ...@@ -5196,13 +5199,6 @@ main (argc, argv)
putenv (INIT_ENVIRONMENT); putenv (INIT_ENVIRONMENT);
#endif #endif
/* Choose directory for temp files. */
#ifndef MKTEMP_EACH_FILE
temp_filename = choose_temp_base ();
temp_filename_length = strlen (temp_filename);
#endif
/* Make a table of what switches there are (switches, n_switches). /* Make a table of what switches there are (switches, n_switches).
Make a table of specified input files (infiles, n_infiles). Make a table of specified input files (infiles, n_infiles).
Decode switches that are handled locally. */ Decode switches that are handled locally. */
......
...@@ -3928,6 +3928,15 @@ Define this macro to be a C string representing the suffix for executable ...@@ -3928,6 +3928,15 @@ Define this macro to be a C string representing the suffix for executable
files on your machine. If you do not define this macro, GCC will use files on your machine. If you do not define this macro, GCC will use
the null string as the suffix for object files. the null string as the suffix for object files.
@findex HOST_BIT_BUCKET
@item HOST_BIT_BUCKET
The name of a file or file-like object on the host system which acts as
a ``bit bucket''. If you do not define this macro, GCC will use
@samp{/dev/null} as the bit bucket. If the target does not support a
bit bucket, this should be defined to the null string, or some other
illegal filename. If the bit bucket is not writable, GCC will use a
temporary file instead.
@findex COLLECT_EXPORT_LIST @findex COLLECT_EXPORT_LIST
@item COLLECT_EXPORT_LIST @item COLLECT_EXPORT_LIST
If defined, @code{collect2} will scan the individual object files If defined, @code{collect2} will scan the individual object files
......
...@@ -1952,6 +1952,7 @@ munge_compile_params (params_list) ...@@ -1952,6 +1952,7 @@ munge_compile_params (params_list)
= (const char **) alloca ((strlen (params_list) + 8) * sizeof (char *)); = (const char **) alloca ((strlen (params_list) + 8) * sizeof (char *));
int param_count = 0; int param_count = 0;
const char *param; const char *param;
struct stat st;
temp_params[param_count++] = compiler_file_name; temp_params[param_count++] = compiler_file_name;
for (;;) for (;;)
...@@ -1998,11 +1999,15 @@ munge_compile_params (params_list) ...@@ -1998,11 +1999,15 @@ munge_compile_params (params_list)
temp_params[param_count++] = "-S"; temp_params[param_count++] = "-S";
temp_params[param_count++] = "-o"; temp_params[param_count++] = "-o";
#if defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN)
temp_params[param_count++] = "NUL"; if ((stat (HOST_BIT_BUCKET, &st) == 0) && (!S_ISDIR (st.st_mode))
#else (access (HOST_BIT_BUCKET, W_OK) == 0))
temp_params[param_count++] = "/dev/null"; temp_params[param_count++] = HOST_BIT_BUCKET;
#endif else
/* FIXME: This is hardly likely to be right, if HOST_BIT_BUCKET is not
writable. But until this is rejigged to use make_temp_file(), this
is the best we can do. */
temp_params[param_count++] = "/dev/null";
/* Leave room for the input file name argument. */ /* Leave room for the input file name argument. */
input_file_name_index = param_count; input_file_name_index = param_count;
......
...@@ -589,6 +589,13 @@ extern void abort PARAMS ((void)); ...@@ -589,6 +589,13 @@ extern void abort PARAMS ((void));
#define ONLY_INT_FIELDS 0 #define ONLY_INT_FIELDS 0
#endif #endif
/* Provide a default for the HOST_BIT_BUCKET.
This suffices for POSIX-like hosts. */
#ifndef HOST_BIT_BUCKET
#define HOST_BIT_BUCKET "/dev/null"
#endif
/* Enumerated bitfields are safe to use unless we've been explictly told /* Enumerated bitfields are safe to use unless we've been explictly told
otherwise or if they are signed. */ otherwise or if they are signed. */
......
...@@ -2127,38 +2127,35 @@ compile_file (name) ...@@ -2127,38 +2127,35 @@ compile_file (name)
pfatal_with_name (aux_info_file_name); pfatal_with_name (aux_info_file_name);
} }
/* Open assembler code output file. */ /* Open assembler code output file. Do this even if -fsyntax-only is on,
because then the driver will have provided the name of a temporary
file or bit bucket for us. */
if (flag_syntax_only) if (! name_specified && asm_file_name == 0)
asm_out_file = NULL; asm_out_file = stdout;
else else
{ {
if (! name_specified && asm_file_name == 0) if (asm_file_name == 0)
asm_out_file = stdout; {
int len = strlen (dump_base_name);
char *dumpname = (char *) xmalloc (len + 6);
memcpy (dumpname, dump_base_name, len + 1);
strip_off_ending (dumpname, len);
strcat (dumpname, ".s");
asm_file_name = dumpname;
}
if (!strcmp (asm_file_name, "-"))
asm_out_file = stdout;
else else
{ asm_out_file = fopen (asm_file_name, "w");
if (asm_file_name == 0) if (asm_out_file == 0)
{ pfatal_with_name (asm_file_name);
int len = strlen (dump_base_name); }
char *dumpname = (char *) xmalloc (len + 6);
memcpy (dumpname, dump_base_name, len + 1);
strip_off_ending (dumpname, len);
strcat (dumpname, ".s");
asm_file_name = dumpname;
}
if (!strcmp (asm_file_name, "-"))
asm_out_file = stdout;
else
asm_out_file = fopen (asm_file_name, "w");
if (asm_out_file == 0)
pfatal_with_name (asm_file_name);
}
#ifdef IO_BUFFER_SIZE #ifdef IO_BUFFER_SIZE
setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
_IOFBF, IO_BUFFER_SIZE); _IOFBF, IO_BUFFER_SIZE);
#endif #endif
}
if (ggc_p && name != 0) if (ggc_p && name != 0)
name = ggc_alloc_string (name, strlen (name)); name = ggc_alloc_string (name, strlen (name));
...@@ -2427,8 +2424,7 @@ compile_file (name) ...@@ -2427,8 +2424,7 @@ compile_file (name)
finish_parse (); finish_parse ();
if (! flag_syntax_only if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
&& (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
fatal_io_error (asm_file_name); fatal_io_error (asm_file_name);
/* Do whatever is necessary to finish printing the graphs. */ /* Do whatever is necessary to finish printing the graphs. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment