[fpc-pascal] Compiler internals. Changing dynamic arrays format

Tomas Hajny XHajT03 at hajny.biz
Wed Apr 13 09:44:39 CEST 2022

On 2022-04-13 00:34, denisgolovan via fpc-pascal wrote:

Hi Denis,

> I've been maintaining a set of private patches for some quite old FPC
> revision for some years.
> My first trouble is initialization of dynamic arrays with constant 
> arrays.
> It looks like simply building one version of compiler just makes a
> build with old-style array constants and my already patched code.
> That leads to code/constant data format mismatches and new compiler
> process just crashes.
> Looks vanilla makefile builds a several versions of compiler
> progressing to a final version.
> It seems that my troubles also can be solved by enabling parts of the
> patchset progressively.
> More specifically, I plan to enable array serialization code patch
> first in cyclelevel 1.
> Then build next compiler level using compiler 1 with rest code enabled
> to get cyclelevel 2.
> Cyclelevel2 build should already contain both all code changes and
> data constants in new format.
> And finally build cyclelevel3 build with cyclelevel2 compiler to 
> complete build.
> Is it the right way to go?
> And if I get it right - could anyone suggest me how to enable my
> constants code serialization patches (via conditional defines I guess)
> at cyclelevel 1 and all patches at cyclelevels 2 and 3?

Your comment about conditional defines goes in the right direction - 

1) Separate your changes into parts affecting the compiler behaviour 
(e.g. the changes impacting the compiled structures and code, etc.) from 
changes needed because of the changed behaviour (i.e. use of your new 
features within the RTL and/or the compiler, modified versions of code 
working with the newly / differently compiled structures, etc.).

2) Create a conditional define for your new changes - this new define 
would be enabled within the compiler behaviour affecting changes.

3) Make your changes resulting from the changed behaviour (either in the 
RTL, or in the compiler) enabled only when the new conditional define is 

If you do this, you should be able to use the standard makefiles without 
any changes (e.g. "make compiler_cycle", etc.).


More information about the fpc-pascal mailing list