Skip to content

Commit 4ebb18e

Browse files
authored
Fix: add wait when linking library with *.resp file (#808)
1 parent a338c03 commit 4ebb18e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/fpm_compiler.f90 renamed to src/fpm_compiler.F90

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,9 @@ end subroutine link
937937

938938

939939
!> Create an archive
940-
!> @todo An OMP critical section is added for Windows OS,
941-
!> which may be related to a bug in Mingw64-openmp and is expected to be resolved in the future,
942-
!> see issue #707 and #708.
940+
!> @todo For Windows OS, use the local `delete_file_win32` in stead of `delete_file`.
941+
!> This may be related to a bug in Mingw64-openmp and is expected to be resolved in the future,
942+
!> see issue #707, #708 and #808.
943943
subroutine make_archive(self, output, args, log_file, stat)
944944
!> Instance of the archiver object
945945
class(archiver_t), intent(in) :: self
@@ -953,16 +953,27 @@ subroutine make_archive(self, output, args, log_file, stat)
953953
integer, intent(out) :: stat
954954

955955
if (self%use_response_file) then
956-
!$omp critical
957956
call write_response_file(output//".resp" , args)
958957
call run(self%ar // output // " @" // output//".resp", echo=self%echo, &
959958
& verbose=self%verbose, redirect=log_file, exitstat=stat)
960-
call delete_file(output//".resp")
961-
!$omp end critical
959+
call delete_file_win32(output//".resp")
960+
962961
else
963962
call run(self%ar // output // " " // string_cat(args, " "), &
964963
& echo=self%echo, verbose=self%verbose, redirect=log_file, exitstat=stat)
965964
end if
965+
966+
contains
967+
subroutine delete_file_win32(file)
968+
character(len=*), intent(in) :: file
969+
logical :: exist
970+
integer :: unit, iostat
971+
inquire(file=file, exist=exist)
972+
if (exist) then
973+
open(file=file, newunit=unit)
974+
close(unit, status='delete', iostat=iostat)
975+
end if
976+
end subroutine delete_file_win32
966977
end subroutine make_archive
967978

968979

@@ -976,7 +987,7 @@ subroutine write_response_file(name, argv)
976987

977988
integer :: iarg, io
978989

979-
open(file=name, newunit=io)
990+
open(file=name, newunit=io, status='replace')
980991
do iarg = 1, size(argv)
981992
write(io, '(a)') unix_path(argv(iarg)%s)
982993
end do

0 commit comments

Comments
 (0)