[fpc-devel] MIPS big-endian program starts but does nothing

Marco van de Voort marcov at stack.nl
Tue Sep 9 13:44:13 CEST 2014

In our previous episode, Mark Morgan Lloyd said:
> > Your observation reduces to letting the compiler figuring out that in the
> > system unit initialization the FPU Initialization can be safely skipped, and
> > that possible state (like the FPU control word) is not important.
> > 
> > This is nearly impossible.
> In fairness, my original question was "Could a completely empty program 
> be recognised by the compiler etc. as a special case". So what you're 
> saying- entirely fairly- is that because of the "Uses System" the 
> problem is probably intractable.

No, not really. The problem is that the system unit (including its
initializer routine) is already available precompiled. Even if you have a
detection, there is no possibility with current formats to walk through the
initialization and say "yes, do this, but not do that".

The linker works purely on sections refering sections, and that
initialization is a section. Probably the initialization of the system unit
should be converted to some table that can somehow be reduced by the linker
or generated by the compiler while compiling the main program, when all
caveats are known.
> But could the "Uses system" be omitted or replaced by a simpler stub if 
> the program was recognised to be trivial?

Multiple RTLs is another solution yes. But when the compiler reaches
"begin..end" the system unit is already loaded, so that's too late, so you
would  have to force that on the commandline or with a $directive before the
uses.  Then we might as well pass a different RTL path (with -n -Fu)
directly instead of making special allowances and detections.

And at that point it basically reduces to what is currently done when
porting, simply commenting the offending lines in system during initial
porting.  A whole lot easier :-)

More information about the fpc-devel mailing list