This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR 38248 - don't silently fail if unlink/rename fails
On Tue, Nov 25, 2008 at 06:36:19AM -0800, H.J. Lu wrote:
> On Mon, Nov 24, 2008 at 3:22 PM, Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> > On Tue, Nov 25, 2008 at 12:04:05AM +0100, Tobias Burnus wrote:
> >> Steve Kargl wrote:
> >> > On Mon, Nov 24, 2008 at 05:54:49PM +0100, Tobias Burnus wrote:
> >> >
> >> >> + if (unlink (filename))
> >> >> + gfc_fatal_error ("Can't delete module file '%s': %s", filename,
> >> >>
> >> > Why gfc_fatal_error instead of gfc_error or gfc_error_now?
> >> >
> >> Frankly, I don't mind that much whether it is an error_now or a fatal
> >> error; however, I think gfc_fatal_error is OK since not able too write a
> >> file is rather bad and can lead to strange errors afterwards. (At least
> >> I often prefer to see the big error first without needing to dig through
> >> parenthesis diagnosts (due to changed .mod format) and other misleading
> >> error messages.)
> >>
> >> But if you think gfc_error_now is superior, I can change it before
> >> submittal.
> >>
> >
> > I have no objection to gfc_fatal_error. I was just curious,
> > because gfortran doesn't use gfc_fatal_error very often.
> >
>
> It breaks libgomp:
>
> [hjl@gnu-33 libgomp]$
> /export/gnu/import/svn/gcc-test/bld/./gcc/gfortran
> -B/export/gnu/import/svn/gcc-test/bld/./gcc/
> -B/usr/local/x86_64-unknown-linux-gnu/bin/
> -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
> /usr/local/x86_64-unknown-linux-gnu/include -isystem
> /usr/local/x86_64-unknown-linux-gnu/sys-include -m32 -g -O2 -Wall
> -m32 -fsyntax-only omp_lib.f90
> Fatal Error: Can't delete module file 'omp_lib_kinds.mod': No such
> file or directory
> [hjl@gnu-33 libgomp]$ ls
> affinity.lo env.lo libgomp.spec omp_lib.h single.lo
> affinity.o env.o libtool omp_lib_kinds.mod0 single.o
> alloc.lo error.lo lock.lo ordered.lo stamp-build-info
> alloc.o error.o lock.o ordered.o stamp-h1
> bar.lo fortran.lo loop.lo parallel.lo task.lo
> bar.o fortran.o loop.o parallel.o task.o
> barrier.lo gstdint.h loop_ull.lo proc.lo team.lo
> barrier.o iter.lo loop_ull.o proc.o team.o
> config.cache iter.o Makefile ptrlock.lo testsuite
> config.h iter_ull.lo multilib.out ptrlock.o time.lo
> config.log iter_ull.o mutex.lo sections.lo time.o
> config.status libgomp_f.h mutex.o sections.o work.lo
> critical.lo libgomp.info omp.h sem.lo work.o
> critical.o libgomp.la omp_lib.f90 sem.o
> [hjl@gnu-33 libgomp]$
>
>
I am checking it in as an obvious fix.
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 142191)
+++ ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2008-11-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ * module.c (gfc_dump_module): Report error on unlink only if
+ errno != ENOENT.
+
2008-11-25 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/36463
Index: module.c
===================================================================
--- module.c (revision 142191)
+++ module.c (working copy)
@@ -4850,7 +4850,7 @@ gfc_dump_module (const char *name, int d
|| memcmp (md5_old, md5_new, sizeof (md5_old)) != 0)
{
/* Module file have changed, replace the old one. */
- if (unlink (filename))
+ if (unlink (filename) && errno != ENOENT)
gfc_fatal_error ("Can't delete module file '%s': %s", filename,
strerror (errno));
if (rename (filename_tmp, filename))