Hi experts. (Beware: long explanation trying to help those ho try something similar. A question is asked at the end.)

I am trying to install, test and run fpc programs on a QNAP 219 P II NAS.

Same is a headless ARM-Linux device. With 512 MB RAM and It has enough resources to even run Lazarus in a remote GUI environment.

But first I tried to install and use fpc.

Here the initial problem is, that the device uses a mildly QNAP propriety Linux distribution. Same comes with installation tools for it's own package format (".qpkg") moreover you can install Optware ".ipkg" packages, as there is a qpkg for Optware. .

But for fpc there is neither a qpkg not an ipkg package. AFAIK for ARM there only is an Debian "apt-get" package for fpc and friends. Same is said to happily be useable on a "Raspberry Pi" with similar resources as the QNAP 219 P II.

So I tried to find the appropriate ".deb" files

I found the downloadable Debian package here:

http://packages.debian.org/squeeze/armel/fp-compiler/download -> http://ftp.de.debian.org/debian/pool/main/f/fpc/fp-compiler_2.4.0-2_armel.deb

I could extract the content doing

>  ar x fp-compiler_2.4.0-2_armel.deb

Now I have a set of some file including data.tar.bz2 and control.tar.gz

Using Midnight Commander (installed as an ipkg) I extracted those to appropriately named the directories.

"control" contains files to be used by apt

"data" contains the folders "etc" and "users", obviously the destination folders for the files they contain.

"etc" contains fpc.cfg

"usr" contains the directories bin, lib and share with their appropriate content.

Now with the "deeply embedded" QNAP, the root directory is on a RAM file system (extracted together with the Kernel when booting) and will be reconstructed with any boot. Thus it does not make sense to copy the files there.

So I created a directory "debian" on the harddisk that is managed by the QNAP. and moved the extracted files in there relative to a fake root.

Now I copied fpc.cfg to /etc and created symlinks
/usr/bin/fpc -> xxx/debian/usr/bin/fpc            and
/usr/lib/fpc -> xxx/debian/usr/lib/fpc

So there is
xxx/debian/usr/lib/fpc/2.4.0/ppcarm

I can happily run this executable:

[/share/Public/debian/usr/lib/fpc/2.4.0] # ./ppcarm
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
/share/MD0_DATA/Public/debian_test/usr/lib/fpc/2.4.0/ppcarm [options] <inputfile> [options]
Put + after a boolean switch option to enable it, - to disable it
  -a     The compiler doesn't delete the generated assembler file
      -al        List sourcecode lines in assembler file
      -an        List node info in assembler file
      -ap        Use pipes instead of creating temporary assembler files
      -ar        List register allocation/release info in assembler file
      -at        List temp allocation/release info in assembler file
  -A<x>  Output format:
      -Adefault  Use default assembler
      -Aas       Assemble using GNU AS
  -b     Generate browser info
      -bl        Generate local symbol info
  -B     Build all modules
  -C<x>  Code generation options:
      -Ca<x>     Select ABI, see fpc -i for possible values
      -Cb        Generate big-endian code
      -Cc<x>     Set default calling convention to <x>
      -CD        Create also dynamic library (not supported)
      -Ce        Compilation with emulated floating point opcodes
*** press enter ***


After I found that I additionally need to do a link

/usr/bin/ppcarm -> xxx/debian/usr/lib/fpc/2.4.0/ppcarm

I also happily can run "fpc":

[~] # fpc -v
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Fatal: No source file name in command line
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)


Now trying to compile .....

[/share/Public/heizarm] # cat hello.pas
begin
  writeln ( 'hello fpc');
end.
[/share/Public/heizarm] # fpc hello.pas
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling hello.pas
Assembling program
Linking hello
3 lines compiled, 0.3 sec
[/share/Public/heizarm] # ./hello
hello fpc

Works !!!!


Now trying to compile the (commandline) project I created and tested using Lazarus on a Linux PC.

Same obviously needs several additional packages providing the necessary units form the rtl and the fcl. It also needs synapse, but here I simply add the directory with the synapse source files to my project.

I found the appropriate three Debian packages and used the method described above to manually install them. These packages provide .ppu and o files but no sources.

I now have:


[/usr/bin] # ls -l | more
...
lrwxrwxrwx 1 admin administ 12 Dec 5 05:35 find -> /bin/busybox* lrwxrwxrwx 1 admin administ 37 Jan 18 20:24 fpc -> /share/Public/debian/usr/bin/fpc*
...

[/usr/lib] # ls -l | more
drwxr-xr-x    4 admin    administ     4096 Dec  5 04:52 cups/
lrwxrwxrwx 1 admin administ 37 Jan 19 13:52 fpc -> /share/Public/debian/usr/lib/fpc/
...

[/usr/lib/fpc/2.4.0] # ls -l
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 msg/
-rwxr-xr-x    1 admin    administ  1921892 Feb 20  2010 ppcarm*
-rwxr-xr-x    1 admin    administ    12929 Feb 20  2010 samplecfg*
drwxr-xr-x    3 admin    administ     4096 Feb 20  2010 units/


[/usr/lib/fpc/2.4.0/units/arm-linux] # ls -l
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-async/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-base/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-db/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-fpcunit/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-image/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-json/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-net/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-passrc/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-process/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-registry/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-res/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-web/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fcl-xml/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 fpmkunit/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 hash/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 ncurses/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 pasjpeg/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 paszlib/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 regexpr/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 rtl/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 uuid/
drwxr-xr-x    2 admin    administ     4096 Feb 20  2010 x11/
[/usr/lib/fpc/2.4.0/units/arm-linux] #




Now I can compile the project, but linking it does not work:
================================================================================
[/share/Public/heizarm] # fpc heiz.lpr
Free Pascal Compiler version 2.4.0-2 [2010/02/20] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling heiz.lpr
Compiling inifiles.pp
Compiling contnrs.pp
contnrs.pp(2736,12) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Writing Resource String Table file: contnrs.rst
Assembling contnrs
inifiles.pp(245,15) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead. inifiles.pp(259,15) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
inifiles.pp(537,3) Note: Local variable "M" not used
inifiles.pp(542,5) Note: Local variable "l2" not used
inifiles.pp(666,5) Note: Local variable "bAppendNextLine" not used
inifiles.pp(666,22) Note: Local variable "bAppended" not used
Assembling inifiles
Compiling work.pas
Compiling work1611.pas
Compiling httpsend.pas
Compiling blcksock.pas
Compiling synafpc.pas
Assembling synafpc
Compiling synsock.pas
Assembling synsock
Compiling synautil.pas
synautil.pas(1922,3) Note: Local variable "BackStop" is assigned but never used
Assembling synautil
Compiling synacode.pas
Assembling synacode
Compiling synaip.pas
Assembling synaip
Assembling blcksock
Assembling httpsend
Assembling work1611
Compiling workmail.pas
Compiling smtpsend.pas
Assembling smtpsend
Compiling pop3send.pas
Assembling pop3send
Compiling mimemess.pas
Compiling mimepart.pas
Compiling synachar.pas
Compiling synaicnv.pas
Assembling synaicnv
Assembling synachar
Compiling mimeinln.pas
Assembling mimeinln
Assembling mimepart
Assembling mimemess
workmail.pas(77,3) Note: Private field "TSMTPWork.SMTPSend" is never used
Assembling workmail
Assembling work
Assembling heiz
Linking heiz
/usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/usr/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
heiz.lpr(89) Error: Error while linking
heiz.lpr(89) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)
[/share/Public/heizarm] #
================================================================================

I found, that _fini and _init *should* be provided by crti.o which is not included in the packages I installed. And I don't know how to find out which package might provide it.

Rather disappointed I tried to compile the crti.s file from the svn.

After renaming it to crti.S and commenting out the two".type" lines, that gcc (installed as an ipkg) does not like, it can be compiled to crti.o:

[/share/Public/heizarm] # cat crti.S
===============================================================
//
//Copyright 2001, QNX Software Systems Ltd. All Rights Reserved
//
// QNX has kindly released this source code under the QNX open
// Community license, expressly to be used with  the
// Free Pascal runtime library
//

        .section .init
        .globl  _init
//      .type   _init,@function
_init:

        .section .fini
        .globl  _fini
//      .type   _fini,@function
_fini:
===============================================================

To make it aware to the linker, I added an appropriate line
{L crti.o}
to the heiz.lpr file.

Now the project can be linked.

But unfortunately it does not run:

[/share/Public/heizarm] # ./heiz
Segmentation fault
[/share/Public/heizarm] #


How to proceed ?

I never use any crt stuff, only writeln() is used, and same does work in the "hello" project. Thus the initialization of the crt stuff seems like a dummy task but should not crash, anyway.

I have no idea why the project needs _init and _fini and thus crti.o. According to the svn files, "haltproc_eabi" is used in system.pp and provided by cprt0.as. I don speak are assembler and I am only acquainted with the gcc type assembler file (.s or .S rather than .as). So I don't understand what is done in the ARM version of cprt0.

Thanks for any help,
-Michael




_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to