[fpc-devel] On a port of Free Pascal to the IBM 370
pascaldragon at googlemail.com
Wed Jan 18 11:36:47 CET 2012
Am 17.01.2012 21:52, schrieb Paul Robinson:
> From: Paul Robinson<paul at paul-robinson.us>
> As has probably been a bit of a scare to some people, I've more-or-less "unofficially announced" by putting up an article on the Free Pascal Wiki regarding how I've decided I am going to work on porting the Free Pascal compiler to the IBM 370 series mainframe, otherwise known as the zSeries. And that, having spoken to a few people here, I've been made aware this has sort of been scary or incredible to some of the other people working on this project because they realize that there is a hell of a lot of work involved and I may not be aware of what I'm up against. I can understand, and I can sympathize with their thoughts.
It's not that I'm scared that you want to tackle this it's more that
I've seen that you based your How-To on assumptions that are wrong or at
least "not good" and wanted to help you in this regard.
> I am aware, first, that this will be a huge undertaking; this is not a weekend project. I'm probably looking at a minimum six months work, possibly longer.
I have not yet started a new CPU target myself (only an OS target), but
I can imagine that you're not that far off with the time needed...
> So anyway, I know there's a lot involved, there will be fits, and starts, and things won't always go right. But it's a learning experience, and, if you follow this as it goes along over the months as it progresses, maybe you'll learn something too.
Well, then let's get started with bringing you on track:
You wrote that you use the source code of FPC 2.6.0 and copied the
"compiler" and "rtl" directories to some other "workplace". I suggest
you to use a SVN checkout of the development version (you can find the
links here: http://www.freepascal.org/develop.var (at "Connect to Source
Repository with SVN")), because than you can more easily revert back
something. Also there were quite a few changes from 2.6.0 to 2.7.1 and
thus it's better to work with the most recent source.
I suggest you to use the Lazarus IDE to do compiler development (you
might use the text mode IDE ("fp") as well, but I myself only use
Lazarus for that). You can then copy one of the project files (*.lpi) in
the compiler directory (e.g. ppi386.lpi) and paste it as "ppi370.lpi".
You can then open this project in Lazarus and adjust the defines (in tab
"Other" replace "-dI386" with "-dI370") and output directory (exchange
"i386/units" with "i370/units") in the project settings. Afterwards you
should be able to compile the compiler using (Ctrl+)F9 (ok, you won't at
first, because you yet need to adjust the source for i370)
I noticed that you wanted to add a unit "i_i370" to the "compiler" unit
and to the directory "systems". This is wrong. The units listed in the
"compiler" unit are the target operating systems (e.g. Windows, Linux,
DOS), not the underlying architecture. Thus you'd only add a "i_osvs1"
(if I remember the name correctly) to that unit and directory, but you
don't need to do this know as you first need to implement the
This architecture support is located in the corresponding CPU unit (e.g.
ARM, PowerPC, i386, x86_64 (the latter two share the x86 directory as
well)) and is included by using the "cputarg" in the unit "compiler".
This unit is located in the corresponding CPU directory. Thus I'd
suggest you to copy the directory of an architecture (e.g. MIPS as this
is a smaller and younger one) and name that "i370" (now the unit output
path I mentioned in "2" will make sense ;) ).
I read in your How-To that you stumpled upon units like "sysutils" and
stubbed them. You don't need to care about these yet. These are only
needed if you compile programs for the target platform which use that
units. The only unit you might want to stub at the beginning is the
"System" unit which is located in $fpcdir/rtl/$target/system.pp (where
$fpcdir is your source directory and $target is one of the supported
targets (e.g. linux, win32, etc.)). The most important part you'll need
there is a function or procedure (depending on the operating system)
which will contain your real entry point (the "begin...end." in a
"program" file is NOT the real entry point, this part is called
"PASCALMAIN" and is called from within the real entry point).
So at the beginning you can mostly concentrate on your "i370" directory
with adding some types here and there (like the assemblertype that you
I myself can't help with porting FPC to a new architecture, as I haven't
done that yet (only to a new operating system target). But AFAIK Mark
Morgan Lloyd worked on the MIPS target and of course there are compiler
developers who implemented new architectures.
Regarding general compiler questions and those regarding the
implementation of a new OS target I might be able to help you, so just
mail to the list and I'll try to see what I can do.
BTW: It might indeed be the best - as suggested by others already - to
first target a Linux system on your architecture as then you can split
the work into "implementing the architecture support" and "implementing
the OS support", because after you've successfully implemented the
architecture support you can of course add other OS targets to your
architecture as well.
More information about the fpc-devel