[Lazarus] Unicode RTL

Michael Van Canneyt michael at freepascal.org
Mon Jul 24 21:49:39 CEST 2023


I have just completed phase one of the "Unicode RTL" effort.

The 'Unicode RTL' is an effort to be more Delphi compatible:
- Char = Unicode Char and String = UnicodeString
- Provide dotted filenames.
Basically closer to the RTL as it exists in more recent versions of Delphi 
(essentially post - Delphi 2009)

This RTL will co-exist with the current RTL (single-byte char, no dotted
names), but will share the same codebase.

More explanations can be found here:


This coexistence of 2 RTLs is accomplished with 'Subtarget support'.

Subtarget support is a means to consistently apply a set of Free Pascal
compiler settings to everything that you compile.

Subtarget support is explained in more detail here:

While it is now used to create a unicode rtl, it could also be used to

* create a llvm-compiled RTL.
* create an rtl with debug info and one without. 
* compile the various Lazarus widgetsets into different directories
* ... any other things you may think of ...

all with a single installation of FPC.

For the second part of the effort, 'provide dotted filenames', the actual
work is finished, but still needs merging to trunk.

This second part is expected to be merged in the next days/weeks.

But today, using FPC trunk, you can now recompile the Free Pascal RTL, 
Packages and Utils (but not the compiler itself!) into a set of units where

Char = UnicodeChar
String = UnicodeString

To compile (and install) the unicode rtl, all you need to do is follow the
steps outlined in


Basically, this means creating a 2-line configuration file for the unicodertl
subtarget, and compiling the RTL, packages and utils with

make SUB_TARGET=unicodertl

For those that need/want more delphi-compatible code, I would love to hear
of your experience with the unicode rtl. I have done extensive testing, but
as practice shows, there will always be cases which defy ordinary test

If the 2 wiki pages need more explanations, please let me know and I will do
my best to improve the explanations.

Hopefully, in the near future the compiler settings dialog in Lazarus will also 
allow you to specify a subtarget.


More information about the lazarus mailing list