[fpc-devel] Building compiler, rtl, host, target... (cross compiling)
Skybuck Flying
skybuck2000 at hotmail.com
Wed Apr 6 21:54:59 CEST 2011
Hello,
First of all I would like to write that I failed to compile the RTL of Free
Pascal so that might be adding a little bit too the confusion.
(Just simple i386/x86 tests to see if the sources build)
The compiler however seems to compile fine.
I am now a bit confused about the whole theory of things and I will try to
explain my confusion:
The confusion pretty much starts with the compiler needing some RTL includes
and units and especially some types like DWORD or PtrInt to be able to
compile itself ?!?
This is a little bit weird to me: Why would the compiler need an RTL to
compile itself ? (Perhaps these are accidental, or unnecessary depedancy ?)
I am now a bit confused again about what free pascal is...
As far as I can remember I once build a free pascal compiler which would
compile from a certain "host" operating system towards another "target"
operating system.
Is free pascal supposed to be able to do this all naturally by itself (as
long as it can use external tools) ?
I just consulted my little tutorial on building a free pascal cross compiler
which I once wrote and I notice the following things:
It mentions a "cross assembler" and a "cross linker" these where external
GNU related tools.
>From the looks of it I'm thinking right now that "Free Pascal" might
actually not be a cross compiler and it actually can only compile to it's
own platform that the compiler executable was compiled for.
So in other words if this "hypothesis" above is correct then what was
happening at the time might have been the following situation:
1. "Free Pascal" ("fake cross") compiler compiles the source from PPC386.EXE
(i386 host) towards Linux/PowerPC (made up target) as "x86 assembly".
2. The cross-assembler.exe from GNU tools takes the x86 assembly produced by
free pascal compiler and actually "cross-assembles" it for linux/powerpc
into powerpc assembly.
3. The cross-linker does the rest.
So suppose that's how it was working at the time then Free Pascal is
actually not really a "cross compiler".
However this does not mean it's useless for my project/experiments... I need
Free Pascal to be a "cross compiler" which compiles to "abstract assembly"
so I can assemble it further into "any assembler" a true cross compiler I
would say ;)
Perhaps I am wrong and you guys would like to correct me... but for that I
will help you by asking a question:
1. Would it be possible to build the following compiler:
FreePascalCompiler.exe (runs on windows) (compiles for virtual machine
instructions/outputs virtual machine assembly).
Or is a "FreePascalCompiler.exe (x86)" only capable of producing "x86
assembly" like I suspect it might be/do...
Suppose I am correct and free pascal compiler can only compile towards the
target that it itself was compiled for then I have a little problem:
My virtual machine isn't really ment to access files, or serve as an
operating system or be a memory manager or have great capabilities... it's
pretty much ment to execute some simple instructions and that's it...
So what I need is a "free pascal compiler" which was compiled for Windows
environment/executable but which can still compile for a virtual machine.
I was under the impression that free pascal was a true cross compiler and
therefore I was a bit confused about the RTL.... why does the free pascal
compiler need an RTL ?
How do I add a new RTL for another target to the compiler ?!? Is it even
necessary or can it compile without it with a few modifications (me
investigating this ;))
It's all a bit fuzzy...
I think most of my questions where already answered in a previous
posting/reply... people said:
"Nope... free pascal can only compile applications towards it's own
platform/target that it was compiled for..."
If that's indeed correct then that's a bit unfortunate...
But none-the-less I seem some possibilities to make free pascal do what I
want...
I could simply take the i386/x86 version of it with it's internal
assemblers... and then simply convert those internal assemblers towards a
sort of cross-assemblers... which would output "virtual machine assembly".
I'm looking for some clearification and confirmation on these thoughts of
mine so that I understand correctly...
Also a little bit more explanation about the roll of RTL in relation to the
compiler would be nice...
Let me ask a question in relation to that...
Let's suppose I want to compile free pascal compiler and/or RTL for a new
target.. since free pascal can only compile towards it's own target... it
cannot do this correct ?
So to actually "port" pascal towards a new platform would theoretically
require other compilers written for the other platforms ?
So in a way this makes free pascal not "cross-platform-self-hosting" ?
So it's still a bit stuck in it's own world ???
Bye,
Skybuck.
More information about the fpc-devel
mailing list