backport: tlink.c (recompile_files): Do not assume that "rename" can overwrite an...
authorDanny Smith <dannysmith@users.sourceforge.net>
Wed, 30 Mar 2005 09:58:48 +0000 (09:58 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Wed, 30 Mar 2005 09:58:48 +0000 (09:58 +0000)
Merge from csl-arm-branch.
2004-02-12  Mark Mitchell  <mark@codesourcery.com>

* tlink.c (recompile_files): Do not assume that "rename" can
overwrite an existing file.

From-SVN: r97252

gcc/ChangeLog
gcc/tlink.c

index 915ec58c6939056dd91515dad61494ec13d8addb..00025a8002b1e11a8d32f664e4af17218a50f90c 100644 (file)
@@ -1,3 +1,11 @@
+2005-03-31  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       Merge from csl-arm-branch.
+       2004-02-12  Mark Mitchell  <mark@codesourcery.com>
+
+       * tlink.c (recompile_files): Do not assume that "rename" can
+       overwrite an existing file.
+
 2005-03-31  Paolo Bonzini  <bonzini@gnu.org>
 
        * gcc/configure.ac (TL_AC_GNU_MAKE_GCC_LIB_PATH): Remove.
index bf4e1d757b0f3dcfc9f9f30413a0a300a61e7e21..3fe531af9e7915b2dd8975f7c3df5d07a8705d7c 100644 (file)
@@ -470,7 +470,13 @@ recompile_files (void)
        }
       fclose (stream);
       fclose (output);
-      rename (outname, f->key);
+      /* On Windows "rename" returns -1 and sets ERRNO to EACCESS if
+        the new file name already exists.  Therefore, we explicitly
+        remove the old file first.  */
+      if (remove (f->key) == -1)
+       fatal_perror ("removing .rpo file");
+      if (rename (outname, f->key) == -1)
+       fatal_perror ("renaming .rpo file");
 
       if (!f->args)
        {