[fpc-devel] AArch64 port committed to svn trunk

Jonas Maebe jonas.maebe at elis.ugent.be
Sat May 9 12:31:48 CEST 2015


On 09/05/15 11:16, Edmund Grimley Evans wrote:

> After a while it objects to a missing aarch64/prt0.as, but it has
> already made compiler/ppcrossa64. Naturally, this is still a Darwin
> compiler:
>
> $ compiler/ppcrossa64 /dev/null 
> Free Pascal Compiler version 3.1.1 [2015/05/09] for aarch64
> Copyright (c) 1993-2015 by Florian Klaempfl and others
> Target OS: Darwin for AArch64

Note that while the compiler binary always only supports one target
architecture (or sometimes even sub-architecture, like with
ARMEL/ARMEL-HF), it always supports all targets OSes for that given
(sub-)architecture. The default target OS is normally explicitly set to
be the same as host OS (if the target architecture is supported on the
host OS). As you noticed, for AArch64 since there is only support for
Darwin right now, it's always Darwin though.

> Now I think this might be because of the code in compiler/systems.pas
> with the comment "change to Linux" ... so I do that, and I add
> system_aarch64_linux to the list in compiler/systems.inc. (Note, by
> the way, that "{ 85 }" occurs twice in that file. Is that a bug?)

It's indeed a copy/paste error, although won't have any effect ("{ }" is
equivalent to "/* */" in C).

> Now I get:
> 
> $ compiler/ppcrossa64 /dev/null 
> Fatal: Internal error 2004121202

That means the compiler is trying to create a compiler define with an
empty name. It may indeed be related to the target OS not being properly
set or registered, as the compiler will define a system with the target
OS name. Including correct versions of the revisions mentioned below
will probably solve that.

> Now this is perhaps not surprising as I know I have to modify
> compiler/systems/i_linux.pas and compiler/systems/t_linux.pas,
> presumably by analogy with [it]_bsd.pas,

You indeed have to include the equivalents of
http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=29877 (in
i_linux.pas) and
http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=29897 (in
t_linux.pas).

In case of the i_linux.pas changes, make sure to change the name,
shortname, flags, unit_env, extradefines, sharedlibext and all other
settings mentioning either bsd, macho, darwin to something that's the
same as for other Linux targets in the i_linux.pas file. Also use
abi_default rather than abi_aarch64_darwin.

For t_linux.pas, you will need more changes, because we currently
(wrongly/superfluously) include the entire target linker script in the
compiler for that OS (even when using the external linker), slightly
modified to add the .fpc section. You can get the linker script via
"aarch64-linux-gnu-ld --verbose" (without any other parameters).

> but I find I can put whatever
> I like in those files bracketed with {$ifdef aarch64} or {$ifdef
> cpuaarch64} and it has no effect because those symbols are never
> defined there, it seems.

Code bracketed with {$ifdef aarch64} is included if you are compiling a
compiler that targets AArch64, regardless of the host architecture.

Code bracketed with {$ifdef cpuaarch64} is included if you are compiling
a compiler that is hosted on AArch64, regardless of its target
architecture (or in general: if you are compiling code for AArch64).

> (I haven't modified compiler/aarch64/agcpugas.pas yet, but I don't
> think I've got that far yet, and those symbols are not mentioned in
> that file.)

Indeed.


Jonas



More information about the fpc-devel mailing list