Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-01

Unicode RTL for FPC

20 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

I'm currently working for a company (Tixeo.com) that is preparing to use FPC to recompile their flagship product (written in Delphi) for certain targets.

As part of this work, we're striving to make the Free Pascal RTL and Packages more compatible with recent Delphis.

That means:

- String = UnicodeString, Char=WideChar
- Dotted units.

Before you all get a heart attack:

Because backwards compatibility is important, FPC will of course continue to distribute a backwards-compatible RTL and packages, with single-byte string. All FPC modes will continue to function.

To make this possible a feature called 'subtargets' has been implemented. This can be used for other things than the unicode RTL, but will be used for the unicode RTL.

The RTL is compiled 'normally' and with subtarget=unicodertl;
this will result in 2 separate sets of .o/.ppu files:

The normal CPU-OS directory and a CPU-OS-unicodertl directory.

The first part of the work has been pushed to gitlab in a branch called unicodertl (NOT the svn/unicodertl branch):

- subtarget support is there
- The rtl compiles with make SUB_TARGET=unicodertl with the compiler as it is in that branch.

Needless to say, this is a major change that will need thorough testing.

The earlier testing starts, the better.

For those that wish to help in testing:

- Update your git clone

- switch to branch unicodertl.

- in the toplevel FPC directory, do a

make all

- if that went well, next to your fpc.cfg, create a file fpc-unicodertl.cfg with the following contents:

----
-dUNICODERTL
-Municodestrings
----

- to create a Unicode RTL, in the rtl directory do a

make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler

- if that worked, you can try then a

make install SUB_TARGET=unicodertl

Note that this is NOT ready for production use:

- The packages have not yet been converted (working on this now) and will certainly fail...
- a private testsuite has been run and gives no failures, but the complete compiler testsuite still needs to be examined.
- Dotted names will be created after the unicode transition is deemed complete.

if you do wish to test and spot errors in the RTL or compiler, please file a bugreport.

You can use a tag 'UnicodeRTL' to report bugs for this.

Michael.

Reply by email

Adriaan van Os
to Michael Van Canneyt
Michael Van Canneyt wrote
- String = UnicodeString, Char=WideChar

UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16 and UTF-8 Some marketing people, not understanding anything about computers, talk about "Unicode" to mean "UTF-16-treated-as-UCS-2".

For me, UTF-16 is the dumbest thing ever invented in computing. So I shiver at the thought of a "Unicode" RTL.

We really should use UTF-8, as most open source projects do.

Regards,

Adriaan van Os

Reply by email

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote 13 lines
Michael Van Canneyt via fpc-devel wrote: > - String = UnicodeString, Char=WideChar UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16 and UTF-8 Some marketing people, not understanding anything about computers, talk about "Unicode" to mean "UTF-16-treated-as-UCS-2". For me, UTF-16 is the dumbest thing ever invented in computing. So I shiver at the thought of a "Unicode" RTL. We really should use UTF-8, as most open source projects do.

There will be two RTLs: the current one (which supports any single-byte code page, including utf-8), and a unicode/utf-16 one for compatibility with recent Delphi versions.

Jonas

Reply by email

Marco van de Voort
to Adriaan van Os: UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16…
Adriaan van Os wrote 5 lines
Michael Van Canneyt via fpc-devel wrote: > - String = UnicodeString, Char=WideChar UnicodeString ? ? I don't know what that is supposed to be.

It is named after Microsofts use of the word unicode. Which was originally UCS2,  but morphed into UTF16 in later versions.

The reason however is Embarcadero's adaptation of it in Delphi.

For the encoding advocacy, these discussions were already held in 2009-2010. Let's not have them again.

Reply by email

Wagner Landgraf
to Adriaan van Os: UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16…
Show quoted text 9 lines
Michael Van Canneyt via fpc-devel wrote: > - String = UnicodeString, Char=WideChar UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16 and UTF-8 Some marketing people, not understanding anything about computers, talk about "Unicode" to mean "UTF-16-treated-as-UCS-2". For me, UTF-16 is the dumbest thing ever invented in computing. So I shiver at the thought of a "Unicode" RTL. We really should use UTF-8, as most open source projects do.

That’s what it’s going to be, if I understood correctly. “Unicode” string (UTF-16) will be an option in addition to UTF-8.

Reply by email

Michael Van Canneyt
to Adriaan van Os: UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16…
Adriaan van Os wrote 10 lines
Michael Van Canneyt via fpc-devel wrote: > - String = UnicodeString, Char=WideChar UnicodeString ? ? I don't know what that is supposed to be. We have UCS-2, UCS-4, UTF-16 and UTF-8 Some marketing people, not understanding anything about computers, talk about "Unicode" to mean "UTF-16-treated-as-UCS-2". For me, UTF-16 is the dumbest thing ever invented in computing. So I shiver at the thought of a "Unicode" RTL.

Seems my warning to prevent heart attacks was on its place but maybe not entirely effective :-)

Relax, no-one will force you to use UTF16.

But there are people that do not have the luxury of choice, and we should be kind to them too.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt: I'm currently working for a company (Tixeo.com) that is preparing to use FPC to recompile…

On Fri, 6 Jan 2023 18:05:43 +0100 (CET)
Michael Van Canneyt via fpc-devel

[...] For those that wish to help in testing: - Update your git clone

I used a fresh clone.

- switch to branch unicodertl.

I used git checkout unicodertl

- in the toplevel FPC directory, do a make all

I get:

Compiling .../packages/fcl-process/src/process.pp
Compiling .../packages/fcl-process/src/pipes.pp
process.inc(94,23) Error: Incompatible type for arg no. 1: Got "PChar", expected "PWideChar"

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner: On Fri, 6 Jan 2023 18:05:43 +0100 (CET) Michael Van Canneyt via fpc-devel I used a fresh…
Mattias Gaertner wrote 25 lines
On Fri, 6 Jan 2023 18:05:43 +0100 (CET) Michael Van Canneyt via fpc-devel wrote: > [...] > For those that wish to help in testing: > > - Update your git clone I used a fresh clone. > - switch to branch unicodertl. I used git checkout unicodertl > - in the toplevel FPC directory, do a > > make all I get: Compiling .../packages/fcl-process/src/process.pp Compiling .../packages/fcl-process/src/pipes.pp process.inc(94,23) Error: Incompatible type for arg no. 1: Got "PChar", expected "PWideChar"

Lesson:
Always run a toplevel "make all" after even the smallest (no matter how insignificant) change in RTL.

Fixed. Make all works.

Thanks for testing!

Michael.

Reply by email

Sven Barth
to Michael Van Canneyt

Michael Van Canneyt via fpc-devel schrieb
am Sa., 7. Jan. 2023, 12:46:

Show quoted text 34 lines
On Sat, 7 Jan 2023, Mattias Gaertner via fpc-devel wrote: > On Fri, 6 Jan 2023 18:05:43 +0100 (CET) > Michael Van Canneyt via fpc-devel > wrote: > >> [...] >> For those that wish to help in testing: >> >> - Update your git clone > > I used a fresh clone. > >> - switch to branch unicodertl. > > I used git checkout unicodertl > >> - in the toplevel FPC directory, do a >> >> make all > > I get: > > Compiling .../packages/fcl-process/src/process.pp > Compiling .../packages/fcl-process/src/pipes.pp > process.inc(94,23) Error: Incompatible type for arg no. 1: Got "PChar", > expected "PWideChar" Lesson: Always run a toplevel "make all" after even the smallest (no matter how insignificant) change in RTL.

That's my usual modus operandi when working on the RTL or some compiler feature: first make sure that make inside the rtl directory works and then ensure that it also works in the top level.
There have often enough been subtle errors further down the line (good candidate, especially when working with generics, is the rtl-generics package 🙄).

Regards,
Sven

Reply by email

Mattias Gaertner
to Michael Van Canneyt: I'm currently working for a company (Tixeo.com) that is preparing to use FPC to recompile…

On Fri, 6 Jan 2023 18:05:43 +0100 (CET)
Michael Van Canneyt via fpc-devel

[...] - to create a Unicode RTL, in the rtl directory do a make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler

The "make clean" deletes the new compiler.

Storing the compiler/ppcx64 somewhere else and using that gives:

*** The only supported starting compiler version is 3.2.2. You are trying to build with 3.3.1.

Trying to build using fpc 3.2.2 gives:
Error: Illegal parameter: -tunicodertl

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
On Fri, 6 Jan 2023 18:05:43 +0100 (CET) Michael Van Canneyt via fpc-devel wrote: > [...] > - to create a Unicode RTL, in the rtl directory do a > > make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler The "make clean" deletes the new compiler.

You probably executed this in the main directory ?

This command must be executed in the rtl directory (see: "in the rtl directory do a"), to create the unicode RTL.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt: I'm currently working for a company (Tixeo.com) that is preparing to use FPC to recompile…

On Fri, 6 Jan 2023 18:05:43 +0100 (CET)
Michael Van Canneyt via fpc-devel

Show quoted text 8 lines
[...] - to create a Unicode RTL, in the rtl directory do a make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler - if that worked, you can try then a make install SUB_TARGET=unicodertl

It installed under
/usr/lib/fpc/3.2.2/units/x86_64-linux-unicodertl

Instead of
/usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 18 lines
On Fri, 6 Jan 2023 18:05:43 +0100 (CET) Michael Van Canneyt via fpc-devel wrote: > [...] > - to create a Unicode RTL, in the rtl directory do a > > make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler > > - if that worked, you can try then a > > make install SUB_TARGET=unicodertl It installed under /usr/lib/fpc/3.2.2/units/x86_64-linux-unicodertl Instead of /usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl

That is because I gave a wrong command-line :/

Should have been

make install SUB_TARGET=unicodertl PP=path/to/the/new/compiler

Sorry about that.

Michael.

Reply by email

Adriaan van Os
to Michael Van Canneyt: Seems my warning to prevent heart attacks was on its place but maybe not entirely…
Michael Van Canneyt wrote 9 lines
Seems my warning to prevent heart attacks was on its place but maybe not entirely effective :-) Relax, no-one will force you to use UTF16. But there are people that do not have the luxury of choice, and we should be kind to them too.

OK. It reminds me of the Turbo assembler, which had a mode to be compatible with the bugs in the Microsoft assembler 😃 😃 .

Regards,

Adriaan van Os

Reply by email

Mattias Gaertner
to Michael Van Canneyt: That is because I gave a wrong command-line :/ Should have been make install…

On Sun, 8 Jan 2023 08:46:37 +0100 (CET)
Michael Van Canneyt via fpc-devel

[...] Should have been make install SUB_TARGET=unicodertl PP=path/to/the/new/compiler

This does not install the new compiler, so I used the compiler/ppcx64 exe directly to compile a program.

I see in the -va output:
[0.008] Hint: Start of reading config file /etc/fpc-unicodertl.cfg [0.008] Handling option "-dUNICODERTL"
[0.008] Interpreting option "-dUNICODERTL"
[0.008] Macro defined: UNICODERTL
[0.008] Handling option "-Municodestrings"
[0.008] Interpreting option "-Municodestrings"
[0.008] Macro defined: FPC_UNICODESTRINGS
[0.008] Macro defined: UNICODE
[0.008] Hint: End of reading config file /etc/fpc-unicodertl.cfg

But then it uses the wrong unit paths:
[0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux/httpd22/

It should be:

[0.012] Using unit path:
/usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl/rtl/

My /etc/fpc.cfg contains:

# searchpath for units and other system dependent things -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl

Mattias

Reply by email

Tomas Hajny
to Mattias Gaertner
Mattias Gaertner wrote 37 lines
On Sun, 8 Jan 2023 08:46:37 +0100 (CET) Michael Van Canneyt via fpc-devel wrote: > [...] > Should have been > > make install SUB_TARGET=unicodertl PP=path/to/the/new/compiler This does not install the new compiler, so I used the compiler/ppcx64 exe directly to compile a program. I see in the -va output: [0.008] Hint: Start of reading config file /etc/fpc-unicodertl.cfg [0.008] Handling option "-dUNICODERTL" [0.008] Interpreting option "-dUNICODERTL" [0.008] Macro defined: UNICODERTL [0.008] Handling option "-Municodestrings" [0.008] Interpreting option "-Municodestrings" [0.008] Macro defined: FPC_UNICODESTRINGS [0.008] Macro defined: UNICODE [0.008] Hint: End of reading config file /etc/fpc-unicodertl.cfg But then it uses the wrong unit paths: [0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux/httpd22/ It should be: [0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl/rtl/ My /etc/fpc.cfg contains: # searchpath for units and other system dependent things -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl

What does your /etc/fpc-unicodertl.cfg contain? The correct paths should be there...

Tomas

Reply by email

Michael Van Canneyt
to Mattias Gaertner: On Sun, 8 Jan 2023 08:46:37 +0100 (CET) Michael Van Canneyt via fpc-devel This does not…
Mattias Gaertner wrote 30 lines
On Sun, 8 Jan 2023 08:46:37 +0100 (CET) Michael Van Canneyt via fpc-devel wrote: > [...] > Should have been > > make install SUB_TARGET=unicodertl PP=path/to/the/new/compiler This does not install the new compiler, so I used the compiler/ppcx64 exe directly to compile a program. I see in the -va output: [0.008] Hint: Start of reading config file /etc/fpc-unicodertl.cfg [0.008] Handling option "-dUNICODERTL" [0.008] Interpreting option "-dUNICODERTL" [0.008] Macro defined: UNICODERTL [0.008] Handling option "-Municodestrings" [0.008] Interpreting option "-Municodestrings" [0.008] Macro defined: FPC_UNICODESTRINGS [0.008] Macro defined: UNICODE [0.008] Hint: End of reading config file /etc/fpc-unicodertl.cfg But then it uses the wrong unit paths: [0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux/httpd22/ It should be: [0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl/rtl/

I am aware of this one.

This is fixed since some time but not yet pushed.

I will push this change together with many others later today.

I'm busy fixing pas2js resolver failures :-)

All packages compile using unicode meanwhile, json/xml work fine, pas2js for the most part as well, just the resolver needs some work. Down to 3 errors in the testsuite. Coming from over 2000 failures initially :/

Michael.

Reply by email

Michael Van Canneyt
to Tomas Hajny: What does your /etc/fpc-unicodertl.cfg contain? The correct paths should be there... Tomas
Tomas Hajny wrote 41 lines
On 2023-01-13 11:22, Mattias Gaertner via fpc-devel wrote: > On Sun, 8 Jan 2023 08:46:37 +0100 (CET) > Michael Van Canneyt via fpc-devel > wrote: > >> [...] >> Should have been >> >> make install SUB_TARGET=unicodertl PP=path/to/the/new/compiler > > This does not install the new compiler, so I used the compiler/ppcx64 > exe directly to compile a program. > > I see in the -va output: > [0.008] Hint: Start of reading config file /etc/fpc-unicodertl.cfg > [0.008] Handling option "-dUNICODERTL" > [0.008] Interpreting option "-dUNICODERTL" > [0.008] Macro defined: UNICODERTL > [0.008] Handling option "-Municodestrings" > [0.008] Interpreting option "-Municodestrings" > [0.008] Macro defined: FPC_UNICODESTRINGS > [0.008] Macro defined: UNICODE > [0.008] Hint: End of reading config file /etc/fpc-unicodertl.cfg > > But then it uses the wrong unit paths: > [0.012] Using unit path: /usr/lib/fpc/3.3.1/units/x86_64-linux/httpd22/ > > It should be: > > [0.012] Using unit path: > /usr/lib/fpc/3.3.1/units/x86_64-linux-unicodertl/rtl/ > > My /etc/fpc.cfg contains: > > # searchpath for units and other system dependent things > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl What does your /etc/fpc-unicodertl.cfg contain? The correct paths should be there...

Nono, there was an error in calculating $fpctarget. It is fixed.

Michael.

Reply by email

Mattias Gaertner
to Tomas Hajny: What does your /etc/fpc-unicodertl.cfg contain? The correct paths should be there... Tomas
Show quoted text 10 lines
[...] > My /etc/fpc.cfg contains: > > # searchpath for units and other system dependent things > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* > -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl What does your /etc/fpc-unicodertl.cfg contain? The correct paths should be there...

Michael wrote it should contain:

----
-dUNICODERTL
-Municodestrings
----

Adding unitpaths without removing/disabling the wrong ones seems wrong to me.

Mattias

Reply by email