chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] always use temporary filenames in csc


From: .alyn.post.
Subject: Re: [Chicken-hackers] [PATCH] always use temporary filenames in csc
Date: Fri, 9 Nov 2012 14:24:19 -0700

On Fri, Nov 09, 2012 at 09:08:14PM +0100, Peter Bex wrote:
> On Fri, Nov 09, 2012 at 09:02:09PM +0100, Peter Bex wrote:
> > Personally, I think there's no shame in expecting the user to know that
> > Chicken will overwrite the .c file in the current working directory
> > with the same basename as the .scm file.  "cc" will also clobber a file
> > called "a.out"; if you happen to have one by that name, tough luck.
> 
> Having said that, a cleaner way to avoid clobbering user files would
> be like CVS: detect that the file exists, and if you think it isn't
> yours, bomb.
> 
> Chicken always writes a comment to the C file.  If the first line
> for the C file that you're about to generate which corresponds to
> foo.scm doesn't match "/* Generated from foo.scm by the CHICKEN compiler",
> csc could abort with a message stating that there's a
> non-Chicken-generated file in the way.  I think this would solve Alan's
> original problem neatly and require a minimal change in Chicken's
> behavior.
> 

That does indeed solve my problem.

I don't like and can't support being told "you should just know
that some invocations of csc will delete one of your input files"
but being told "certain invocations of csc will error and the fix
is to rename your input file" is perfectly acceptable.  You
suggestion above is perfectly fine with me.

I did test the following command:

  $ gcc -o foo -save-temps foo.c foo.s

And gcc does indeed delete foo.s.  I will claim this makes gcc
a right bastard, rather than making csc correct.

Another solution, similar to Peter's, is to check for set overlap
between all of the temporary files that will be generated and all
of the files on the command-line.  If there is overlap, error out
and report something like "I'm sure you have some kind of deep and
insightful human plan that I can't understand."

-Alan
-- 
.i ma'a lo bradi cu penmi gi'e du



reply via email to

[Prev in Thread] Current Thread [Next in Thread]