Recent

Author Topic: File format issue with crtbegin.o for crosscompiler  (Read 5035 times)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
File format issue with crtbegin.o for crosscompiler
« on: November 27, 2015, 04:27:31 pm »
I just updated fpc to 3.0.0 and had to recreate crosscompiler for i386 and arm. I'm pretty sure that it was a piece of cake with 2.6.4. But today the compilers complain about "/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/crtbegin.o: file not recognized: File format not recognized".

I use to do "make clean crosszipinstall CPU_TARGET=i386" and extract units and ppc to the right directory. As before. The same for arm with OPT="-dARMEL". And finally I created symlinks for ppcarm and ppci386 at /usr/bin to the ppcross* at /usr/lib/fpc.

My arm binutils reside in /usr/local/arm/, /usr/lib32 is valid too - both are referenced in fpc.cfg
Code: Text  [Select][+][-]
  1. #ifdef cpui386
  2. -Xd
  3. -Fl/usr/lib32
  4. #endif
  5. #ifdef cpuarm
  6. -Xd
  7. -Fl/usr/local/arm/lib
  8. -Fl/usr/local/arm/libc/usr/lib
  9. -Parm
  10. #endif
"ppcarm -vt b" returns
Code: Text  [Select][+][-]
  1. [ht@Venus ~]$ ppcarm -vt b
  2. Configfile search: /home/ht/.fpc.cfg
  3. Reading options from file /home/ht/.fpc.cfg
  4. Hint: End of reading config file /home/ht/.fpc.cfg
  5. Free Pascal Compiler version 3.0.0 [2015/11/27] for arm
  6. Copyright (c) 1993-2015 by Florian Klaempfl and others
  7. Searching file /lib/ld-linux.so.3... not found
  8. Searching file /lib/ld-uClibc.so.0... not found
  9. Compiler: /usr/lib/fpc/3.0.0/ppcrossarm
  10. Target OS: Linux for ARMEL
  11. Using executable path: /usr/lib/fpc/3.0.0/
  12. Using unit path: /usr/lib/fpc/3.0.0/
  13. Using library path: /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/
  14. Using library path: /usr/local/arm/libc/usr/lib/

I'm sure to never have added binprefix. And playing around with these options didn't help. But to me it's poking in the dark. Any idea what's wrong here?

PS: A simple "program Test; begin writeln('Hello World'); end." works on all targets.
Lazarus 1.7 (SVN) FPC 3.0.0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: File format issue with crtbegin.o for crosscompiler
« Reply #1 on: November 27, 2015, 05:02:24 pm »
Well, arm target has been split, and is now ARMEL it seems? Probably you need to adjust the ifdef in fpc.cfg accordingly (probably cpuarmel, see what is defined with -a)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: File format issue with crtbegin.o for crosscompiler
« Reply #2 on: November 27, 2015, 05:15:49 pm »
Simply change it to #ifdef cpuarmel doesn't have any effect.

ppcarm -i (no -a option) tells me
Supported targets (targets marked with '{*}' are under development):
  Linux: Linux for ARMEL
  WinCE: WinCE for ARM
  gba: GameBoy Advance
  PalmOS: PalmOS
  nds: Nintendo DS
  embedded: Embedded
  Symbian: Symbian OS for ARM
  Darwin: Darwin for ARM
  Android: Android for ARMEL

Args, while writing this down I found the reason - or something like. I tried RC1 some time ago and got warnings. As recommended in https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg39959.html it was solved by
Code: Text  [Select][+][-]
  1. #ifdef VER3_0
  2. -Fl/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0
  3. #ENDIF
  4.  
which is not good obviously.

Without this line the compilation works but with warnings
Code: Text  [Select][+][-]
  1. Warning: (9034) "crtbegin.o" not found, this will probably cause a linking failure
  2. Warning: (9034) "crtend.o" not found, this will probably cause a linking failure

The same when I compile for i386
ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
ld: skipping incompatible /usr/lib/libpthread.a when searching for -lpthread
...

Is it worth a new thread?
Lazarus 1.7 (SVN) FPC 3.0.0

ykot

  • Full Member
  • ***
  • Posts: 141
Re: File format issue with crtbegin.o for crosscompiler
« Reply #3 on: November 27, 2015, 09:09:43 pm »
From what it looks like, i386 cross-compiler can't find the appropriate libraries (it finds 64-bit ones, which are not compatible). I had this problem on Linux for quite some time and it seems to be solved by properly editing "fpc.cfg".

In my case, I had to edit these lines (there could be more):
Code: [Select]
# path to the gcclib
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.9/32
#endif
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.9
#endif

In the end of "fpc.cfg", I've added:
Code: [Select]
#IFDEF CPUI386
-Fl/usr/lib32
-Fl/usr/lib/i386-linux-gnu
#ENDIF

In case you find it useful, I've added my "fpc-prepare-x32.sh" script, which installs missing libraries (when building SVN trunk from scratch for i386 cross-compilation) and "fpc.cfg". In my config, I cross-compile from Linux x86_64 to Linux/i386, Linux/ARM-HF, Windows i386/x86_64, Android/ARMEL, Android/i386, Embedded/ARM and Embedded/AVR. However, I haven't tried seeding with 3.x though.

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: File format issue with crtbegin.o for crosscompiler
« Reply #4 on: November 28, 2015, 01:11:58 am »
From what it looks like, i386 cross-compiler can't find the appropriate libraries...

Thanks. In my case it was the fix definition to avoid warnings - as I wrote in my first reply. With a "normal" fpc.cfg I can build i386 and arm code but still get warnings.
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018