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

building gforth on Mac OS X Snow Leopard (10.6.x)

66 views
Skip to first unread message

zbrown

unread,
Nov 15, 2009, 12:41:53 PM11/15/09
to
Hi all,

I was in #fo...@irc.freenode.net and having problems building gforth
on Mac OS X Snow Leopard (10.6.2). After some toying and suggestions
from ASau, I managed to find that the solution to building on Snow
Leopard is the following:

LDFLAGS="-arch i386 -m32" CFLAGS="-arch i386 -m32" ./configure

It appears that the 64 bit user land for Mac OS X causes problems.
Simple fix and it lets the gforth binary build properly.

-Zac Brown

Anton Ertl

unread,
Nov 15, 2009, 12:45:50 PM11/15/09
to

Ulrich Hoffmann recently reported a problem building Gforth on MacOS X
10.6, and my suggestion was to configure as follows:

./configure x86_64-apple-darwin10.0.0

and he reported success with that. Your suggestion would also have
fixed his problem. The problem is that for some reason configure by
itself guesses that it's a 32-bit system. Your approach fixes this by
making it a 32-bit system, my suggestion fixes it by eliminating the
guessing and telling it that it's a 64-bit system. Of course, if
there are other problems with 64-bit applications in MacOS X, building
a 32-bit Gforth is the way to go.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2009: http://www.euroforth.org/ef09/

Bernd Paysan

unread,
Nov 15, 2009, 5:13:41 PM11/15/09
to
Anton Ertl wrote:
>>It appears that the 64 bit user land for Mac OS X causes problems.
>>Simple fix and it lets the gforth binary build properly.

I suppose the 64 bit userland is just inconsistent. What do

uname -p

and

gcc -v

report? On 10.5, they report "i386" and "Target: i686-apple-darwin9".
On 10.6, I suspect, they'll report "i386" and "Target: x86_64-apple-
darwin10", which can't fly.

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/

David N. Williams

unread,
Nov 16, 2009, 8:07:11 AM11/16/09
to
Bernd Paysan wrote:
> Anton Ertl wrote:
>>> It appears that the 64 bit user land for Mac OS X causes problems.
>>> Simple fix and it lets the gforth binary build properly.
>
> I suppose the 64 bit userland is just inconsistent. What do
>
> uname -p
>
> and
>
> gcc -v
>
> report? On 10.5, they report "i386" and "Target: i686-apple-darwin9".
> On 10.6, I suspect, they'll report "i386" and "Target: x86_64-apple-
> darwin10", which can't fly.
>

Not quite. In the following, line wrap has been edited:

----------
schwartz:~ dnwills$ uname -p
i386
schwartz:~ dnwills$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5646.1~2/src/configure
--disable-checking --enable-werror --prefix=/usr
--mandir=/share/man --enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
--with-slibdir=/usr/lib --build=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1d
--program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5646) (dot 1)
----------

Note the --host line. My understanding is that the OS X kernel
is 64-bit, but userland runs in either 32- or 64-bit mode. For
example:

----------
schwartz:~ dnwills$ gforth
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
1 cells . 8 ok
bye
schwartz:~ dnwills$ pfe
\ Portable Forth Environment 0.33.70 (Sep 27 2009 10:20:34)
Copyright (C) Dirk Uwe Zoller 1993 - 1995.
Copyright (C) Tektronix, Inc. 1998 - 2003.
Copyright (C) Guido U. Draheim 2005 - 2008.
ANS/ffa ITC Forth - Please enter LICENSE and WARRANTY.
Running on i386 darwin9.8.0 - to quit say BYE. ok
1 cells . 4 ok
----------

-- David

Bernd Paysan

unread,
Nov 16, 2009, 8:43:45 AM11/16/09
to
David N. Williams wrote:
> Not quite. In the following, line wrap has been edited:
>
> ----------
> schwartz:~ dnwills$ uname -p
> i386
> schwartz:~ dnwills$ gcc -v
> Using built-in specs.
> Target: i686-apple-darwin10
> Configured with: /var/tmp/gcc/gcc-5646.1~2/src/configure
> --disable-checking --enable-werror --prefix=/usr
> --mandir=/share/man --enable-languages=c,objc,c++,obj-c++
> --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
> --with-slibdir=/usr/lib --build=i686-apple-darwin10
> --with-gxx-include-dir=/include/c++/4.2.1d
> --program-prefix=i686-apple-darwin10-
> --host=x86_64-apple-darwin10 --target=i686-apple-darwin10
> Thread model: posix
> gcc version 4.2.1 (Apple Inc. build 5646) (dot 1)
> ----------
>
> Note the --host line. My understanding is that the OS X kernel
> is 64-bit, but userland runs in either 32- or 64-bit mode.

Of course - the latter is true for Mac OS X 10.5, too, or for most x86_64
Linuxes. The problem is that GCC apparently lies to you, when it tells you
that the target is i686-apple-darwin10. If that was true, it won't need a
special "-arch i386 -m32" flag to actually compile for 32 bit x86. There's
probably some confusion within Apple about the two "different"
architectures, because GCC internally treats x86 and x86_64 as the same
architecture, just with two different modes (selected by -m32 or -m64, i.e.
you don't need a cross compiler to compile for the other x86 architecture).
Apparently, -m64 is default on Apple's GCC, but it won't tell the usual way.

David N. Williams

unread,
Nov 16, 2009, 1:53:15 PM11/16/09
to

Thanks for the heads up! Zac's suggestion finally allows me to
build pfe under Snow Leopard, with the following configure line:

./configure --with-regs=all CFLAGS="-DUNROLL_NEXT -m32" --with-opt=3

It appears that -arch i386 is also unnecessary for 32-bit gforth,
but with or without it, there is a disconcerting build error:

----------
file not found
in file included from *OS command line*:-1
unix/socket.fs:48: open-lib failed
>>>end-c-library<<<
Backtrace:
$302B14 throw
$32454C c(abort")
$324A10 compile-wrapper-function1
make: *** [build-libcc-named] Error 1
----------

But a 32-bit gforth is actually built and *appears* to be okay.

The error does not occur in 64-bit mode, with an updated version
of Anton's configure line:

./configure x86_64-apple-darwin10.2.0

-- David

Anton Ertl

unread,
Nov 16, 2009, 2:12:46 PM11/16/09
to
"David N. Williams" <will...@umich.edu> writes:
>It appears that -arch i386 is also unnecessary for 32-bit gforth,
>but with or without it, there is a disconcerting build error:
>
>----------
>file not found
>in file included from *OS command line*:-1
>unix/socket.fs:48: open-lib failed

My guess is that libcc/libtool/gcc built for the wrong architecture.
It's probably better to configure with

./configure CC="gcc -m32"

than by setting LDFLAGS and CFLAGS. By setting CC you also set
LIBTOOL_CC, and with a little luck that fixes the problem.

>But a 32-bit gforth is actually built and *appears* to be okay.

At the moment very little depends on libcc, so most of Gforth will
work.

0 new messages