Forum > macOS / Mac OS X
How to set up cross compile to z80?
Cascade:
I’d quite like to try cross-compiling to z80 with FPC/Lazarus, so I need to build the cross-compiler. I’ve cloned the source into GitHub Desktop from:
https://gitlab.com/freepascal.org/fpc/source.git
…and I have a build script from the FreePascal Wiki:
--- Code: ---#!/bin/sh
set -e
FPC_Z80_DIR= ... /some/new/folder
STARTPP= ... /fpc/bin/aarch64-darwin/fpc
BINUTILSPREFIX=
CROSSOPT=-O-1
export CROSSOPT
OPT="-CX -XXs"
if [ -n "$EXTRAOPT" ]
then
OPT+=" $EXTRAOPT"
fi
export OPT
export CPU_TARGET=z80
export OS_TARGET=zxspectrum
export OS_SOURCE=`$STARTPP -iSO`
export CPU_SOURCE=`$STARTPP -iSP`
cd $FPC_Z80_DIR/fpc
alias nproc="sysctl -n hw.logicalcpu"
make -j `nproc` clean PP=$STARTPP BINUTILSPREFIX=$BINUTILSPREFIX
make -j `nproc` all PP=$STARTPP BINUTILSPREFIX=$BINUTILSPREFIX
make -j `nproc` crossinstall PP=$FPC_Z80_DIR/fpc/compiler/ppcrossz80 INSTALL_PREFIX=$FPC_Z80_DIR/zxspectrum-snapshot BINUTILSPREFIX=$BINUTILSPREFIX
--- End code ---
…but after a couple of hours rubbing them both together I’ve yet to see any smoke, let alone fire.
I added an alias to workaround lack of nproc:
alias nproc="sysctl -n hw.logicalcpu" (thank you Google)
STARTAPP is set to …/MyNativeFpc/fpc/bin/aarch64-darwin/fpc - I'm running on an M4 chip, so that's the location of the native fpc compiler previously set up with FpcUpDeluxe - is that correct?
I’ve tried copying and executing the above build script in various folders in the fpc source code, but wherever I put it, it chokes on line 24 with the error:
make: *** No rule to make target 'clean'. Stop.
What should the variable FPC_Z80_DIR be set to? It needs to be a folder containing an 'fpc' subfolder in order to satisfy line 22 of the build script (cd $FPC_Z80_DIR/fpc), so either an existing fpc folder, or a new empty folder for output (?).
Any insight welcome :)
DonAlfredo:
I have added Z80-spectrum into fpcupdeluxe.
Please test.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.4.0ip/fpcupdeluxe-aarch64-darwin-cocoa.zip
Cascade:
That's brilliant - thank you!
I haven't got it to work yet, but I can definitely see the z80 options in the Cross Compiler section of FpcUpDeluxe. FPC Trunk (3.3.1) isn't building for me at the moment, but I guess Trunk will not always build - it doesn't look like an issue with FpcUpDeluxe.
Good news is FPC Fixes (3.2.x) installs fine with FpcUpDeluxe 2.4.0ip - though installing the z80 cross-compiler complains:
--- Code: ---3-1-26 19:14:09: fpcupdeluxe: V511 (20251116) started.
FPCUPdeluxe V2.4.0ip for aarch64-darwin running on macOS 15.7.1
Build with: FPC 3.2.3 on Win11 x86_64
Found valid bsdtar application.
Found valid make application.
fpcupdeluxe: ERROR: FPC Cross Installer (CleanModule: FPC): Makefile does not support z80-zxspectrum as cross-target. Expect errors.
fpcupdeluxe: ERROR: Cross-target not supported by FPC Makefile.
ERROR: Building cross-tools failed. Aborting.
--- End code ---
Could it be that FPC 3.3.1 is minimum version for z80 target support (3.2.x might support z80, but not sure). If that is the issue I might just have to wait a bit for FPC Trunk to stabilise and then try again.
Cascade:
I've found an older version of FPC 3.3.1 already built on my system, so although it's a few months old, I had a go at installing the cross-compiler there. FpcUpDeluxe 2.4.0ip got further then - the errors I'm seeing are:
--- Code: ---/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `…/fpcsrc/compiler/ppcrossz80 -Tzxspectrum -Pz80 -XPz80-zxspectrum- -Ur -Xs -O2 -n -Fi../inc -Fi../z80 -FDError: cross compiler extension must set FBinUtilsPath: the cross compile binutils (as, ld etc). Could be the same as regular path if a binutils prefix is used. -FE. -FU/…/fpcsrc/rtl/units/z80-zxspectrum -CX -XX -Fl/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -vw-n-h-l-d-u-t-p-c- -ap -dz80 -dRELEASE -CX -XX -Us -Sg system.pp'
...
make[2]: *** [system.ppu] Error 2
make[1]: *** [zxspectrum_all] Error 2
make: *** [rtl_all] Error 2
/Library/Developer/CommandLineTools/usr/bin/make -C rtl all
/Library/Developer/CommandLineTools/usr/bin/make -C zxspectrum all
...
fpcupdeluxe: ERROR: FPC Cross Installer (BuildModuleCustom: FPC): Running cross compiler fpc /usr/bin/make for z80-zxspectrum failed with an error code.
ERROR: Fpcupdeluxe fatal error !
Sequencer (FPCCleanBuildOnly): Failure running fpcupdeluxe: error executing sequence FPCCleanBuildOnly
Sequencer (Only): Failure running fpcupdeluxe: error executing sequence Only
ERROR: Building cross-tools failed. Aborting.
--- End code ---
Please let me know if you need more detail - as I've just copied certain lines above that seemed relevant.
Cascade:
Speculation: The unexpected '(' token is because no path is assigned to CROSSBINDIR:
--- Code: ---fpcupdeluxe: info: FPC Cross Installer (BuildModuleCustom: FPC): Executing: make [Rtl Build] (FPC crosscompiler: z80-zxspectrum) with CROSSOPT: -CX -XX.
fpcupdeluxe: Executing: /usr/bin/make RELEASE=1 ... CPU_TARGET=z80 CROSSINSTALL=1 CROSSBINDIR=Error: cross compiler extension must set FBinUtilsPath: the cross compile binutils (as, ld etc). Could be the same as regular path if a binutils prefix is used. BINUTILSPREFIX=...etc...
--- End code ---
CROSSBINDIR=Error: cross compiler extension must set FBinUtilsPath: the cross compile binutils (as, ld etc)
...so a directory path is expected, but instead the parser reads an Error message containing a bracket '('
Navigation
[0] Message Index
[#] Next page