Forum: GHDL Successful (almost) build of 0.27 on Mac OS X 10.5.5

Posted by D. Jeff Dionne (Guest)
on 2009-01-11 08:04
(Received via mailing list)
Hello all,
It seems like it should not very difficult to make 0.27 build for Mac
OS X cleanly.

You need xcode installed (Apple's version of the GNU tools and an IDE)
Grab Gnati386-4.3-xcode3.0.dmg from 
http://www.macada.org/macada/Downloads.html
Grab gcc-core-4.2.4.tar.bz2 from GNU
Grab ghdl-0.27.tar.bz2 from the GHDL site

Make a list of the contents of /Developer/Library/Xcode/Plug-ins
Install the gnat package.  Remove anything the gnat install puts in /
Developer/Library/Xcode/Plug-ins

As per Thomas Sailer - 
https://mail.gna.org/public/ghdl-discuss/2008-05/msg00006.html
Hack ghdl-0.27/vhdl/grt/grt.adc commenting out 3 lines, thus:

-- pragma Restrictions (No_Exception_Handlers);
-- pragma restrictions (No_Exceptions);
pragma Restrictions (No_Secondary_Stack);
--pragma Restrictions (No_Elaboration_Code);
pragma Restrictions (No_Io);
pragma Restrictions (Max_Tasks => 0);
pragma Restrictions (No_Implicit_Heap_Allocations);
-- pragma No_Run_Time;

Note: this causes trouble later, which is not quite solved...

The build will break complaining that xgcc doesn't know ada.  It's
possible that this could
be solved by building the ada compiler.  Another day.  For  now, patch
gcc/vhdl/Makefile.in
before you run configure

GRT_ADACOMPILE=$(ADAC) -c $(GRT_FLAGS) $(GRT_PRAGMA_FLAG) -o $@ $<
hacked to run gcc directly
GRT_ADACOMPILE=gcc -c $(GRT_FLAGS) $(GRT_PRAGMA_FLAG) -o $@ $<

Prefix PATH with the path to the ada install /usr/local/ada-4.3/bin
Build as per instructions in ghdl-0.27/README.
I also suggest setting a prefix eg, /usr/local/ghdl-0.27 and build
languages c and vhdl

$ make ; sudo make install
Works... mostly.  Since we had to enable the ada run time, elaboration
fails when it tries to link.

$ cat > hello.vhd
use std.textio.all; --  Imports the standard textio package.

--  Defines a design entity, without any ports.
entity hello_world is
end hello_world;

architecture behaviour of hello_world is
begin
   process
      variable l : line;
   begin
      write (l, String'("Hello world!"));
      writeline (output, l);
      wait;
   end process;
end behaviour;

^C
$ ghdl -a hello.vhd
$ ghdl -e hello_world
Undefined symbols:
   "___gl_interrupt_states", referenced from:
       ___gl_interrupt_states$non_lazy_ptr in libgrt.a(run-bind.o)
   "___gnat_eh_personality", referenced from:
... and on and on...

We need the ada runtime and GCC's exception handling code...

$ ghdl --bind hello_world
$ gcc `ghdl --list-link hello_world` /usr/local/ghdl-0.27/lib/gcc/i386-
apple-darwin9.5.0/4.2.4/libgcc_eh.a /usr/local/ada-4.3/lib/gcc/i686-
apple-darwin9/4.3.0/adalib/libgnat.a  -o hello_world
$ ./hello_world
Hello world!

Thanks to Tristan, as always, for GHDL.
I'll try and make a patch or a build script, and fix the elaboration...
Cheers,
J
Posted by Tristan Gingold (Guest)
on 2009-01-15 04:37
(Received via mailing list)
On Tue, Jan 06, 2009 at 12:02:43PM +0900, D. Jeff Dionne wrote:
> Hello all,
> It seems like it should not very difficult to make 0.27 build for Mac  
> OS X cleanly.

Hi,

thank you for the work and the procedure.

> $ ghdl -a hello.vhd
> $ ghdl -e hello_world
> Undefined symbols:
>    "___gl_interrupt_states", referenced from:
>        ___gl_interrupt_states$non_lazy_ptr in libgrt.a(run-bind.o)
>    "___gnat_eh_personality", referenced from:
> ... and on and on...
> 
> We need the ada runtime and GCC's exception handling code...

Correct.  This is supposed to be fixed in the SVN repository.  GRT can 
now
be compiled using the pragma No_Run_Time.

> Thanks to Tristan, as always, for GHDL.

You're welcome!

Tristan.
This topic is locked and can not be replied to.