Re: QL / PASCAL
Posted: Sat Dec 12, 2020 11:54 pm
Thanks Chain-Q. I'm reading in bed at the moment (insomnia) but I'll give your fixes/workarounds a proper try soon, and get back to you.
Cheers,
Norm.
Cheers,
Norm.
Ha! Sneaky. At least I still have my uses!mk79 wrote:Au contraire, I had exactly the same problems, but I thought I leave something for you to figure out, too So well done
Most helpful, but highly unlikely I'll be moving things around. Good to know though.Chain-Q wrote: You can actually extend environment variables inside fpc.cfg. So you can replace /home/norman with $HOME$ (note the trailing $) and it will work. Minor thing, but if you move your config files around in several systems, it might help.
Hmmm:Chain-Q wrote:The reason for this is because 8+3 filenames support is enabled for the Sinclair QL, because I based the system descriptor table inside the compiler on the Atari TOS version... And this leads to some inconsistencies if the compiler and the external build process prefers "m68k-sinclairql" or just "sinclairql" as the full name of the target. As a workaround, I changed this in the wiki now, to recommend $fpccpu-$fpcos combination, instead of $fpctarget. This works for now. (I actually tested it now... )
Code: Select all
$ cat ~/fpc-ql/lib/fpc/etc/fpc.cfg
#IFDEF CPUM68K
-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/$fpccpu-$fpcos
-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/$fpccpu-$fpcos/*
-Tsinclairql
#IFDEF SINCLAIRQL
-FD/home/norman/bin
-XPm68k-sinclairql-
-WQxtcc
#ENDIF
#ENDIF
Code: Select all
$ fpc-ql test.pas
Fatal: Can't find unit system used by test
Fatal: Compilation aborted
I honestly don't mind. The QL allows up to 36 characters in a file name, plus 5 more for the device, 8.3 was always a bit limited, even on DOS 3.x! The best answer is probably "what is the standard with other implementations? Do they all get the "CPU-OS" format? If so, stick with "m68k-sinclairql" otherwise, "sinclairql" says it all.Chain-Q wrote:Having said this, what do you think? Should the compiler/build system stick to the shorter version of "sinclairql" or use "m68k-sinclairql" everywhere? The later would require switching the 8+3 short filenames support, but it doesn't really make a difference for now, because the native compiler is still quite far away (if it ever happens), but it would be good to make it consistent at least. I'd prefer the longer version, for consistency with other systems (where no 8+3 unless required), but I also don't have a really strong preference.
Right, let's debug:Chain-Q wrote:Another hint: Debugging config file and path issues is quite easy using the -vv compiler argument. This will write a file called "fpcdebug.txt" into the current directory, which contains human readable verbose information about the config file parsing, telling you what it expands those $foobar templates into, and if it can find the path or not.
Code: Select all
$ fpc-ql -vv test.pas
Fatal: Can't find unit system used by test
Fatal: Compilation aborted
Code: Select all
$view fpcdebug.txt
...
00020000:Handling option "-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/m68k-linux"
...
00008000:Path "/usr/lib/fpc/3.3.1/units/sinclairql/rtl/" not found
...
00008000:Compiler: /home/norman/fpc-ql/lib/fpc/3.3.1/ppcross68k
00020000:Compiler OS: Linux for x86-64
00001000:Target OS: Sinclair QL
...
10000001:Fatal: Can't find unit system used by test
10000001:Fatal: Compilation aborted
Sorry, I wasn't too precise. You have to put -Tsinclairql before any line where these config variables/templates related to the target are resolved. So -Tsinclairql has to be before the -Fu lines. The config file is just resolved/parsed in a linear sequence, and the default target for cross compilers is usually Linux (see below). Hence the -Fu line before -Tsinclairql, which actually switches the target over to the QL will resolve the $fpcos to "linux".NormanDunbar wrote: It's unfortunately, still not working for me. I'll see what the debugger says.
It's nothing to do with your host system, as I wrote, the cross-compilers just tend to default to Linux, because most often that's the target platform we use for compiler testing. The cross-compiler binary itself is OS target agnostic. It can compile for any m68k target. Obviously the native compilers default to their host platforms.NormanDunbar wrote:It's picked up my host operating system, linux, and not the one I'm cross-compiling for, sinclairql.
Ha! Of course, that makes a whole lot of sense when you put it like that! Call it a "senior" moment!Chain-Q wrote:Sorry, I wasn't too precise. You have to put -Tsinclairql before any line where these config variables/templates related to the target are resolved.
Code: Select all
#IFDEF CPUM68K
-Tsinclairql
-Fu/home/norman/fpc-ql/lib/fpc/$fpcversion/units/$fpccpu-$fpcos
-Fu/home/norman/fpc-ql/lib/fpc/$fpcversion/units/$fpccpu-$fpcos/*
#IFDEF SINCLAIRQL
-FD/home/norman/bin
-XPm68k-sinclairql-
-WQxtcc
#ENDIF
#ENDIF
Code: Select all
make clean OS_TARGET=sinclairql CPU_TARGET=m68k
make crossall OS_TARGET=sinclairql CPU_TARGET=m68k
Code: Select all
{ delete a file, given its name}
procedure do_erase(p : pchar; pchangeable: boolean);
begin
Error2InOutRes(io_delet(p));
end;
Code: Select all
function io_delet(name: pchar): longint; external name '_io_delet';
Code: Select all
_IO_DELET = $04;
Code: Select all
function io_delet_qlstr(name_qlstr: pointer): longint; assembler; nostackframe; public name '_io_delet_qlstr';
asm
movem.l d2-d3,-(sp)
move.l name_qlstr,a0
moveq.l #-1,d1
moveq.l #_IO_DELET,d0
trap #2
tst.l d0
@quit:
movem.l (sp)+,d2-d3
end;
Code: Select all
function io_delet(name: pchar): Tchanid; public name '_io_delet';
var
len: longint;
name_qlstr: array[0..63] of char;
begin
len:=length(name);
if len > length(name_qlstr)-2 then
len:=length(name_qlstr)-2;
PWord(@name_qlstr)[0]:=len;
Move(name^,name_qlstr[2],len);
result:=io_delet_qlstr(@name_qlstr);
end;
Code: Select all
cd rtl/sinclairql
make OS_TARGET=sinclairql CPU_TARGET=m68k
Code: Select all
-XPm68k-sinclairql- -Fi../inc -Fi../m68k -Fim68k -FE. -FU../../rtl/units/m68k-sinclairql -dm68k -Us -Sg @rtl.cfg system.pp
Error: ppc68k can't be executed, error message: Failed to execute "ppc68k", error code: 127
make: *** [Makefile:3570: system.ppu] Error 1
Code: Select all
make: -iVSPTPSOTO: Command not found
Code: Select all
make rtl_cleanall
make rtl_all FPC=<path-to-fpc>/compiler/ppcross68k FPMAKE=<path-to-fpc>/compiler/ppc RELEASE=1 OPT= FPCMAKEOPT= OS_TARGET=sinclairql CPU_TARGET=m68k BINUTILSPREFIX=
Code: Select all
make rtl_cleanall
make rtl_all FPC=ppcross68k RELEASE=1 OS_TARGET=sinclairql CPU_TARGET=m68k
Code: Select all
FPMAKE=<path-to-fpc>/compiler/ppc
Code: Select all
{ Program to demonstrate the Erase function. }
Var F : Text;
begin
Assign(F,'test.txt');
Rewrite(F);
Writeln('The file, "test.txt" will be deleted.');
Writeln(F,'Try and find this when I''m finished !');
Close(F);
Erase(F);
end.
Code: Select all
make rtl_install RELEASE=1 OS_TARGET=sinclairql CPU_TARGET=m68k INSTAL_PREFIX=/home/norman/bin
Code: Select all
{ Program to demonstrate the Erase function. }
Var F : Text;
begin
Writeln('The file, "test.txt" will be deleted.');
Assign(F,'test.txt');
Erase(F);
end.