This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PR 11728--Unlinking before closing a file
- From: Sterling Augustine <sterling at tensilica dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 21 Jun 2010 10:28:52 -0700
- Subject: PR 11728--Unlinking before closing a file
Today, when you have an error in your input, gas unlinks a file before
it is closed, which fails on windows-file systems. (And probably other
non-unixy file systems.) This is filed as bugzilla 11728
The erroneous output file won't be deleted, confusing make and certain
developers like me.
Enclosed is a patch that moves unlinking to after closing. It simply
keeps unlinking in close proximity to closing.
OK to apply?
Sterling
2010-06-21 Sterling Augustine <sterling@jaw.hq.tensilica.com>
PR gas/11728
* as.c: Globalize keep_it.
(main): Remove keep_it. Move conditional from here...
(close_output_file): ...to here.
Index: as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.88
diff -u -p -d -u -r1.88 as.c
--- as.c 9 Apr 2010 14:40:18 -0000 1.88
+++ as.c 18 Jun 2010 23:38:58 -0000
@@ -98,6 +98,9 @@ int debug_memory = 0;
/* Enable verbose mode. */
int verbose = 0;
+/* Keep the output file. */
+int keep_it = 0;
+
segT reg_section;
segT expr_section;
segT text_section;
@@ -953,6 +956,8 @@ static void
close_output_file (void)
{
output_file_close (out_file_name);
+ if (!keep_it)
+ unlink_if_ordinary (out_file_name);
}
/* The interface between the macro code and gas expression handling. */
@@ -1082,7 +1087,6 @@ main (int argc, char ** argv)
char ** argv_orig = argv;
int macro_strip_at;
- int keep_it;
start_time = get_run_time ();
@@ -1245,9 +1249,6 @@ main (int argc, char ** argv)
if (had_errors () > 0 && ! flag_always_generate_output)
keep_it = 0;
- if (!keep_it)
- unlink_if_ordinary (out_file_name);
-
input_scrub_end ();
END_PROGRESS (myname);