aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-02-01 04:32:51 +0100
committerTristan Gingold <tgingold@free.fr>2014-02-01 04:32:51 +0100
commit65f7250d7f0ddbf916758acd1a91d313e57ca0f1 (patch)
tree5d044fdfb383b17e4bfa14136ef9d5f606cf70ce
parenta60ee6981330604152d73f023140c1d30a0c52e1 (diff)
downloadghdl-65f7250d7f0ddbf916758acd1a91d313e57ca0f1.tar.gz
ghdl-65f7250d7f0ddbf916758acd1a91d313e57ca0f1.tar.bz2
ghdl-65f7250d7f0ddbf916758acd1a91d313e57ca0f1.zip
Windows: fix library update, handle errors during elaboration.
-rw-r--r--libraries.adb5
-rw-r--r--translate/ghdldrv/Makefile4
-rw-r--r--translate/grt/grt-main.adb15
-rw-r--r--translate/grt/grt-processes.adb6
-rw-r--r--translate/grt/grt-processes.ads7
5 files changed, 28 insertions, 9 deletions
diff --git a/libraries.adb b/libraries.adb
index 0b07dc32b..e0306f42d 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 51592ae9e..af2e82dcd 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 995a0d326..3052a958b 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 7e049fced..50d760129 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 d75ca4904..55662335e 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