Sign in Join

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

Mailing lists / fpc-devel / 2015-03

FPC programs in OSv

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner

Hi,

For those who don't know: OSv is an operating system running Linux "applications" in a mini VM.

I was able to write and run a fpc hello-world program. I created a wiki page for this with all the details:
http://wiki.lazarus.freepascal.org/Free_Pascal_on_OSv

The "applications" are dynamic libs (ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked) with a 'main' function. I had to cheat a bit. Calling the FPC init crashes badly. So I disabled that.
The OSv people claim, that any "normal" Linux lib works, except for syscall and fork. They prefer libc.
The standard Linux System unit uses syscalls.

Can you give me some advice how to proceed from here? How can I make the System unit use libc calls instead of the syscalls?

Mattias

Reply by email

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote
How can I make the System unit use libc calls instead of the syscalls?

In theory: by compiling the RTL with -dFPC_USE_LIBC. In practice, this is barely tested on Linux because no one uses it there. Sven has been working a little on it lately, but I don't know if he already committed all of his changes.

Jonas

Reply by email

Sven Barth
to Jonas Maebe
"Jonas Maebe" wrote 9 lines
On 04/03/15 15:47, Mattias Gaertner wrote: > How can I make the System unit use libc calls instead of the syscalls? In theory: by compiling the RTL with -dFPC_USE_LIBC. In practice, this is barely tested on Linux because no one uses it there. Sven has been working a little on it lately, but I don't know if he already committed all of his changes.

I haven't found the time yet. Maybe tomorrow. :)
@Matthias: it might be that cycling the compiler fails on current Linux systems if you specify that define (it does at least on my up to date ArchLinux systems). My outstanding commit fixes this.

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 15 lines
Am 04.03.2015 16:20 schrieb "Jonas Maebe" : > > On 04/03/15 15:47, Mattias Gaertner wrote: > > > How can I make the System unit use libc calls instead of the syscalls? > > In theory: by compiling the RTL with -dFPC_USE_LIBC. In practice, this > is barely tested on Linux because no one uses it there. Sven has been > working a little on it lately, but I don't know if he already committed > all of his changes. I haven't found the time yet. Maybe tomorrow. :) @Matthias: it might be that cycling the compiler fails on current Linux systems if you specify that define (it does at least on my up to date ArchLinux systems).

Yes, it fails:
/home/mattias/3.1.1/fpc/compiler/ppc1 -Ur -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix -Fix86_64 -FE. -FU/home/mattias/pascal/fpc_sources/3.1.1/fpc/rtl/units/x86_64-linux -Cg -g -dFPC_USE_LIBC -dx86_64 -dRELEASE ../inc/fpintres.pp Fatal: No source file name in command line

My outstanding commit fixes this.

Outstanding! :)

Mattias

Reply by email

Mattias Gaertner
to Mattias Gaertner
Show quoted text 8 lines
On Wed, 4 Mar 2015 16:41:23 +0100 Sven Barth wrote: [...] > > In theory: by compiling the RTL with -dFPC_USE_LIBC. [...] > My outstanding commit fixes this. Outstanding! :)

Now (30159) it fails with:

/home/mattias/3.1.1/compiler/ppc1 -Ur -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix -Fix86_64 -FE. -FU/home/mattias/3.1.1/rtl/units/x86_64-linux -Cg -dFPC_USE_LIBC -dx86_64 -dRELEASE -Us -Sg system.pp
system.pp(34,2) Fatal: Cannot open include file "sysunixh.inc"

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 16 lines
On Wed, 4 Mar 2015 17:32:41 +0100 Mattias Gaertner wrote: > On Wed, 4 Mar 2015 16:41:23 +0100 > Sven Barth wrote: > [...] >>> In theory: by compiling the RTL with -dFPC_USE_LIBC. > [...] >> My outstanding commit fixes this. > > Outstanding! :) Now (30159) it fails with: /home/mattias/3.1.1/compiler/ppc1 -Ur -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix -Fix86_64 -FE. -FU/home/mattias/3.1.1/rtl/units/x86_64-linux -Cg -dFPC_USE_LIBC -dx86_64 -dRELEASE -Us -Sg system.pp system.pp(34,2) Fatal: Cannot open include file "sysunixh.inc"

Yes, it fails randomly, because the parameters can not be parsed correctly (some of the passed arguments are randomly missing). I've now finally committed my fix in r30160 which also allows the usage of FPC binaries on OSv (which had originally been the reason I investigated this... but it seems my procrastination took the better of me ^^)

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 6 lines
[...] Yes, it fails randomly, because the parameters can not be parsed correctly (some of the passed arguments are randomly missing). I've now finally committed my fix in r30160 which also allows the usage of FPC binaries on OSv (which had originally been the reason I investigated this... but it seems my procrastination took the better of me ^^)
I get:
/home/mattias/3.1.1/fpc/compiler/ppc1 -Ur -Xs -O2 -n -Fux86_64 -Fusystems -Fu/home/mattias/3.1.1/fpc/rtl/units/x86_64-linux -Fix86_64 -FE. -FUx86_64/units/x86_64-linux -Cg -dRELEASE -dFPC_USE_LIBC    -dx86_64 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pas
pp.pas(247,1) Warning: "crtbeginS.o" not found, this will probably cause a linking failure
pp.pas(247,1) Warning: "crtendS.o" not found, this will probably cause a linking failure
/usr/bin/ld: warning: ./link.res contains output sections; did you forget -T?
pp.pas(247,1) Fatal: There were 2 errors compiling module, stopping

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 16 lines
On Tue, 10 Mar 2015 19:34:59 +0100 Sven Barth wrote: > [...] > Yes, it fails randomly, because the parameters can not be parsed > correctly (some of the passed arguments are randomly missing). I've now > finally committed my fix in r30160 which also allows the usage of FPC > binaries on OSv (which had originally been the reason I investigated > this... but it seems my procrastination took the better of me ^^) I get: /home/mattias/3.1.1/fpc/compiler/ppc1 -Ur -Xs -O2 -n -Fux86_64 -Fusystems -Fu/home/mattias/3.1.1/fpc/rtl/units/x86_64-linux -Fix86_64 -FE. -FUx86_64/units/x86_64-linux -Cg -dRELEASE -dFPC_USE_LIBC -dx86_64 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pas pp.pas(247,1) Warning: "crtbeginS.o" not found, this will probably cause a linking failure pp.pas(247,1) Warning: "crtendS.o" not found, this will probably cause a linking failure /usr/bin/ld: warning: ./link.res contains output sections; did you forget -T? pp.pas(247,1) Fatal: There were 2 errors compiling module, stopping

For me those two are in /usr/lib/gcc/i686-pc-linux-gnu/4.9.2 (for you it might be different, especially if you compile for x86_64) so you need to add that path using -Fl...

Regards,
Sven

Reply by email