Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GCC 4.8.1 for Mac OS X

1,964 views
Skip to first unread message

Simon Wright

unread,
Jul 7, 2013, 2:37:02 PM7/7/13
to
You can find this at
https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/4.8.1/

The README says:

This is GCC 4.8.1 built for Mac OS X Mountain Lion (10.8.4, Darwin 12.4.0).

gcc-4.8.1-x86_64-apple-darwin12.tar.bz2
=======================================

Compilers included: Ada, C, C++, Objective C, Objective C++, Fortran.

Tools included: ASIS, AUnit, GPRbuild, GNATColl, XMLAda from GNAT GPL
2013.

Target: x86_64-apple-darwin12
Configured with:
../gcc-4.8.1/configure \
--prefix=/opt/gcc-4.8.1 \
--disable-multilib \
--enable-languages=c,c++,ada,fortran,objc,obj-c++ \
--target=x86_64-apple-darwin12 \
--build=x86_64-apple-darwin12
Thread model: posix
gcc version 4.8.1 (GCC)

MD5 (gcc-4.8.1-x86_64-apple-darwin12.tar.bz2) = 549d32da94a7af15e99bb98a7d288be9


Install by
=======

$ cd /
$ sudo tar jxvf ~/Downloads/gcc-4.8.1-x86_64-apple-darwin12.tar.bz2

and put /opt/gcc-4.8.1/bin first on your PATH.


Notes
=====

The compiler is GPL verson 3 with the Runtime Exception, so
executables built with it can be released on proprietary terms
PROVIDED THAT they make no use of the the packages from GNAT GPL 2013,
which are full GPL.

Changes made to GPRbuild GPL 2013 are in gprbuild-2013-src.diff. They:
* remove the '-c' flag that is wrongly passed to ranlib (and isn't by gnatmake).
* correct a problem when building static stand-alone libraries.

Changes made to GNATColl GPL 2013 are in gnatcoll-gpl-2013-src.diff. Only
changes necessary for the build are included.

Changes to ASIS GPL 2013 are in asis-gpl-2013-src.diff. Only changes
necessary for the build are included.

In addition to the above, a new library gnat_util is required by
GNATColl. A Sourceforge project to provide this has been set up at
https://sourceforge.net/projects/gnatutil/; release 4.8.1 is included
here. This is the equivalent of the Debian libgnatvsn.

The GNATColl build was configured as below, which is minimal apart
from GNU Readline being enabled. Users may wish to reconfigure for
their own requirements.

Shared libraries: yes (default: static)
Gtk+: no (requires pkg-config and gtkada.gpr)
Python: yes /System/Library/Frameworks/Python.framework/Versions/2.7 (see --with-python)
PyGtk: no (see --enable-pygtk)
PyGObject: no (see --enable-pygobject)
Syslog: yes (see --enable-syslog)
Readline (GPL license): yes (see --with-readline --enable-gpl)
gmp: no (see --with-gmp)
PostgreSQL: no -L/usr/lib (see --with-postgresql)
Sqlite: embedded (see --with-sqlite)
Iconv: yes (see --with-iconv)
Projects: yes

Bill Findlay

unread,
Jul 7, 2013, 6:02:38 PM7/7/13
to
On 07/07/2013 19:37, in article lya9lyz...@pushface.org, "Simon Wright"
Many thanks for that, Simon.
I see it shares with GNAT GPL 2013 this foible:

function hash_fn2 (the_key : naming.id)
return hash_code is
slice : constant slice_list
with Import, Convention => Ada, Address => the_key'Address;
h : hash_code := 0;
begin
for s of slice loop
exit when s = all_blanks_code;
|
>>> warning: variable "s" is not modified in loop body [enabled by default]
>>> warning: possible infinite loop [enabled by default]
h := rotate_left(h, 2) + s;
end loop;
h := avalanche(h);
return (if h = empty_hash_code then empty_hash_code + 1 else h);
end hash_fn2;


--
Bill Findlay
with blueyonder.co.uk;
use surname & forename;


Simon Wright

unread,
Jul 8, 2013, 3:25:31 AM7/8/13
to
Bill Findlay <yald...@blueyonder.co.uk> writes:

> On 07/07/2013 19:37, in article lya9lyz...@pushface.org, "Simon Wright"
> <si...@pushface.org> wrote:
>
>> You can find this at
>> https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/4.8.1/
>>
>
> Many thanks for that, Simon.

You're welcome.

> I see it shares with GNAT GPL 2013 this foible:

Foible! excellent word.

> function hash_fn2 (the_key : naming.id)
> return hash_code is
> slice : constant slice_list
> with Import, Convention => Ada, Address => the_key'Address;
> h : hash_code := 0;

Should that 0 be empty_hash_code?

> begin
> for s of slice loop
> exit when s = all_blanks_code;
> |
>>>> warning: variable "s" is not modified in loop body [enabled by default]
>>>> warning: possible infinite loop [enabled by default]

Some sort of mistake about the flow analysis, I guess.

Bill Findlay

unread,
Jul 8, 2013, 1:57:15 PM7/8/13
to
On 08/07/2013 08:25, in article ly61wlz...@pushface.org, "Simon Wright"
<si...@pushface.org> wrote:

> Bill Findlay <yald...@blueyonder.co.uk> writes:
>
>> On 07/07/2013 19:37, in article lya9lyz...@pushface.org, "Simon Wright"
>> <si...@pushface.org> wrote:
>>
>>> You can find this at
>>> https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/4.8.1/
>>>
>>
>> Many thanks for that, Simon.
>
> You're welcome.
>
>> I see it shares with GNAT GPL 2013 this foible:
>
> Foible! excellent word.

8-)

>> h : hash_code := 0;
>
> Should that 0 be empty_hash_code?

I can see why you ask that. empty_hash_code is chosen by the user to
indicate an empty table slot and the function is embedded in a generic
package having empty_hash_code as a constant parameter of the instantiation.
So it might not be zero, and I don't see much reason to start h off at
anything other than 0.

>> for s of slice loop
>> exit when s = all_blanks_code;
>> |
>>>>> warning: variable "s" is not modified in loop body [enabled by default]
>>>>> warning: possible infinite loop [enabled by default]
>
> Some sort of mistake about the flow analysis, I guess.
>

Looks like it.

>> h := rotate_left(h, 2) + s;
>> end loop;

Felix Krause

unread,
Jul 8, 2013, 4:06:26 PM7/8/13
to
On 2013-07-07 18:37:02 +0000, Simon Wright said:

> You can find this at
> https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/4.8.1/
>
> The README says:
>
> This is GCC 4.8.1 built for Mac OS X Mountain Lion (10.8.4, Darwin 12.4.0).
>
> [snip]

Great!

However, when I try to build any GPRBuild project with the included
gprbuild, it doesn't recognize the compiler. This is from gprconfig's
verbose output:

Foreach compiler in /opt/gcc-4.8.1/bin regexp=TRUE extra_dir=FALSE

[...]

GCC is candidate: filename=gcc
target: executing "gcc -dumpmachine" output=<use -v -v> no match
target: grep matched="x86_64-apple-darwin12"
version: executing "gcc -v" output=<use -v -v> no match
version: grep no match
Ignore compiler, since couldn't guess its version

[...]

GNAT is candidate: filename=gnatmake
target: executing "gcc -dumpmachine" output=<use -v -v> no match
target: grep matched="x86_64-apple-darwin12"
version: executing "gnatls -v" output=<use -v -v> no match
version: grep matched="4.8"
variables: executing "gcc -v" output=<use -v -v> no match
variables: grep no match
Ignore compiler since variable 'gcc_version' is empty

Interestingly, gcc -v outputs german text, which may be the reason for
the failure:

Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/opt/gcc-4.8.1/libexec/gcc/x86_64-apple-darwin12/4.8.1/lto-wrapper

Ziel: x86_64-apple-darwin12
Konfiguriert mit: ../gcc-4.8.1/configure --prefix=/opt/gcc-4.8.1
--disable-multilib --enable-languages=c,c++,ada,fortran,objc,obj-c++
--target=x86_64-apple-darwin12 --build=x86_64-apple-darwin12
Thread-Modell: posix
gcc-Version 4.8.1 (GCC)

I believe the last line is the problem; Apple's llvm-gcc gives:

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

so if gprconfig searches for "gcc version", it will fail. I don't have
a clue why gcc gives german output; I am german, but my system language
is english, and other binaries usually give english output. Does anyone
know how I can fix this?

--
Felix Krause
http://flyx.org/

Simon Wright

unread,
Jul 8, 2013, 6:37:12 PM7/8/13
to
Felix Krause <fl...@isobeef.org> writes:

> I don't have a clue why gcc gives german output; I am german, but my
> system language is english, and other binaries usually give english
> output. Does anyone know how I can fix this?

I get the same if I set the enviroment variable LANG to de; or, I find,
LC_MESSAGES which would be less pervasive.

so I'd guess that you'd be OK if you set LANG=en or LANG=c (or
LC_MESSAGES). LC_MESSAGES=fr gives

Utilisation des specs internes.
COLLECT_GCC=/opt/gcc-4.8.1/bin/gcc
COLLECT_LTO_WRAPPER=/opt/gcc-4.8.1/libexec/gcc/x86_64-apple-darwin12/4.8.1/lto-wrapper
Target: x86_64-apple-darwin12
Configuré avec: ../gcc-4.8.1/configure --prefix=/opt/gcc-4.8.1 --disable-multilib --enable-languages=c,c++,ada,fortran,objc,obj-c++ --target=x86_64-apple-darwin12 --build=x86_64-apple-darwin12
Modèle de thread: posix
gcc version 4.8.1 (GCC)

I see I should have configured with --disable-nls, as AdaCore do (but
not Apple. OTOH their compiler is llvm-gcc - ?)

Can you live with this?

Felix Krause

unread,
Jul 9, 2013, 11:31:29 AM7/9/13
to
On 2013-07-08 22:37:12 +0000, Simon Wright said:

> Felix Krause <fl...@isobeef.org> writes:
>
>> I don't have a clue why gcc gives german output; I am german, but my
>> system language is english, and other binaries usually give english
>> output. Does anyone know how I can fix this?
>
> I get the same if I set the enviroment variable LANG to de; or, I find,
> LC_MESSAGES which would be less pervasive.

Ah yes, that fixes the issue. Thanks!

> I see I should have configured with --disable-nls, as AdaCore do (but
> not Apple. OTOH their compiler is llvm-gcc - ?)
>
> Can you live with this?

Sure!

I managed to compile GPS with this GCC now, so it seems to work well.
One thing I noticed is that GNAT FSF does not support the switch
-fdump-xref for C Code which is used in the GNATCOLL project files. The
switch is described at [1]. Seems like it didn't make its way into the
GCC repos (yet?).


[1]: http://www.adacore.com/developers/development-log/NF-64-H721-006-gnat/

Simon Wright

unread,
Jul 9, 2013, 3:35:52 PM7/9/13
to
Felix Krause <fl...@isobeef.org> writes:

> I managed to compile GPS with this GCC now, so it seems to work
> well. One thing I noticed is that GNAT FSF does not support the switch
> -fdump-xref for C Code which is used in the GNATCOLL project
> files. The switch is described at [1]. Seems like it didn't make its
> way into the GCC repos (yet?).

And it's a long time coming, because it was already in GNAT GPL 2011!

AdaCore probably have a lot less influence on the FSF C/C++ compiler
front-ends than they do on GNAT.

Felix Krause

unread,
Jul 17, 2013, 3:57:09 PM7/17/13
to
On 2013-07-07 18:37:02 +0000, Simon Wright said:

> Tools included: ASIS, AUnit, GPRbuild, GNATColl, XMLAda from GNAT GPL
> 2013.

Just noticed that there is no gdb included. Would be great to have
that. It does't seem to be possible to use the gdb from Apple, it
doesn't recognize things like "break exception". I am rather unsure
about how language support is compiled into gdb and how one would
compile a gdb that supports Ada.

Simon Wright

unread,
Jul 17, 2013, 5:00:40 PM7/17/13
to
The system gdb is 6.3, and as you say doesn't understand Ada (BTW, the
current usage is 'catch exception', not 'break exception').

GDB 7.6 builds with the GCC 4.8.1 I uploaded, with very little
configuration needed (or possible):

../gdb-7.6/configure \
--prefix=/opt/gcc-4.8.1 \
--build=x86_64-apple-darwin12

but the resulting GDB isn't without its problems --

* it needs to be code-signed (but you can run it as root)

* it needs to be kicked to realise that it can catch Ada exceptions,
just like in [1]

* it gets confused about exceptions, but seems to stumble its way
through eventually

* it doesn't demangle Ada subprogram names properly

-- see [2].

I used to use the GDB that comes with GNAT GPL, but I see that the GPL
2013 version has exactly the same problems I noted above! Bug report
required, I think.

[1]
http://forward-in-code.blogspot.co.uk/2012/01/catching-exceptions-in-gdb.html

[2]
(gdb) catch exception name_error
Your Ada runtime appears to be missing some debugging information.
Cannot insert Ada exception catchpoint in this configuration.
(gdb) print __gnat_debug_raise_exception
$1 = {<text variable, no debug info>} 0x10017d4dd <__gnat_debug_raise_exception>
(gdb) catch exception name_error
warning: failed to reevaluate internal exception condition for catchpoint 0: A syntax error in expression, near `e) = long_integer (&name_error)'.
Catchpoint 1: `name_error' Ada exception
(gdb) run foo.uml
Starting program: /Users/simon/coldframe/tools/normalize_xmi foo.uml
warning: failed to reevaluate internal exception condition for catchpoint 1: A syntax error in expression, near `e) = long_integer (&name_error)'.
warning: failed to reevaluate internal exception condition for catchpoint 1: A syntax error in expression, near `e) = long_integer (&name_error)'.
processing foo.uml

Catchpoint 1, ADA.IO_EXCEPTIONS.NAME_ERROR at 0x000000010009b5f7 in _ada_normalize_xmi__main () at /Users/simon/coldframe/tools/normalize_xmi-main.adb:90
90 Input_Sources.File.Open (Arg, File_Source);
(gdb)

Simon Wright

unread,
Jul 18, 2013, 4:23:50 PM7/18/13
to
Simon Wright <si...@pushface.org> writes:

> I used to use the GDB that comes with GNAT GPL, but I see that the GPL
> 2013 version has exactly the same problems I noted above! Bug report
> required, I think.

GDB GPL 2013 is GDB 7.5 with a _lot_ of Ada-related changes. So I think
that's the one to go for.

Shame that the changes can't be folded back into the GDB trunk.

Michael Rohan

unread,
Jul 20, 2013, 8:59:41 PM7/20/13
to
Hi,

Not sure if this is simply a setup issue on my MacBook (this is the first Mac
system I've worked on) but when I try to build an application I run into a linker issue:

$ make
gnatmake -p -XOS=unix -XTYPE=static -XBUILD=Debug -aP../../lib/gnat -aP../../src -P zbmcompile
gnatbind -x /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali
gnatlink /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali -g /Users/mrohan/zb/zanyblue/lib/zanyblue/libzanyblue.a -Wl,-rpath,/opt/gcc-4.8.1/lib/gcc/x86_64-apple-darwin12/4.8.1/adalib/ -o /Users/mrohan/zb/zanyblue/bin/zbmcompile
ld: unknown option: -R
collect2: error: ld returned 1 exit status
gnatlink: error when calling /opt/gcc-4.8.1/bin/gcc
gnatmake: *** link failed.
make: *** [all] Error 4

I assume I need GNU ld, it seems I don't currently have it:

$ ld -v
@(#)PROGRAM:ld PROJECT:ld64-136
configured to support archs: armv6 armv7 armv7s i386 x86_64
LTO support using: LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)

Apologies if this is a basic question.

Take care,
Michael.

Bill Findlay

unread,
Jul 20, 2013, 9:06:16 PM7/20/13
to
On 21/07/2013 01:59, in article
a944c0c4-cff4-4318...@googlegroups.com, "Michael Rohan"
<mic...@zanyblue.com> wrote:


> Not sure if this is simply a setup issue on my MacBook (this is the first Mac
> system I've worked on) but when I try to build an application I run into a
> linker issue:
>
> $ make
> gnatmake -p -XOS=unix -XTYPE=static -XBUILD=Debug -aP../../lib/gnat
> -aP../../src -P zbmcompile
> gnatbind -x /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali
> gnatlink /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali -g
> /Users/mrohan/zb/zanyblue/lib/zanyblue/libzanyblue.a
> -Wl,-rpath,/opt/gcc-4.8.1/lib/gcc/x86_64-apple-darwin12/4.8.1/adalib/ -o
> /Users/mrohan/zb/zanyblue/bin/zbmcompile
> ld: unknown option: -R
> collect2: error: ld returned 1 exit status
> gnatlink: error when calling /opt/gcc-4.8.1/bin/gcc
> gnatmake: *** link failed.
> make: *** [all] Error 4

I had a similar problem with GNAT GPL 2102. You need to install the latest
Xcode 4.4, but that does not install by default the command line tools
/usr/bin{as, ld, make} needed by GNAT. It is necessary to invoke:

Xcode > Preferences... > Downloads > Command Line Tools: Install

It's about a 115MB download.

Once completed, GNAT GPL 2102 was restored to sanity, so that might be what
you need with GCC 4.8.1

Michael Rohan

unread,
Jul 20, 2013, 9:19:45 PM7/20/13
to
Hi,

Thank you for the feedback. I did install Xcode, the latest version (4.6.2) which might be the problem. I do have /usr/bin/ld, /usr/bin/as and /usr/bin/make. Both as and make report themselves as GNU:

$ /usr/bin/as -v
Apple Inc version cctools-839, GNU assembler version 1.38
^CInterrupted by signal 2

$ /usr/bin/make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

Take care,
Michael.
Message has been deleted

Simon Wright

unread,
Jul 21, 2013, 7:55:05 AM7/21/13
to
Michael Rohan <mic...@zanyblue.com> writes:

> Not sure if this is simply a setup issue on my MacBook (this is the first Mac
> system I've worked on) but when I try to build an application I run
> into a linker issue:
>
> $ make
> gnatmake -p -XOS=unix -XTYPE=static -XBUILD=Debug -aP../../lib/gnat
> -aP../../src -P zbmcompile
> gnatbind -x /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali
> gnatlink /Users/mrohan/zb/zanyblue/src/obj/zbmcompile-main.ali -g
> /Users/mrohan/zb/zanyblue/lib/zanyblue/libzanyblue.a
> -Wl,-rpath,/opt/gcc-4.8.1/lib/gcc/x86_64-apple-darwin12/4.8.1/adalib/
> -o /Users/mrohan/zb/zanyblue/bin/zbmcompile
> ld: unknown option: -R
> collect2: error: ld returned 1 exit status
> gnatlink: error when calling /opt/gcc-4.8.1/bin/gcc
> gnatmake: *** link failed.
> make: *** [all] Error 4
>
> I assume I need GNU ld, it seems I don't currently have it:
>
> $ ld -v
> @(#)PROGRAM:ld PROJECT:ld64-136
> configured to support archs: armv6 armv7 armv7s i386 x86_64
> LTO support using: LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)
>
> Apologies if this is a basic question.

Not at all!

I tried your gnatmake command above with zanyblue-1.1.0b (after having
run make from src/), first with -largs -Wl,-v to show the actual command
passed to ld (which showd the -R) and then with -largs -v to give a full
report of the gnatlink command; which gave, near the end,

...-Wl,-R,$ORIGIN/../lib...

so I grepped for ORIGIN from src/, which gave (along with some files in
src/obj/)

./mkfile/conf.mk:# ld.so runtime path "$ORIGIN/../lib", i.e., load shared libraries from

./os/unix/zanyblue-os-ld_run_path.ads: pragma Linker_Options ("-Wl,-R,$ORIGIN/../lib");

Just looking at the last, it says

package ZanyBlue.OS.Ld_Run_Path is

pragma Warnings (Off, ZanyBlue.OS.Ld_Run_Path);
pragma Linker_Options ("-Wl,-R,$ORIGIN/../lib");
-- Embed the ls.do runtime shared library path "../lib" relative to the
-- executable.

end ZanyBlue.OS.Ld_Run_Path;

(I think that comment should say ld.so, not ls.do!) -- and the thing is,
that's not how you embed .dylib runtime paths in the executable on Mac
OS X.

(a) build your .dylibs using gprbuild, not gnatmake, because gnatmake
doesn't know how to embed runtime paths in .dylibs;

(b) install your .dylibs to the proper place;

(c) link against them.

(I should say, I can't give you the full reasoning behind this, but it
works!)

Michael Rohan

unread,
Jul 21, 2013, 2:01:56 PM7/21/13
to
Hi,

Awesome, it's my error. I can rework that area for Mac. Thanks for digging into this.

BTW, it's really neat that the GNAT are simply available with this distribution: AUnit, XML Ada.

Apart from my explicit step outside the language via my pragma Linker_Options, everything just built and passed my tests (850 + 1229) on a new platform for me. I've worked in other languages and there's always something that needs to be handled but as a random, isolated, data point, it does look good for Ada.

Take care, and thank you,
Michael.
0 new messages