gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building Gforth for Apple's new Arm-based Macs


From: Craig Treleaven
Subject: Re: Building Gforth for Apple's new Arm-based Macs
Date: Wed, 20 Jan 2021 20:14:56 -0500

> On Jan 20, 2021, at 11:26 AM, Anton Ertl <anton@mips.complang.tuwien.ac.at> 
> wrote:
> 
> On Wed, Jan 20, 2021 at 10:07:10AM -0500, Craig Treleaven wrote:
>> 
>>> On Jan 19, 2021, at 6:08 PM, Anton Ertl <anton@mips.complang.tuwien.ac.at> 
>>> wrote:
>>> 
>>> On Tue, Jan 19, 2021 at 02:42:10PM -0500, Craig Treleaven wrote:
>>>> Hi:
>>>> 
>>>> I contribute a little to the MacPorts project.  MacPorts packages many, 
>>>> many open source software titles for use on Macintosh.  I noticed that 
>>>> Gforth failed to build on our new buildbot running on an M1 machine(aka 
>>>> Apple’s 64 bit ARM SOC).  The configure phase reported the following error:
>>>> 
>>>> checking build system type... Invalid configuration 
>>>> `arm64-apple-darwin20.1.0': machine `arm64-apple' not recognized
>>>> configure: error: /bin/sh ./config.sub arm64-apple-darwin20.1.0 failed
>>> 
>>> config.sub apparently does not know this architecture under the name
>>> arm64, but instead under the name aarch64.
>>> 
>>>> For a number of years, we’ve invoked configure thusly on Intel 64 
>>>> bit-based Macs:
>>>> 
>>>> ./configure --prefix=/opt/local --build=x86_64-apple-darwin14.5.0 
>>>> 
>>>> I browsed through configure.ac but I have only a rudimentary knowledge of 
>>>> auto tools and couldn’t determine if the “-build” flag was even necessary;
>>> 
>>> If you are not cross-building, you don't need --build.  configure then
>>> looks at the current machine and guesses the machine from that (with
>>> config.guess).
>> 
>> Many thanks for explaining so clearly.
>> 
>> So I’ve tried several different combinations…sorry for the length of this 
>> email.
>> 
>> I’m running these on an older MacBook Pro (Core i7) which identifies thusly:
>> 
>> $ uname -m
>> x86_64
>> $ uname -rs
>> Darwin 14.5.0
>> 
>> Running config.guess gives:
>> 
>> $ ./config.guess
>> i386-apple-darwin14.5.0
>> 
>> If I omit the build flag, configure says (in part):
>> 
>> ./configure --prefix=/opt/local
>> ...
>> checking build system type... i386-apple-darwin14.5.0
>> checking host system type... i386-apple-darwin14.5.0
> 
> Ok, config.guess will only produce one architecture on a
> multi-architecture machine, and you have to set up the other variants
> manually.
> 
>> Check for arch/386//gforth.ld (false)
> 
> Don't worry about gforth.ld.
> 
>> But it fails testing:
>> 
>> --- ./test/coretest.out      2013-10-11 17:31:28.000000000 -0400
>> ***************
>> *** 1,10 ****
>> ! redefined {  
>> ! 
>> ! Floating point exception: 8.
>> ! INCORRECT RESULT: { -1 S>D 1 FM/MOD -> 0 -1 }
>> ! INCORRECT RESULT: { -2 S>D 1 FM/MOD -> 0 -2 }
>> ! INCORRECT RESULT: { 1 S>D -1 FM/MOD -> 0 -1 }
>> ! INCORRECT RESULT: { 2 S>D -1 FM/MOD -> 0 -2 }
>> ! INCORRECT RESULT: {  7 S>D -3 FM/MOD -> -2 -3 }
>> ! INCORRECT RESULT: { -7 S>D  3 FM/MOD -> 2 -3 }
>> ! INCORRECT RESULT: { -7 S>D -3 FM/MOD -> -1 2 }
>> --- 1,17 ----
>> ! redefined {  redefined GDX  YOU SHOULD SEE THE STANDARD GRAPHIC CHARACTERS:
>> !  !"#$%&'()*+,-./0123456789:;<=>?@
>> ! ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
>> ! abcdefghijklmnopqrstuvwxyz{|}~
>> ! YOU SHOULD SEE 0-9 SEPARATED BY A SPACE:
>> ! 0 1 2 3 4 5 6 7 8 9 
>> ! YOU SHOULD SEE 0-9 (WITH NO SPACES):
>> ! 0123456789
>> ! YOU SHOULD SEE A-G SEPARATED BY A SPACE:
>> ! A B C D E F G 
>> ! YOU SHOULD SEE 0-5 SEPARATED BY TWO SPACES:
>> ! 0  1  2  3  4  5  
>> ! YOU SHOULD SEE TWO SEPARATE LINES:
>> ! LINE 1
>> ! LINE 2
>> ! you should see this first. 
>> ! you should see this later. 
>> make[3]: *** [checkone] Error 1
> 
> That should not happen.  One theory is that you actually compile for
> AMD64, but due to the i386 setting get some 386-specific setup (in
> particular the multiplication and division instructions), and these
> then don't work.  If that is the case, you may have to tell the
> compiler to use -m32 (at least if it's gcc; clang usually understands
> the same options, but I am not sure).  Or alternatively tell configure
> to configure for amd64:
> 
>> If I set the build flag to x86_64 on my machine, Gforth configures and 
>> builds OK and passes all tests.  Configure says:
>> 
>> ./configure --prefix=/opt/local --build=x86_64 
>> ...
>> checking build system type... x86_64-pc-none
>> checking host system type... x86_64-pc-none
>> Check for arch/amd64//gforth.ld (false)
>> 
>> 
>> Unless you have a better solution, it appears we need to keep adding the 
>> build flag to configure.  
> 
> An alternative may be to get a more recent config.guess (from the
> autotools).
> 

Aha!  Our automake package has an up-to-date copy of config.guess that gives a 
better answer:

$ /opt/local/share/automake-1.16/config.guess
x86_64-apple-darwin14.5.0

>> Re the arm-based macs, configure does not seem to like aarch64:
>> 
>> ./configure --prefix=/opt/local --build=aarch64 
>> …
>> checking build system type... Invalid configuration `aarch64': machine 
>> `aarch64' not recognized
>> configure: error: /bin/sh ./config.sub aarch64 failed
> 
> I found that you use gforth 0.7.3, which has a fairly old config.guess
> and config.sub, which don't know aarch64 yet.  One option is to
> replace them with newer versions.  An alternative is to tell configure
> that you use a machine that config.sub knows and that gforth-0.7.3 has no
> special support for, e.g.:
> 
> configure --build=vax-apple-darwin14.5.0
> 
> Alternatively, you could also try a recent Gforth development snapshot
> from
> 
> https://www.complang.tuwien.ac.at/forth/gforth/Snapshots/current/
> 
> These have config.sub that know about aarch64, and they have special
> support for aarch64.
> 
>> If I pass just “-build=arm”, configure at least completes without error.
> 
> It then builds a version that tries to use dynamic native code
> generation without having the necessary cache consistency support;
> using --build=vax should disable dynamic native code generation.
> Alternatively, Gforth development snapshots know how to deal with
> aarch64.

At MacPorts, we strongly prefer to build from a release tarball.  Is there any 
chance that a new version of Gforth will be released soon?

The good news is that Gforth 0.7.3 built successfully and passed all tests on 
the arm-based Mac buildbot [1].  The configure step said:

checking build system type... arm-unknown-none
checking host system type... arm-unknown-none
configure: WARNING: No I-cache flush code known, disabling dynamic native code 
generation

[1] 
https://build.macports.org/builders/ports-11_arm64-builder/builds/9723/steps/install-port/logs/stdio

As you noted, configure wasn’t happy about dynamic native code generation.  I 
will try substituting ‘vax’ for ‘arm'.

Re MACOSX_DEPLOYMENT_TARGET, I see that the Gforth development version sets 
this to “10.10” [2].  This is normally used to specify the minimum OS version 
that is needed to support your package.  I don’t know about whatever issue 
there is with libtool but it seems to me that Gforth has no special OS 
requirements.  MacPorts tries to provide some support for PPC Macs running 10.5.

[2] https://git.savannah.gnu.org/cgit/gforth.git/tree/configure.ac#n930

Thanks again for the prompt and detailed answers to my questions!

Craig




reply via email to

[Prev in Thread] Current Thread [Next in Thread]