Author Topic: Cross-build compiler environment for SBE  (Read 12597 times)

TimKelly

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-3
    • View Profile
Cross-build compiler environment for SBE
« on: September 08, 2025, 01:58:22 pm »
Does anyone have a link to the directions to build the cross-build compiler environment necessary to compile the Self-Build Engine source code?  The source code has many references to

# Makefile for P9-XIP image code and tools; works on X86 Linux hosts.

ifndef GCC-TOOL-PREFIX
GCC-TOOL-PREFIX = $(CROSS_COMPILER_PATH)/bin/powerpc-eabi-
endif

TCC     = $(PPETRACEPP_BIN_DIR)/ppetracepp $(GCC-TOOL-PREFIX)gcc
CC      = $(PPETRACEPP_BIN_DIR)/ppetracepp $(GCC-TOOL-PREFIX)gcc

I would like to build that cross-build environment natively on Debian on Raptor, as part of my effort to port the building of SBE to strict POSIX 2024 for portability to other build environments.

Thank you,
tim

TimKelly

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-3
    • View Profile
Re: Cross-build compiler environment for SBE
« Reply #1 on: September 09, 2025, 06:04:02 am »
I believe I have been able to answer my own question.

https://git.raptorcs.com/git/ppe42-gcc/
https://git.raptorcs.com/git/ppe42-binutils/

After you run git clone for each, you will get the message that HEAD does not exist and have an empty repository.  In the appropriate repository run

git switch gcc-4_9_2-ppe42
git switch binutils-2_24-ppe42

which should populate the repository with the most recent code.
« Last Edit: September 09, 2025, 06:33:24 am by TimKelly »

tle

  • Hero Member
  • *****
  • Posts: 533
  • Karma: +53/-0
    • View Profile
    • Trung's Personal Website
Re: Cross-build compiler environment for SBE
« Reply #2 on: September 18, 2025, 06:35:30 pm »
I have not tried to but wondering have you checked https://github.com/open-power/ppe42-gcc ?
Faithful Linux enthusiast

My Raptor Blackbird

TimKelly

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-3
    • View Profile
Re: Cross-build compiler environment for SBE
« Reply #3 on: September 19, 2025, 03:42:07 am »
I have not.  Certainly it looks like there are more instructions, but I gave up after getting internal compiler errors when ppe42-gcc tried to build ppe-binutils.  It was in the internal register allocator (ira) and both the subdirectory configure and Makefiles would not respect flags passed to them, as I documented at

https://forums.raptorcs.com/index.php/topic,617.0.html

However, I did not apply patches to what was in Raptor's source code tree.  Thank you for pointing out the different repository.

TimKelly

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-3
    • View Profile
Re: Cross-build compiler environment for SBE
« Reply #4 on: September 19, 2025, 04:51:57 am »
Ok, I installed the open-power sources from Microsoft's Github, but the build failed.

ppe42-gcc binutils fails with

../../ppe42-binutils/bfd/srec.c: In function ‘srec_bad_byte’:
../../ppe42-binutils/bfd/srec.c:254:26: error: ‘%03o’ directive writing between 3 and 11 bytes into a region of size 9 -Werror=format-overflow=]
  254 |         sprintf (buf, "\\%03o", (unsigned int) c);
      |                          ^~~~


The instructions for building ppe42-gcc say install the following patches:

https://github.com/open-power/op-build/blob/master/openpower/package/ppe42-gcc/0001-2016-02-19-Jakub-Jelinek-jakub-redhat.com.patch

https://github.com/open-power/op-build/blob/master/openpower/package/ppe42-gcc/0001-reload-Change-to-type-of-x_spill_indirect_levels.patch

These appear to be embedded within Microsoft's Github pages and not easily downloaded via curl -O.

I stopped here.  The line for me is I am not debugging GNU's binutils or gcc code or hunting around Microsoft's Github in order to build the environment to build the SBE.  There is a gambler's lure here, where maybe just maybe one more hour of effort will make it all work, but it never does.

TimKelly

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-3
    • View Profile
Re: Cross-build compiler environment for SBE
« Reply #5 on: October 05, 2025, 11:38:45 am »
just a follow-up, I have abandoned my efforts to port the SBE to a strict POSIX make environment.  The issue is not the strict POSIX part, as that can be done with some work (53 files by my count, some of which migrate easily). 

The real issue is that the SBE code is not particularly portable.  Much of the hardware descriptions use C++ that could easily be implemented with structs, and the SBE relies on trivial (even lazy) C++ code in dozens of places that will not compile because the Linux implementation of C++ does not mesh well with the FreeBSD C++ implementation.  Libraries and namespaces are labeled differently, so included files are not found, leading to a failure to compile.  Fixing this would require an unreasonable amount of effort (over 8000 identified locations, plus the hardware descriptors), when there shouldn't even be any C++ code in something this close to bare metal.  None of the functionality causing issues requires C++, and would have been much more portable if written in C14 or even C99.  In some cases it is literally a std:: class to make a brief reference to a string.  Utterly unnecessary, and in my opinion, either lazy or intentional.

The code in question came from IBM; the choice to use C++ and how it is used leads me to believe there was not a true effort to open up the SBE.  The code released was built to a pretty specific environment, to the exclusion of others.  This is a direct (and very disappointing) example of how open source is not always free, as in "free to port and use in one's personal environment."  "Our way or no way" is not a choice, and without choices we are not free.

In my opinion it would be easier to construct a replacement to the SBE than to try to fix it.