diff options
-rw-r--r-- | libraries.adb | 5 | ||||
-rw-r--r-- | translate/ghdldrv/Makefile | 4 | ||||
-rw-r--r-- | translate/grt/grt-main.adb | 15 | ||||
-rw-r--r-- | translate/grt/grt-processes.adb | 6 | ||||
-rw-r--r-- | translate/grt/grt-processes.ads | 7 |
5 files changed, 28 insertions, 9 deletions
diff --git a/libraries.adb b/libraries.adb index 0b07dc3..e0306f4 100644 --- a/libraries.adb +++ b/libraries.adb @@ -1287,8 +1287,11 @@ package body Libraries is & Back_End.Library_To_File_Name (Library); Delete_Success : Boolean; begin + -- For windows: renames doesn't overwrite destination; so first + -- delete it. This can create races condition on Unix: if the + -- program is killed between delete and rename, the library is lost. + Delete_File (File_Name, Delete_Success); Rename_File (Temp_Name.all, File_Name, Success); - Delete_File (Temp_Name.all, Delete_Success); Free (Temp_Name); if not Success then Error_Msg ("cannot update library file """ & File_Name & """"); diff --git a/translate/ghdldrv/Makefile b/translate/ghdldrv/Makefile index 51592ae..af2e82d 100644 --- a/translate/ghdldrv/Makefile +++ b/translate/ghdldrv/Makefile @@ -43,6 +43,7 @@ target=i686-pc-linux-gnu #target=x86_64-pc-linux-gnu #target=i686-apple-darwin #target=x86_64-apple-darwin +#target=i386-pc-mingw32 GRTSRCDIR=../grt include $(GRTSRCDIR)/Makefile.inc @@ -52,6 +53,9 @@ endif ifeq ($(filter-out i%86 darwin%,$(arch) $(osys)),) ORTHO_X86_FLAGS=Flags_Macosx endif +ifeq ($(filter-out i%86 mingw32%,$(arch) $(osys)),) + ORTHO_X86_FLAGS=Flags_Windows +endif ifdef ORTHO_X86_FLAGS ORTHO_DEPS=ortho_code-x86-flags.ads endif diff --git a/translate/grt/grt-main.adb b/translate/grt/grt-main.adb index 995a0d3..3052a95 100644 --- a/translate/grt/grt-main.adb +++ b/translate/grt/grt-main.adb @@ -53,6 +53,13 @@ package body Grt.Main is procedure Ghdl_Elaborate; pragma Import (C, Ghdl_Elaborate, "__ghdl_ELABORATE"); + -- Wrapper around elaboration just to return 0. + function Ghdl_Elaborate_Wrapper return Integer is + begin + Ghdl_Elaborate; + return 0; + end Ghdl_Elaborate_Wrapper; + procedure Disp_Stats_Hook (Code : Integer); pragma Convention (C, Disp_Stats_Hook); @@ -135,8 +142,12 @@ package body Grt.Main is Stats.Start_Elaboration; end if; - -- Elaboration. - Ghdl_Elaborate; + -- Elaboration. Run through longjump to catch errors. + if Grt.Processes.Run_Through_Longjump (Ghdl_Elaborate_Wrapper'Access) < 0 + then + Grt.Errors.Error ("error during elaboration"); + return; + end if; if Flag_Stats then Stats.Start_Order; diff --git a/translate/grt/grt-processes.adb b/translate/grt/grt-processes.adb index 7e049fc..50d7601 100644 --- a/translate/grt/grt-processes.adb +++ b/translate/grt/grt-processes.adb @@ -628,12 +628,6 @@ package body Grt.Processes is pragma Unreferenced (Disp_All_Processes); - type Run_Handler is access function return Integer; - -- pragma Convention (C, Run_Handler); - - function Run_Through_Longjump (Hand : Run_Handler) return Integer; - pragma Import (Ada, Run_Through_Longjump, "__ghdl_run_through_longjump"); - -- Run resumed processes. -- If POSTPONED is true, resume postponed processes, else resume -- non-posponed processes. diff --git a/translate/grt/grt-processes.ads b/translate/grt/grt-processes.ads index d75ca49..5566233 100644 --- a/translate/grt/grt-processes.ads +++ b/translate/grt/grt-processes.ads @@ -133,6 +133,13 @@ package Grt.Processes is procedure Ghdl_Protected_Init (Obj : System.Address); procedure Ghdl_Protected_Fini (Obj : System.Address); + type Run_Handler is access function return Integer; + + -- Run HAND through a wrapper that catch some errors (in particular on + -- windows). Returns < 0 in case of error. + function Run_Through_Longjump (Hand : Run_Handler) return Integer; + pragma Import (Ada, Run_Through_Longjump, "__ghdl_run_through_longjump"); + private -- State of a process. type Process_State is |