Recent

Author Topic: Feature Request: Support for Freebsd PowerPC32/Powerpc64  (Read 2111 times)

clhamilto

  • Newbie
  • Posts: 4
Feature Request: Support for Freebsd PowerPC32/Powerpc64
« on: September 18, 2020, 07:40:36 pm »
I'm looking to see if there is any interest in supporting FreeBSD on PowerPC64. It appears that it should be relatively easy given the overall support for other OSes running on this PowerPC architecture.

I'm a novice programmer and I've been successfully in building both PowerPC32 and PowerPC64 cross compilers on X86_64.  However, I've been unsuccessful in modifying the Linux PowerPC32/PowerPC64 code for use on FreeBSD.  The results was a PowerPC32 FPC that segfaults when run on the native OS.  I've not been as successful on PowerPC64.

I'm willing to help, if I can.

-Cheers

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #1 on: September 18, 2020, 08:14:36 pm »
Need more info. I remember that 32-bit PPC on Linux had problems with smartlinking.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #2 on: September 18, 2020, 11:03:34 pm »
Are they still manufactured ?
The only true wisdom is knowing you know nothing

clhamilto

  • Newbie
  • Posts: 4
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #3 on: September 19, 2020, 01:39:26 am »
I’m not sure of what additional information to provide.  For PowerPC32 everything builds without error, using modified Linux/PowerPC32 files in rtl/FreeBSD/powerpc directory. No changes were made to prt0.as, crt0.as, grt0.as and dllrt0.as. However, I think the issue may be with “prt0.as” as it is used to build the compiler (ppcppc).

There are plenty of old Apple PowerMacs being used to run Linux and various BSD implementations.  However, Raptor Computing makes and sell systems built on IBM OpenPOWER technology. In fact, I’m using a Blackbird, one of their Power9 based systems which supports PowerPC64, both big and little endian.  Starting with FreeBSD 12 there is support for Power9, big endian.  FreeBSD programmers are currently working on a little endian implementation.

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #4 on: September 19, 2020, 12:22:02 pm »
Are they still manufactured ?
More than that: https://en.wikipedia.org/wiki/POWER10 which is currently only available in development batches, full scale to be released in 2021.
PowerPC as such is still a - very - popular server platform
« Last Edit: September 19, 2020, 12:27:21 pm by Thaddy »
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #5 on: September 19, 2020, 12:25:50 pm »
Need more info. I remember that 32-bit PPC on Linux had problems with smartlinking.

MarkMLl
You can specify an external linker, usually ld.

With FreeBSD I have not really much experience, but marcov has.
He might be able to help OP with the setup..
Specialize a type, not a var.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #6 on: September 19, 2020, 02:48:16 pm »
The crt/prt ones are simply the ones provided by the OS with some modifications.  The prt ones remove C lib initialization, and both also copy argv/argc and some other strings to operatingsystem_ * variables.

For problem finding it can be easier to compile everything on the host with -s, but only link on target (with generated ppas.sh)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #7 on: September 19, 2020, 03:40:27 pm »
I’m not sure of what additional information to provide.  For PowerPC32 everything builds without error, using modified Linux/PowerPC32 files in rtl/FreeBSD/powerpc directory. No changes were made to prt0.as, crt0.as, grt0.as and dllrt0.as. However, I think the issue may be with “prt0.as” as it is used to build the compiler (ppcppc).

You should look at the startup files for the BSD C library and translate those instead of using the Linux ones (like marcov suggested). Linux startup is different from e.g. FreeBSD.

clhamilto

  • Newbie
  • Posts: 4
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #8 on: September 20, 2020, 03:45:20 am »
Pardon my ignorance.  I'm not sure which files you're referring to.  Can you point me in the right direction?

clhamilto

  • Newbie
  • Posts: 4
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #9 on: September 20, 2020, 03:50:50 am »
BTW, This is what I get when I attempt to execute the compiler on the target (with a gdb backtrace).

root@blackbird:~/Downloads/fpc-3.2.0-devel/compiler # ./ppcppc64
Segmentation fault (core dumped)
root@blackbird:~/Downloads/fpc-3.2.0-devel/compiler # gdb ./ppcppc64 ppcppc64.core
GNU gdb (GDB) 8.3 [GDB v8.3 for FreeBSD]
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./ppcppc64...

warning: core file may not match specified executable file.
[New LWP 101484]
Core was generated by `./ppcppc64'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x7c0802a6fbe1fff8 in ?? ()
(gdb) backtrace
#0  0x7c0802a6fbe1fff8 in ?? ()
#1  0x0000000010020138 in $fpc_initializeunits () at ../inc/system.inc:969
#2  0x0000000010000980 in $main () at pp.pas:256
(gdb) disass
No function contains program counter for selected frame.
(gdb) frame 1
#1  0x0000000010020138 in $fpc_initializeunits () at ../inc/system.inc:969
969            Procs.InitProc();
(gdb) disass
Dump of assembler code for function $fpc_initializeunits:
   0x00000000100200c0 <+0>:   mflr    r0
   0x00000000100200c4 <+4>:   std     r31,-8(r1)
   0x00000000100200c8 <+8>:   std     r30,-16(r1)
   0x00000000100200cc <+12>:   std     r29,-24(r1)
   0x00000000100200d0 <+16>:   std     r28,-32(r1)
   0x00000000100200d4 <+20>:   std     r0,16(r1)
   0x00000000100200d8 <+24>:   stdu    r1,-128(r1)
   0x00000000100200dc <+28>:   bl      0x100029c8 <fpc_cpuinit>
   0x00000000100200e0 <+32>:   nop
   0x00000000100200e4 <+36>:   ld      r3,-31472(r2)
   0x00000000100200e8 <+40>:   ld      r28,0(r3)
   0x00000000100200ec <+44>:   cmpldi  r28,1
   0x00000000100200f0 <+48>:   blt     0x1002014c <$fpc_initializeunits+140>
   0x00000000100200f4 <+52>:   li      r31,0
   0x00000000100200f8 <+56>:   addi    r3,r31,1
   0x00000000100200fc <+60>:   mr      r31,r3
   0x0000000010020100 <+64>:   rldicr  r4,r31,4,59
   0x0000000010020104 <+68>:   ld      r3,-31472(r2)
   0x0000000010020108 <+72>:   ldx     r3,r4,r3
   0x000000001002010c <+76>:   cmpldi  r3,0
   0x0000000010020110 <+80>:   beq     0x1002013c <$fpc_initializeunits+124>
   0x0000000010020114 <+84>:   rldicr  r4,r31,4,59
   0x0000000010020118 <+88>:   ld      r3,-31472(r2)
   0x000000001002011c <+92>:   ldx     r29,r4,r3
   0x0000000010020120 <+96>:   ld      r30,0(r29)
   0x0000000010020124 <+100>:   std     r2,40(r1)
   0x0000000010020128 <+104>:   mtctr   r30
   0x000000001002012c <+108>:   ld      r2,8(r29)
   0x0000000010020130 <+112>:   ld      r11,16(r29)
   0x0000000010020134 <+116>:   bctrl
=> 0x0000000010020138 <+120>:   ld      r2,40(r1)
   0x000000001002013c <+124>:   ld      r3,-31472(r2)
   0x0000000010020140 <+128>:   std     r31,8(r3)
   0x0000000010020144 <+132>:   cmpld   r31,r28
   0x0000000010020148 <+136>:   blt     0x100200f8 <$fpc_initializeunits+56>
   0x000000001002014c <+140>:   ld      r3,-31392(r2)
   0x0000000010020150 <+144>:   ld      r3,0(r3)
   0x0000000010020154 <+148>:   cmpldi  r3,0
   0x0000000010020158 <+152>:   beq     0x10020180 <$fpc_initializeunits+192>
   0x000000001002015c <+156>:   ld      r3,-31392(r2)
   0x0000000010020160 <+160>:   ld      r31,0(r3)
   0x0000000010020164 <+164>:   ld      r30,0(r31)
   0x0000000010020168 <+168>:   std     r2,40(r1)
   0x000000001002016c <+172>:   mtctr   r30
   0x0000000010020170 <+176>:   ld      r2,8(r31)
   0x0000000010020174 <+180>:   ld      r11,16(r31)
   0x0000000010020178 <+184>:   bctrl
   0x000000001002017c <+188>:   ld      r2,40(r1)
   0x0000000010020180 <+192>:   addi    r1,r1,128
   0x0000000010020184 <+196>:   ld      r31,-8(r1)
   0x0000000010020188 <+200>:   ld      r30,-16(r1)
   0x000000001002018c <+204>:   ld      r29,-24(r1)
   0x0000000010020190 <+208>:   ld      r28,-32(r1)
   0x0000000010020194 <+212>:   ld      r0,16(r1)
   0x0000000010020198 <+216>:   mtlr    r0
   0x000000001002019c <+220>:   blr
End of assembler dump.
(gdb) quit



trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #10 on: September 20, 2020, 03:55:50 am »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #11 on: September 20, 2020, 12:37:42 pm »
It also helps to know that the freebsd startup code is called "csu" and iirc is in the libc part of the sources.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #12 on: September 20, 2020, 02:33:05 pm »
They are located in lib/csu. You'll have to adjust these for the Pascal startup.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Feature Request: Support for Freebsd PowerPC32/Powerpc64
« Reply #13 on: September 20, 2020, 02:54:38 pm »
Also, to check for anomalies, compile a C program with some verbosity options to get the parameters/commandline that gcc/llvm uses passes to the linker.

 

TinyPortal © 2005-2018