A couple years ago, I successfully installed GHDL on Mac OS X (10.5.1) with 
much help from Tristan. Below are my notes. Trying to reinstall on OS X 10.6.6 
with the current version of GHDL I have no such success. It appears that the 
GHDL package has changed substantially in the interim, so some of my notes are 
no longer even applicable.

Anyone have any luck on OS X recently? Can anyone point me to some install 
instructions that might get me back on track here?

I've also attached the ghdl.diff patch file below, which I think Tristan 
created for me and got me going last time. Of course, this patch appears to 
reference files that have moved.

Any help would be very much appreciated.

Best,

Jake

--------
Installing GHDL on Mac OS X (10.5.1)
--------
Install gnat using the gcc-4.3 package downloaded from www.macada.org.

Add gnat to the search path by adding the following line to the ~/.profile file:

            export PATH="$PATH:/usr/local/ada-4.3/bin"
Create a directory called GHDL in the /Applications directory and change to 
this directory.

Anonymously checkout the GHDL source with Subversion using the following 
command (this should create a directory called /Applications/GHDL/trunk):

            svn co svn://svn.gna.org/svn/ghdl/trunk ghdl
In the trunk/ortho/mcode/ortho_code-x86-flags.ads file, change 2 ** 3 to 2 ** 4 
in the following line:

            Stack_Boundary : Unsigned_32 := 2 ** 3
Copy the ghdl.diff patch to the trunk/ directory and from this directory run 
the following command:

            patch < ghdl.diff
In the trunk/translate/ghdldrv directory, run the following Make commands:

            make target=x86-darwin
            make target=x86-darwin install.mcode
In the trunk/translate/ghdldrv directory, create a symlink to the binary using 
the following command:

            ln -s ghdl_mcode ghdl
Add GHDL to the path by adding the following line to the ~/.profile file:

            export PATH="$PATH:/Applications/GHDL/trunk/translate/ghdldrv/""
Open a new terminal window and run the following command to verify that GHDL 
compiled and is setup appropriately:

            ghdl -v
--------


----------
ghdl.diff Patch File
----------
Index: translate/ghdldrv/Makefile
===================================================================
--- translate/ghdldrv/Makefile  (revision 93)
+++ translate/ghdldrv/Makefile  (working copy)
@@ -32,7 +32,8 @@
 #GNAT_LARGS= -static
 all: ghdl_mcode
 
-target=i686-pc-linux-gnu
+#target=i686-pc-linux-gnu
+target=i686-darwin
 GRTSRCDIR=../grt
 include $(GRTSRCDIR)/Makefile.inc
 
Index: translate/grt/config/linux.c
===================================================================
--- translate/grt/config/linux.c        (revision 93)
+++ translate/grt/config/linux.c        (working copy)
@@ -25,6 +25,10 @@
 #include <stdlib.h>
 //#include <stdint.h>
 
+#ifdef __APPLE__
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
 /* On x86, the stack growns downward.  */
 #define STACK_GROWNS_DOWNWARD 1
 
Index: translate/grt/grt-processes.adb
===================================================================
--- translate/grt/grt-processes.adb     (revision 93)
+++ translate/grt/grt-processes.adb     (working copy)
@@ -111,6 +111,9 @@
    begin
       if State /= State_Sensitized then
          Stack := Stack_Create (Proc, This);
+         if Stack = Null_Stack then
+            Internal_Error ("cannot allocate stack: memory exhausted");
+         end if;
       else
          Stack := Null_Stack;
       end if;
Index: ortho/mcode/memsegs_c.c
===================================================================
--- ortho/mcode/memsegs_c.c     (revision 93)
+++ ortho/mcode/memsegs_c.c     (working copy)
@@ -34,6 +34,10 @@
 #define HAVE_MREMAP
 #endif
 
+#ifndef HAVE_MREMAP
+#include <string.h>
+#endif
+
 void *
 mmap_malloc (int size)
 {
Index: ortho/mcode/ortho_code-x86-flags.ads
===================================================================
--- ortho/mcode/ortho_code-x86-flags.ads        (revision 93)
+++ ortho/mcode/ortho_code-x86-flags.ads        (working copy)
@@ -24,5 +24,5 @@
 
    --  Prefered stack alignment.
    --  Must be a power of 2.
-   Stack_Boundary : Unsigned_32 := 2 ** 3; -- 4 for MacOSX, 3 for Linux
+   Stack_Boundary : Unsigned_32 := 2 ** 4; -- 4 for MacOSX, 3 for Linux
 end Ortho_Code.X86.Flags;
Index: ortho/mcode/ortho_code-x86-emits.adb
===================================================================
--- ortho/mcode/ortho_code-x86-emits.adb        (revision 93)
+++ ortho/mcode/ortho_code-x86-emits.adb        (working copy)
@@ -1988,10 +1988,12 @@
       use Binary_File;
       use Interfaces;
       use Ortho_Code.Flags;
+      use Ortho_Code.X86.Insns;
       Sym : Symbol;
       Subprg_Decl : O_Dnode;
       Is_Global : Boolean;
       Frame_Size : Unsigned_32;
+      Saved_Regs_Size : Unsigned_32;
    begin
       Set_Current_Section (Sect_Text);
       Subprg_Decl := Subprg.D_Decl;
@@ -2007,14 +2009,18 @@
       Set_Symbol_Pc (Sym, Is_Global);
       Subprg_Pc := Get_Current_Pc;
 
+      Saved_Regs_Size := Boolean'Pos(Reg_Used (R_Di)) * 4
+        + Boolean'Pos(Reg_Used (R_Si)) * 4
+        + Boolean'Pos(Reg_Used (R_Bx)) * 4;
+
       --  Compute frame size.
       --  8 bytes are used by return address and saved frame pointer.
-      Frame_Size := Unsigned_32 (Subprg.Stack_Max) + 8;
+      Frame_Size := Unsigned_32 (Subprg.Stack_Max) + 8 + Saved_Regs_Size;
       --  Align.
       Frame_Size := (Frame_Size + X86.Flags.Stack_Boundary - 1)
         and not (X86.Flags.Stack_Boundary - 1);
       --  The 8 bytes are already allocated.
-      Frame_Size := Frame_Size - 8;
+      Frame_Size := Frame_Size - 8 - Saved_Regs_Size;
 
       --  Emit prolog.
       --  push %ebp
-------


_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to