This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Bulletproofing -fsyntax-only, round 2 (extra armour plate)
- To: law at cygnus dot com
- Subject: Re: [PATCH] Bulletproofing -fsyntax-only, round 2 (extra armour plate)
- From: Nix <nix at esperi dot demon dot co dot uk>
- Date: Sun, 20 Aug 2000 00:39:43 +0100 (BST)
- Cc: gcc-patches at gcc dot gnu dot org
- References: <14731.64187.329437.797918@loki.wkstn.nix><1708.965998331@upchuck>
[Sorry for the delay, illness and such :( ]
Jeffrey A Law writes:
> For stuff like temporary files we manage them entirely in gcc.c instead of
> cc1. If gcc.c aborts, then, well, we lose. That is arguably bad behavior.
>
> I'm not sure how to best manage the temporary file problem, except maybe
> to move its management into gcc.c like we do for other temporary files.
Agreed. Stupid of me. Fixed.
> Yes, we don't care about the case where
> MKTEMP_EACH_FILE is not defined. But my recollection is that your patch
> removed some code where MKTEMP_EACH_FILE was defined. Looking at it more
> closely now, I was mistaken (I read a #if[n]def backwards).
Ah, good :) I'll keep that, then.
> > > I think you need to make those changes and resubmit.
> >
> > I will strip out the specs changes, too, because Zack has done the same
> > thing already.
> OK.
Er, whoops, no he hasn't, he's made the code much simpler though.
> So the pending issues are the documentation and a better way to handle
> the temporary file without using atexit if at all possible -- possibly
> by managing the temporary file in gcc.c.
Done. This is against the 20000814 snapshot, but it won't apply cleanly
:( because Jakub's patch of
<20000818131204.W24872@devserv.devel.redhat.com> collides with it,
modifying exactly the same line ;) it should be easy enough to modify
(three letters ain't so hard) but I can supply a suitably fixed patch if
you like.
It adds a %j specs flag, which expands to /dev/null if HOST_BIT_BUCKET
is defined and writable, and creates a temporary file exactly as %u;
this is possibly not optimal, as %U should perhaps not substitute it in,
but I'm not sure how important this is (or if it is important at
all). If this is undesirable behaviour, I can change it.
I have changed the bits in the weird part of the Fortran specs file that
used /dev/null to use %j instead, so that wierdness (versioning?) will
work even on hosts that don't support /dev/null.
Where are %u and %U used, anyway? It doesn't seem to be used anywhere
that I can tell. (If this stuff is not critical for backward
compatibility, and I can't see how it is, maybe I should rationalize it
a bit...)
I'd like to provide a way for hosts to say that they do not support any
kind of bit bucket, but just `#undef'ing it in the hosts files can't
work, because system.h is included after config.h, so system.h would
just redefine it again. A pity; perhaps there is a nice way to say this,
but for now I suggest just #defining an illegal filename (the null
string, perhaps) for hosts that don't support a bit bucket. This is ugly
and kludged :( improvements welcome.
Tested on i586-pc-linux-gnu with writable and non-writable bit buckets;
no test regressions, and it works with -fsyntax-only too, emitting lots
of FAILs from the test suite because the output file doesn't exist
(maybe, for makefiles, we should arrange to create it if -o was
specified, but that is probably overkill. Anyone who uses -fsyntax-only
in makefiles should know what it does :) )
The changes to protoize.c are untested.
2000-08-19 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), ch/lang-specs.h, cp/lang-specs.h, f/lang-specs.h,
java/lang-specs.h, objc/lang-specs.h: Do not process -o or
run the assembler if -fsyntax-only.
* f/lang-specs.h: Use %j instead of /dev/null.
diff -uprN egcs/gcc/ch/lang-specs.h egcs-hacking/gcc/ch/lang-specs.h
--- egcs/gcc/ch/lang-specs.h Mon Jul 31 19:29:57 2000
+++ egcs-hacking/gcc/ch/lang-specs.h Sat Aug 19 00:49:40 2000
@@ -26,5 +26,6 @@ Boston, MA 02111-1307, USA. */
{"@chill",
"tradcpp0 -lang-chill %{!no-gcc:-D__GNUCHILL__=%v1} %(cpp_options)\
%{!M:%{!MM:%{!E:%{!pipe:%g.i} |\n\
- cc1chill %{!pipe:%g.i} %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}\n"},
+ cc1chill %{!pipe:%g.i} %(cc1_options)\
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"},
diff -uprN egcs/gcc/config/i386/xm-dos.h egcs-hacking/gcc/config/i386/xm-dos.h
--- egcs/gcc/config/i386/xm-dos.h Mon Apr 12 00:59:24 1999
+++ egcs-hacking/gcc/config/i386/xm-dos.h Sat Aug 19 00:13:14 2000
@@ -33,6 +33,8 @@ Boston, MA 02111-1307, USA. */
/* Suffix for executable file names. */
#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
diff -uprN egcs/gcc/config/i386/xm-os2.h egcs-hacking/gcc/config/i386/xm-os2.h
--- egcs/gcc/config/i386/xm-os2.h Thu May 25 20:07:33 2000
+++ egcs-hacking/gcc/config/i386/xm-os2.h Sat Aug 19 00:13:14 2000
@@ -67,8 +67,8 @@ int spawnvp (int modeflag, char *path, c
#define OBJECT_SUFFIX ".obj"
#endif
-/* This is required to make temporary file names unique on file
- systems which severely restrict the length of file names. */
-#define MKTEMP_EACH_FILE
+/* Tell GCC about OS/2's bit bucket. */
+
+#define HOST_BIT_BUCKET "NUL"
#include "i386/xm-i386.h"
diff -uprN egcs/gcc/config/winnt/xm-winnt.h egcs-hacking/gcc/config/winnt/xm-winnt.h
--- egcs/gcc/config/winnt/xm-winnt.h Mon Feb 7 19:46:20 2000
+++ egcs-hacking/gcc/config/winnt/xm-winnt.h Sat Aug 19 00:13:14 2000
@@ -53,6 +53,10 @@ Boston, MA 02111-1307, USA. */
/* Allows checks for drive names. */
#define HAVE_DOS_BASED_FILE_SYSTEM
+/* Tell GCC about NT's bit bucket. */
+
+#define HOST_BIT_BUCKET "NUL"
+
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
diff -uprN egcs/gcc/cp/lang-specs.h egcs-hacking/gcc/cp/lang-specs.h
--- egcs/gcc/cp/lang-specs.h Mon Jul 31 22:00:36 2000
+++ egcs-hacking/gcc/cp/lang-specs.h Thu Aug 17 18:15:29 2000
@@ -37,19 +37,21 @@ Boston, MA 02111-1307, USA. */
%{fnew-abi:-D__GXX_ABI_VERSION=100}\
%{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
%(cpp_options) %(cc1_options) %{+e*}\
- %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}"
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"
#else /* ! USE_CPPLIB */
"cpp0 -lang-c++ %{!no-gcc:-D__GNUG__=%v1}\
%{fnew-abi:-D__GXX_ABI_VERSION=100}\
%{ansi:-trigraphs -$ -D__STRICT_ANSI__} %(cpp_options)\
%{!M:%{!MM:%{!E:%{!pipe:%g.ii} |\n\
- cc1plus %{!pipe:%g.ii} %(cc1_options) %{+e*} %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}\n"
+ cc1plus %{!pipe:%g.ii} %(cc1_options) %{+e*}\
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"
#endif /* ! USE_CPPLIB */
},
{".ii", "@c++-cpp-output"},
{"@c++-cpp-output",
"%{!M:%{!MM:%{!E:\
cc1plus -fpreprocessed %i %(cc1_options) %{+e*}\
- %{!S:-o %{|!pipe:%g.s} |\n as %(asm_options) %{!pipe:%g.s} %A }}}}"},
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"},
diff -uprN egcs/gcc/f/lang-specs.h egcs-hacking/gcc/f/lang-specs.h
--- egcs/gcc/f/lang-specs.h Mon Jul 31 19:29:58 2000
+++ egcs-hacking/gcc/f/lang-specs.h Thu Aug 17 18:20:16 2000
@@ -29,27 +29,27 @@ the Free Software Foundation, 59 Temple
{".FPP", "@f77-cpp-input"},
{"@f77-cpp-input",
"tradcpp0 -lang-fortran %(cpp_options) %{!M:%{!MM:%{!E:%{!pipe:%g.f |\n\
- f771 %{!pipe:%g.f} %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"},
+ f771 %{!pipe:%g.f} %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}}\n"},
{".r", "@ratfor"},
{"@ratfor",
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
ratfor %{C} %{v} %i %{E:%W{o*}} %{!E: %{!pipe:-o %g.f} |\n\
- f771 %{!pipe:%g.f} %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}\n"},
+ f771 %{!pipe:%g.f} %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}\n"},
{".f", "@f77"},
{".for", "@f77"},
{".FOR", "@f77"},
{"@f77",
- "%{!M:%{!MM:%{!E:f771 %i %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}\n"},
+ "%{!M:%{!MM:%{!E:f771 %i %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"},
/* XXX This is perverse and should not be necessary. */
{"@f77-version",
- "tradcpp0 -lang-fortran %(cpp_options) /dev/null \n\
+ "tradcpp0 -lang-fortran %(cpp_options) %j \n\
f771 -fnull-version %1 \
%{!Q:-quiet} -dumpbase g77-version.f %{d*} %{m*} %{a*} \
%{g*} %{O*} %{W*} %{w} %{pedantic*} \
- -version -fversion %{f*} %{I*} -o %g.s /dev/null \n\
+ -version -fversion %{f*} %{I*} -o %g.s %j \n\
as %a %Y -o %g%O %g.s %A \n\
ld %l %X -o %g %g%O %{A} %{d} %{e*} %{m} %{N} %{n} \
%{r} %{s} %{t} %{u*} %{x} %{z} %{Z} \
diff -uprN egcs/gcc/gcc.c egcs-hacking/gcc/gcc.c
--- egcs/gcc/gcc.c Sat Aug 12 11:28:52 2000
+++ egcs-hacking/gcc/gcc.c Sat Aug 19 22:20:33 2000
@@ -292,6 +292,12 @@ or with constant text in a single argume
for each `%g.s' and another for each `%U.s'. Previously, %U was
simply substituted with a file name chosen for the previous %u,
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
temporary file name, so that that file will be deleted if CC exits
successfully. Unlike %g, this contributes no text to the argument.
@@ -571,7 +577,8 @@ static const char *cc1_options =
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi}\
%{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
%{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 =
"%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
#if USE_CPPLIB
"%{E|M|MM:cpp0 -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\
- as %(asm_options) %{!pipe:%g.s} %A }}}}"
+ %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"
#else /* ! USE_CPPLIB */
"%(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options) \
%{!M:%{!MM:%{!E:%{!pipe:%g.i} |\n\
- cc1 %{!pipe:%g.i} %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}\n"
+ cc1 %{!pipe:%g.i} %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"
#endif /* ! USE_CPPLIB */
},
{"-",
@@ -709,8 +716,8 @@ static struct compiler default_compilers
{".i", "@cpp-output"},
{"@cpp-output",
"%{!M:%{!MM:%{!E:\
- cc1 %i %(cc1_options) %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}"},
+ cc1 %i %(cc1_options) %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"},
{".s", "@assembler"},
{"@assembler",
"%{!M:%{!MM:%{!E:%{!S:as %(asm_options) %i %A }}}}"},
@@ -1226,13 +1233,9 @@ static int argbuf_length;
static int argbuf_index;
-/* We want this on by default all the time now. */
-#define MKTEMP_EACH_FILE
-
-#ifdef MKTEMP_EACH_FILE
-
-/* This is the list of suffixes and codes (%g/%u/%U) and the associated
- temp file. */
+/* This is the list of suffixes and codes (%g/%u/%U/%j) and the associated
+ temp file. If the HOST_BIT_BUCKET is used for %j, no entry is made for
+ it here. */
static struct temp_name {
const char *suffix; /* suffix associated with the code. */
@@ -1242,8 +1245,6 @@ static struct temp_name {
int filename_length; /* strlen (filename). */
struct temp_name *next;
} *temp_names;
-#endif
-
/* Number of commands executed so far. */
@@ -1681,7 +1682,7 @@ read_specs (filename, main_p)
/* This is the common prefix we use to make temp file names.
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.
In practice, all temp file names start with this prefix.
@@ -3973,6 +3974,26 @@ do_spec_1 (spec, inswitch, soft_matched_
}
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 'u':
case 'U':
@@ -3983,11 +4004,6 @@ do_spec_1 (spec, inswitch, soft_matched_
}
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;
int suffix_length;
const char *suffix = p;
@@ -4024,8 +4040,8 @@ do_spec_1 (spec, inswitch, soft_matched_
&& t->unique == (c != 'g'))
break;
- /* Make a new association if needed. %u requires one. */
- if (t == 0 || c == 'u')
+ /* Make a new association if needed. %u and %j require one. */
+ if (t == 0 || c == 'u' || c == 'j')
{
if (t == 0)
{
@@ -4047,19 +4063,6 @@ do_spec_1 (spec, inswitch, soft_matched_
obstack_grow (&obstack, t->filename, t->filename_length);
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;
break;
@@ -5196,13 +5199,6 @@ main (argc, argv)
putenv (INIT_ENVIRONMENT);
#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 specified input files (infiles, n_infiles).
Decode switches that are handled locally. */
diff -uprN egcs/gcc/gcc.texi egcs-hacking/gcc/gcc.texi
--- egcs/gcc/gcc.texi Sat Aug 19 22:39:19 2000
+++ egcs-hacking/gcc/gcc.texi Sat Aug 19 22:47:15 2000
@@ -3928,6 +3928,15 @@ Define this macro to be a C string repre
files on your machine. If you do not define this macro, GCC will use
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
@item COLLECT_EXPORT_LIST
If defined, @code{collect2} will scan the individual object files
diff -uprN egcs/gcc/java/lang-specs.h egcs-hacking/gcc/java/lang-specs.h
--- egcs/gcc/java/lang-specs.h Wed Jul 19 13:59:13 2000
+++ egcs-hacking/gcc/java/lang-specs.h Thu Aug 17 18:21:28 2000
@@ -32,5 +32,5 @@ The Free Software Foundation is independ
{"@java",
"%{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}}\
%{!E:jc1 %i %(jc1) %(cc1_options) %{+e*} %{I*} %{MD} %{MMD} %{M} %{MM}\
- %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}"},
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}"},
diff -uprN egcs/gcc/objc/lang-specs.h egcs-hacking/gcc/objc/lang-specs.h
--- egcs/gcc/objc/lang-specs.h Mon Jul 31 19:29:58 2000
+++ egcs-hacking/gcc/objc/lang-specs.h Thu Aug 17 18:22:58 2000
@@ -25,19 +25,19 @@ Boston, MA 02111-1307, USA. */
{"@objective-c",
#if USE_CPPLIB
"%{E|M|MM:cpp0 -lang-objc %{ansi:-std=c89} %(cpp_options)}\
- %{!E:%{!M:%{!MM:cc1obj -lang-objc %(cpp_options) %(cc1_options)\
- %{gen-decls} %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}"
+ %{!E:%{!M:%{!MM:cc1obj -lang-objc %(cpp_options) %(cc1_options) %{gen-decls}\
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"
#else /* ! USE_CPPLIB */
"%(trad_capable_cpp) -lang-objc %{ansi:-std=c89} %(cpp_options)\
%{!M:%{!MM:%{!E:%{!pipe:%g.mi} |\n\
cc1obj -lang-objc %{!pipe:%g.mi} %(cc1_options) %{gen-decls}\
- %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}\n"
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}\n"
#endif /* ! USE_CPPLIB */
},
{".mi", "@objc-cpp-output"},
{"@objc-cpp-output",
"%{!M:%{!MM:%{!E:cc1obj -lang-objc %i %(cc1_options) %{gen-decls}\
- %{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_options) %{!pipe:%g.s} %A }}}}"},
+ %{!fsyntax-only:%{!S:-o %{|!pipe:%g.s} |\n\
+ as %(asm_options) %{!pipe:%g.s} %A }}}}}"},
diff -uprN egcs/gcc/protoize.c egcs-hacking/gcc/protoize.c
--- egcs/gcc/protoize.c Thu May 25 20:04:02 2000
+++ egcs-hacking/gcc/protoize.c Sat Aug 19 23:05:20 2000
@@ -1952,6 +1952,7 @@ munge_compile_params (params_list)
= (const char **) alloca ((strlen (params_list) + 8) * sizeof (char *));
int param_count = 0;
const char *param;
+ struct stat st;
temp_params[param_count++] = compiler_file_name;
for (;;)
@@ -1998,11 +1999,15 @@ munge_compile_params (params_list)
temp_params[param_count++] = "-S";
temp_params[param_count++] = "-o";
-#if defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN)
- temp_params[param_count++] = "NUL";
-#else
- temp_params[param_count++] = "/dev/null";
-#endif
+
+ if ((stat (HOST_BIT_BUCKET, &st) == 0) && (!S_ISDIR (st.st_mode))
+ (access (HOST_BIT_BUCKET, W_OK) == 0))
+ temp_params[param_count++] = HOST_BIT_BUCKET;
+ 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. */
input_file_name_index = param_count;
diff -uprN egcs/gcc/system.h egcs-hacking/gcc/system.h
--- egcs/gcc/system.h Sat Jul 29 20:04:23 2000
+++ egcs-hacking/gcc/system.h Sat Aug 19 22:20:16 2000
@@ -585,6 +585,13 @@ extern void abort PARAMS ((void));
#define ONLY_INT_FIELDS 0
#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
otherwise or if they are signed. */
diff -uprN egcs/gcc/toplev.c egcs-hacking/gcc/toplev.c
--- egcs/gcc/toplev.c Thu Aug 17 19:45:56 2000
+++ egcs-hacking/gcc/toplev.c Sat Aug 19 00:13:14 2000
@@ -2128,38 +2128,35 @@ compile_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)
- asm_out_file = NULL;
+ if (! name_specified && asm_file_name == 0)
+ asm_out_file = stdout;
else
{
- if (! name_specified && asm_file_name == 0)
- asm_out_file = stdout;
+ if (asm_file_name == 0)
+ {
+ 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
- {
- if (asm_file_name == 0)
- {
- 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);
- }
+ asm_out_file = fopen (asm_file_name, "w");
+ if (asm_out_file == 0)
+ pfatal_with_name (asm_file_name);
+ }
#ifdef IO_BUFFER_SIZE
- setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
- _IOFBF, IO_BUFFER_SIZE);
+ setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
+ _IOFBF, IO_BUFFER_SIZE);
#endif
- }
if (ggc_p && name != 0)
name = ggc_alloc_string (name, strlen (name));
@@ -2428,8 +2425,7 @@ compile_file (name)
finish_parse ();
- if (! flag_syntax_only
- && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
+ if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
fatal_io_error (asm_file_name);
/* Do whatever is necessary to finish printing the graphs. */
--
`OS's and GUI's come and go, only Emacs has lasting power.' --- Per Abrahamsen