Recent

Author Topic: Need help to build FPC for PowerPC 64-bit big-endian ELFv2  (Read 786 times)

link4electronics

  • Newbie
  • Posts: 3
Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« on: December 01, 2025, 09:41:21 am »
Hello everyone, I hope everything is okay.

I'm trying to compile FPC for a machine running ArchPOWER Linux, powerpc64 big-endian ELFv2 platform. FPC versions provided to download are only for ppc64 big-endian ELFv1 or ppc64 little-endian ELFv2, and need ppc64 BE ELFv2. I tried to compile on a VM ppc64le using command
Code: Pascal  [Select][+][-]
  1. make all OS_TARGET=linux CPU_TARGET=powerpc64 OPT="-Cb -Caelfv2"
It compiles until ppc1 but can't run it since it's using ppc64le to be able to compile others binaries.

Best regards,
Link.

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #1 on: December 01, 2025, 11:31:59 am »
Hmm, probably just noise but ...

I suspect you OPT="-Cb -Caelfv2" should be CROSSOPT="-Cb -Caelfv2" ?

But no idea of what the options them selves should be in this particular case.

Incidentally, should be possible to build a cross compiler from an x86 machine too, probably no harder. I think ...

Oh, and you know that  to build version X of FPC, you must use version X-1 ?
 

Davo 
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #2 on: December 01, 2025, 11:57:33 am »
You can crosscompile X using version X. A version must always be able to compile itself(as it is part of the bootstrap to compile itself).

There are some rare exceptions for new architectures etc though.

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #3 on: December 01, 2025, 12:41:07 pm »
Oh, well, did not know that. Hm, must have know it, my fpc compile script does, in fact use the newly built compiler ...

Incidentally, my comment about building using your x86_64 box is incomplete too. You will also need the binutils-powerp64-linux-gnu, I think they work for both LE and BE but need to be told if not default.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

link4electronics

  • Newbie
  • Posts: 3
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #4 on: December 01, 2025, 10:13:33 pm »
Hello,

Thanks for the suggestions and help. I forgot to say that I'm trying to compile version 3.2.2
But still can't compile it for ppc64 BE ELFv2. on x86_64 tried to compile as
Code: Pascal  [Select][+][-]
  1. make all OS_TARGET=linux CPU_TARGET=powerpc64 CROSSOPT="-Cb -Caelfv2" BINUTILSPREFIX=/usr/bin/powerpc64-linux-gnu-
, tried adding
Code: Pascal  [Select][+][-]
  1. CROSSCOMPILE=1
, on x86_64 binaries were still compiled as for x86_64. on ppc64le they're for pp64le.

On Arch Linux they're separate binutils packages for BE and LE, powerpc64-linux-gnu-binutils for BE and powerpc64le-linux-gnu-binutils for LE.

Regards,
Link.
« Last Edit: December 01, 2025, 10:27:42 pm by link4electronics »

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #5 on: December 02, 2025, 12:09:53 pm »
But still can't compile it for ppc64 BE ELFv2. on x86_64 tried to compile as
Code: Pascal  [Select][+][-]
  1. make all OS_TARGET=linux CPU_TARGET=powerpc64 CROSSOPT="-Cb -Caelfv2" BINUTILSPREFIX=/usr/bin/powerpc64-linux-gnu-
, on x86_64 binaries were still compiled as for x86_64. on ppc64le they're for pp64le.

That is quite strange. Now, my notes tell me that I build my armhf compiler in a 64bit intel VM with -

Code: Pascal  [Select][+][-]
  1. make clean all CPU_TARGET=arm CROSSOPT="-CpARMV6 -CaEABIHF" CROSSBINDIR=/usr/arm-linux-gnueabihf/bin

I end up with compiler/ppcarm and compiler/ppcrossarm. The file command confirms them as what they should be. Yours should be ppcpower64 or some such, a cross compiler that is x86_64 and a straight power64 compiler.

The only difference I can see is the use of CROSSBINDIR=...  instead of BINUTILSPREFIX...   I take it your power binutils live in /usr/bin and are called powerpc64-linux-gnu-as, powerpc64-linux-gnu-ld etc ?  You have checked that they are actually there ? Mine is a debian based machine so no point me installing here.

I am struggling to suggest something more. Perhaps do a make clean, pump a few blank lines and then run that compile command without the "clean" and have a look through the log, the early part, to see if its talking about the right thing.

link4, we have to be realistic, there are not a lot of Power CPU users here. I logged a compile problem, a relativly minor issue on PowerLE a few years ago, while it got some comments, no fix unfortunately. The issue being, probably, none of the current devs have access to a Power64 machine. I sure don't ...

Davo

PS, my binutils look like this -

Code: [Select]
dbannon@u2004MnewBuild:~/bin/FPC/SRC/test$ ls -l /usr/arm-linux-gnueabihf/bin
total 0
lrwxrwxrwx 1 root root 32 Mar 31  2025 ar -> ../../bin/arm-linux-gnueabihf-ar
lrwxrwxrwx 1 root root 32 Mar 31  2025 as -> ../../bin/arm-linux-gnueabihf-as
lrwxrwxrwx 1 root root 32 Mar 31  2025 ld -> ../../bin/arm-linux-gnueabihf-ld
lrwxrwxrwx 1 root root 36 Mar 31  2025 ld.bfd -> ../../bin/arm-linux-gnueabihf-ld.bfd
lrwxrwxrwx 1 root root 37 Mar 31  2025 ld.gold -> ../../bin/arm-linux-gnueabihf-ld.gold
lrwxrwxrwx 1 root root 32 Mar 31  2025 nm -> ../../bin/arm-linux-gnueabihf-nm
lrwxrwxrwx 1 root root 37 Mar 31  2025 objcopy -> ../../bin/arm-linux-gnueabihf-objcopy
lrwxrwxrwx 1 root root 37 Mar 31  2025 objdump -> ../../bin/arm-linux-gnueabihf-objdump
lrwxrwxrwx 1 root root 36 Mar 31  2025 ranlib -> ../../bin/arm-linux-gnueabihf-ranlib
lrwxrwxrwx 1 root root 37 Mar 31  2025 readelf -> ../../bin/arm-linux-gnueabihf-readelf
lrwxrwxrwx 1 root root 35 Mar 31  2025 strip -> ../../bin/arm-linux-gnueabihf-strip
 


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

link4electronics

  • Newbie
  • Posts: 3
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #6 on: December 05, 2025, 02:45:33 am »
Hello,

I'm happily to say that I got it working!  :D
I ended up compiling branch fixes_3_2 from gitlab, which gave me version 3.2.3
Just compiled lazarus and goverlay to test it and confirmed that they work properly!

I understand that this platform is old, but it still working great. LLVM project for eg.  is gonna drop support for ELFv1 for powerpc64 big-endian, and they'll only support ELFv2 for PPC64BE for version 22.x onward.

Best regards,
Link.
« Last Edit: December 05, 2025, 02:48:40 am by link4electronics »

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #7 on: December 05, 2025, 04:00:40 am »
Excellent !  I'm guessing you wrote down what you did ?

Please consider posting it here so there is a record. We really should have a central list of what make the various cross compilers work.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

PascalDragon

  • Hero Member
  • *****
  • Posts: 6315
  • Compiler Developer
Re: Need help to build FPC for PowerPC 64-bit big-endian ELFv2
« Reply #8 on: December 05, 2025, 09:13:32 pm »
Thanks for the suggestions and help. I forgot to say that I'm trying to compile version 3.2.2
But still can't compile it for ppc64 BE ELFv2. on x86_64 tried to compile as
Code: Pascal  [Select][+][-]
  1. make all OS_TARGET=linux CPU_TARGET=powerpc64 CROSSOPT="-Cb -Caelfv2" BINUTILSPREFIX=/usr/bin/powerpc64-linux-gnu-
, tried adding
Code: Pascal  [Select][+][-]
  1. CROSSCOMPILE=1
, on x86_64 binaries were still compiled as for x86_64. on ppc64le they're for pp64le.

On Arch Linux they're separate binutils packages for BE and LE, powerpc64-linux-gnu-binutils for BE and powerpc64le-linux-gnu-binutils for LE.

I built both 3.2.2 and 3.3.1 on my x86_64-linux ArchLinux using the following command line:

Code: [Select]
make all CPU_TARGET=powerpc64 CROSSOPT="-Cb -Caelfv2" BINUTILSPREFIX=powerpc64-linux-gnu- FPMAKEOPT="-T 8" -j 8
A binary compiled with the created ppcrossppc64 runs without problems with qemu-ppc64 and file outputs the following for it:

Code: [Select]
ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), statically linked, not stripped
Any yes, the created ppcppc64 also runs with qemu-ppc.
« Last Edit: December 05, 2025, 09:15:21 pm by PascalDragon »

 

TinyPortal © 2005-2018