Recent

Author Topic: Cross-compile FPC on ppc64 for ppc64le  (Read 5362 times)

ferseiti

  • Newbie
  • Posts: 4
Cross-compile FPC on ppc64 for ppc64le
« on: July 29, 2015, 10:15:42 pm »
Hello. I have been trying to build fpc for target ppc64le but using a ppc64 Fedora vm.

What I did so far was:
Create a script /usr/bin/powerpc64-linux-ld that runs
Code: [Select]
ld -A elf64lppc $@ And create a /usr/bin/powerpc64-linux-as that runs
Code: [Select]
as -little $@
Then:
Code: [Select]
make all  CROSSOPT="-Cb- -Caelfv2" BINUTILSPREFIX=powerpc64-linux-
But the build fails with several errors just like this one:
Code: [Select]
ld: powerpc64/units/powerpc64-linux/dbgstabs.o: compiled for a little endian system and target is big endian
ld: failed to merge target specific data of file powerpc64/units/powerpc64-linux/dbgstabs.o
pp.pas(238,36) Error: Error while linking
pp.pas(238,36) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

I am probably doing something wrong, of course. Any help will be appreciated.
Thanks

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1059
Re: Cross-compile FPC on ppc64 for ppc64le
« Reply #1 on: July 29, 2015, 10:25:43 pm »
As mentioned at http://bugs.freepascal.org/view.php?id=26261#c81964 , building a ppc64le installation on a big endian ppc64 is not possible at this time using the top level Makefile, because we don't have support yet for having multiple ABIs of a single platform in one source tree (which you need when bootstrapping ppc64le on a ppc64 platform).

The easiest way to bootstrap is to cross-build on a non-ppc64 machine instead (with the make invocation that you used), and then copy the resulting bootstrap compiler (compiler/ppcppc64) to your ppc64le system.

ferseiti

  • Newbie
  • Posts: 4
Re: Cross-compile FPC on ppc64 for ppc64le
« Reply #2 on: July 29, 2015, 10:32:51 pm »
That was a quick response :)
Yes, I saw that bug, but I didn't quite get it from there.
I will give it a try and post the outcome here.
Thank you!

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1059
Re: Cross-compile FPC on ppc64 for ppc64le
« Reply #3 on: July 29, 2015, 10:48:46 pm »
Alternatively, if you really want to bootstrap on a big endian ppc64 machine:
  • build svn trunk for regular ppc64 using a plain make all (note that you can speed up compilations on multicore machines by adding -j X FPMAKEOPT="-T X", with X the number of cores)
  • move compiler/ppcppc64 to a temporary location (e.g. $HOME/bin/ppc64n)
  • go into fpc/rtl/linux, and execute make FPC=$HOME/bin/ppc64n OPT="-Cb- -Caelfv2 -O2 -a -st" clean all
  • then go into fpc/compiler and execute the same there
  • scp -r fpc/rtl/units ppc64le-machine:fpc/rtl and then on ppc64le-machine in fpc/units/powerpc64-linux execute for file in *.s; do as -o `basename $file .s`.o $file; done
  • scp -r fpc/compiler/powerpc64/units ppc64le-machine:fpc/compiler/powerpc64/units ; scp ppas.sh link.res ppc64le-machine:fpc/compiler
  • edit ppas.sh and link.res on the ppc64le machine to adapt the paths to the various files (if necessary) and finally execute ./ppas.sh in the compiler directory on the ppc64le machine. The compiler binary will be called "pp"
The above method is generally what I use to bootstrap compilers for a new platform, so that I don't need cross binutils.
« Last Edit: July 30, 2015, 11:15:00 am by Jonas Maebe »

ferseiti

  • Newbie
  • Posts: 4
Re: Cross-compile FPC on ppc64 for ppc64le
« Reply #4 on: July 30, 2015, 10:31:07 pm »
As a matter of fact, I also contacted Jaromír Cápík (reporter of http://bugs.freepascal.org/view.php?id=26261).
He was able to generate a binary which he sent to me and I saved as $HOME/fpc/bin/fpc
Then I ran:
Code: [Select]
make compiler_cycle PP=$HOME/fpc/bin/fpc
cp ./compiler/ppcppc64 $HOME/fpc/bin/ppcppc64
make install PP=$HOME/fpc/bin/ppcppc64

I will try to bootstrap it anyway. Haven't tried yet.
Too bad it wasn't able to build v2.6.4 with the result (The version available in Debian repository).

Code: [Select]
/usr/local/bin/ppcppc64 -Ur -Ur -Xs -O2 -n -Fi../inc -Fi../powerpc64 -Fi../unix -Fipowerpc64 -FE. -FU/root/fpc/fpc-debian/fpc-2.6.4+dfsg/fpcsrc/rtl/units/powerpc64-linux @/root/fpc/fpc-debian/fpc-2.6.4+dfsg/debian/deb-host-fpc.cfg -dpowerpc64 -dRELEASE -Us -Sg system.pp
systemh.inc(508,3) Fatal: Cannot find system type "TEXTREC". Check if you use the correct run time library.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1059
Re: Cross-compile FPC on ppc64 for ppc64le
« Reply #5 on: July 30, 2015, 11:15:53 pm »
It's never possible to build older versions of FPC with newer ones, because the RTL and the compiler are quite tightly interwoven. And even if the RTL would compile, it wouldn't help you at all since FPC 2.6.4 does not have any ppc64el support (so once the compiler itself would be compiled, the resulting compiler would not be able to generate ppc64el code).

 

TinyPortal © 2005-2018