Sign in Join

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

Mailing lists / fpc-pascal / 2020-01

Best start point for adding new FPC target

11 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Fabio Luis Girardi

Hi all!

I'm studying how to add a new target for the Freepascal compiler. The target is the missing armhf-FreeBSD. So I have looked at FPC guide ( https://wiki.freepascal.org/Porting_Free_Pascal#Adding_a_new_target) and looking at Overview section, item 2 says:

"Take the closest existing RTL as a start, copy it and start implementing"

I was thinking of starting with armhf-netbsd, that can I suppose to be the closest to the armhf-freebsd target. I'm right? Someone experienced adding new targets for FPC has another suggestion?

The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Yuriy Sydorov
to Fabio Luis Girardi
Fabio Luis Girardi wrote 8 lines
I'm studying how to add a new target for the Freepascal compiler. The target is the missing armhf-FreeBSD. So I have looked at FPC guide (https://wiki.freepascal.org/Porting_Free_Pascal#Adding_a_new_target) and looking at Overview section, item 2 says: "Take the closest existing RTL as a start, copy it and start implementing" I was thinking of starting with armhf-netbsd, that can I suppose to be the closest to the armhf-freebsd target. I'm right? Someone experienced adding new targets for FPC has another suggestion?

You need to add support of a new CPU to the existing freebsd target. The target would be arm-freebsd, since armhf is not treated as a separate CPU by FPC. You need to create arm startup files in the rtl/freebsd/arm folder.

Yuriy.

Reply by email

Fabio Luis Girardi
to Yuriy Sydorov
Yuriy Sydorov wrote 5 lines
You need to add support of a new CPU to the existing freebsd target. The target would be arm-freebsd, since armhf is not treated as a separate CPU by FPC. You need to create arm startup files in the rtl/freebsd/arm folder.

Yes, I know. But to add this new CPU support for the FPC/FreeBSD, it is better I start with files of rtl/freebsd/i386 or rtl/freebsd/x86_64 or use another start point, like rtl/netbsd/arm ?

The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Yuriy Sydorov
to Fabio Luis Girardi
Fabio Luis Girardi wrote 9 lines
Em ter., 28 de jan. de 2020 às 16:04, Yuriy Sydorov < > escreveu: You need to add support of a new CPU to the existing freebsd target. The target would be arm-freebsd, since armhf is not treated as a separate CPU by FPC. You need to create arm startup files in the rtl/freebsd/arm folder. Yes, I know. But to add this new CPU support for the FPC/FreeBSD, it is better I start with files of rtl/freebsd/i386 or rtl/freebsd/x86_64 or use another start point, like rtl/netbsd/arm ?

The primary goal of a startup code is to get pointers to the command line parameters and the environment block. If arm-freebsd uses the stack to pass these pointers (the same way as i386-freebsd), then you need just to convert the i386 startup assembly to the arm assembly.
For start you need only the prt0.as file.

Yuriy.

Reply by email

Fabio Luis Girardi
to Yuriy Sydorov

Thanks for the hints!

Yuriy Sydorov wrote 27 lines
On 28.01.2020 21:14, Fabio Luis Girardi via fpc-pascal wrote: > Em ter., 28 de jan. de 2020 às 16:04, Yuriy Sydorov < > escreveu: > > You need to add support of a new CPU to the existing freebsd target. The target would be arm-freebsd, since armhf is > not > treated as a separate CPU by FPC. You need to create arm startup files in the rtl/freebsd/arm folder. > > > Yes, I know. But to add this new CPU support for the FPC/FreeBSD, it is better I start with files of rtl/freebsd/i386 or > rtl/freebsd/x86_64 or use another start point, like rtl/netbsd/arm ? The primary goal of a startup code is to get pointers to the command line parameters and the environment block. If arm-freebsd uses the stack to pass these pointers (the same way as i386-freebsd), then you need just to convert the i386 startup assembly to the arm assembly. For start you need only the prt0.as file. Yuriy. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Marco van de Voort
to Fabio Luis Girardi: Hi all! I'm studying how to add a new target for the Freepascal compiler. The target is…

Op 28/01/2020 om 18:08 schreef Fabio Luis Girardi via fpc-pascal:

Show quoted text 13 lines
Hi all! I'm studying how to add a new target for the Freepascal compiler. The target is the missing armhf-FreeBSD. So I have looked at FPC guide (https://wiki.freepascal.org/Porting_Free_Pascal#Adding_a_new_target) and looking at Overview section, item 2 says: "Take the closest existing RTL as a start, copy it and start implementing" I was thinking of starting with armhf-netbsd, that can I suppose to be the closest to the armhf-freebsd target. I'm right? Someone experienced adding new targets for FPC has another suggestion?

That was written from the perspective of a new OS.

For adding a new architecture to an existing OS, probably the files systems/i_bsd.pas and t_bsd.pas are the main files.

A record with settings needs to be added to i_bsd and the calling of assembler and linker needs to be checked in t_bsd.

Reply by email

Florian Klämpfl
to Yuriy Sydorov: The primary goal of a startup code is to get pointers to the command line parameters and…
Yuriy Sydorov wrote 21 lines
On 28.01.2020 21:14, Fabio Luis Girardi via fpc-pascal wrote: > Em ter., 28 de jan. de 2020 às 16:04, Yuriy Sydorov < > > escreveu: > >     You need to add support of a new CPU to the existing freebsd > target. The target would be arm-freebsd, since armhf is >     not >     treated as a separate CPU by FPC. You need to create arm startup > files in the rtl/freebsd/arm folder. > > > Yes, I know. But to add this new CPU support for the FPC/FreeBSD, it > is better I start with files of rtl/freebsd/i386 or rtl/freebsd/x86_64 > or use another start point, like rtl/netbsd/arm ? The primary goal of a startup code is to get pointers to the command line parameters and the environment block. If arm-freebsd uses the stack to pass these pointers (the same way as i386-freebsd), then you need just to convert the i386 startup assembly to the arm assembly. For start you need only the prt0.as file.

I strongly recommend to create pascal startup files for newly added targets.

Reply by email

Karoly Balogh (Charlie/SGR
to Fabio Luis Girardi: Hi all! I'm studying how to add a new target for the Freepascal compiler. The target is…

Hi,

Fabio Luis Girardi wrote
I was thinking of starting with armhf-netbsd, that can I suppose to be the closest to the armhf-freebsd target. I'm right? Someone experienced adding new targets for FPC has another suggestion?

Well, you don't need to clone the entire RTL for just porting the thing to a different CPU architecture, if the OS support is already there, so I wouldn't follow that advice. And I'd just extend the existing FreeBSD RTL and for that, I could use the NetBSD one. They're heavily overlap anyway.

However, you need to add the new target it to the build system, and the compiler, which is quite complicated, as a system ID and various properties have to be added to quite a few places (compiler, /systems/t_bsd.pas, systems.pas, ppudump, FPMake and FPCMake, then regenerate all the Makefiles...) So it's quite an undertaking, not really feasible for submitting a simple patch. However, if you want I can assist in that part, so you can just iterate on the RTL, by having a working compiler already.

BTW the NetBSD/ARMHF port (by me, if I'm correct), was never really working fully, because I was too lazy to figure out some things, like the usual "always broken on BSD" differences in the stat structure, and how some syscalls have changed.

But maybe it's a time to figure out what's up with that. I still have the required NetBSD setup for that anyway.

Charlie

Reply by email

Karoly Balogh (Charlie/SGR
to Florian Klämpfl: I strongly recommend to create pascal startup files for newly added targets.

Hi,

Florian Kl?mpfl wrote 7 lines
> The primary goal of a startup code is to get pointers to the command > line parameters and the environment block. If arm-freebsd uses the stack > to pass these pointers (the same way as i386-freebsd), then you need > just to convert the i386 startup assembly to the arm assembly. > For start you need only the prt0.as file. I strongly recommend to create pascal startup files for newly added targets.

There was some extra section on BSDs identifying which syscall version the binary uses, and some other stuff, IIRC. Which makes it difficult to add a Pascal startup code. But the assembly part can be minimized indeed. Not sure if that can be added by the internal assembler. Probably it can be generated by the compiler though?

Also there was some other thing with weak references I don't remember.

Charlie

Reply by email

Sven Barth
to Karoly Balogh (Charlie/SGR: Well, you don't need to clone the entire RTL for just porting the thing to a different…

Karoly Balogh (Charlie/SGR) schrieb am Mi., 29.
Jan. 2020, 01:22:

Show quoted text 9 lines
However, you need to add the new target it to the build system, and the compiler, which is quite complicated, as a system ID and various properties have to be added to quite a few places (compiler, /systems/t_bsd.pas, systems.pas, ppudump, FPMake and FPCMake, then regenerate all the Makefiles...) So it's quite an undertaking, not really feasible for submitting a simple patch. However, if you want I can assist in that part, so you can just iterate on the RTL, by having a working compiler already.

As a little anecdote: submitting a patch for a new target was exactly how I have started (and it was a completely new target, so more changes), so I wouldn't say that this isn't feasible for a patch ;) ( https://bugs.freepascal.org/view.php?id=14886 )

Regards,
Sven

Reply by email

Mgr. Janusz Chmiel
to Sven Barth

Dear specialists,
Does somebody of you know, if it would be possible to build functional Android app from PPCJVM created .class files which will not depend on App compat jar library?
I have found two fully functional solutions, which do not used appcompat library.
Scatter on GOogle Play named create Android apps and one Termux project, which have been created by MR Sdrausty. It build .apk packages with minimal dependencies and fully functional, .dex sizes can be 40 100 KB, ETC.

But unfortunately, there is very very few projects, which can build .dex files from .class files, which have been created by Free Pascal compiler. My goal is to reduce memory allocations and increase GUI speed while touching screen with Android accessibility suite. I believe, that if resulting app have minimal dependencies, it allocates less memory and its GUI responsiveness can be much more faster.
Mr Sven Bard have created one functional app several ayears ago. it was metro organizer app.
It is very sad, that nobody have released good Android app builder which is based on PPCJVM, it would allow developers to create very small applications.

Reply by email