diff --git a/.github/workflows/deploy-docker.yaml b/.github/workflows/deploy-docker.yaml
new file mode 100644
index 000000000..ff2c88036
--- /dev/null
+++ b/.github/workflows/deploy-docker.yaml
@@ -0,0 +1,61 @@
+name: ci-docker
+on:
+ pull_request:
+ branches:
+ - master
+
+ # Runs on pushes targeting the default branch
+ push:
+ branches: ['master']
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ dockerhub-push:
+ runs-on: ubuntu-latest
+ environment: DockerHub
+ env:
+ DOCKERHUB_REPONAME: ps3dev
+ strategy:
+ matrix:
+ platform: [linux/amd64]
+
+ steps:
+
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: README to Dockerhub
+ uses: christian-korneck/update-container-description-action@v1
+ env:
+ DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
+ DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
+ with:
+ destination_container_repo: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPONAME }}
+ provider: dockerhub
+ short_description: 'A Docker Image for PS3 Development'
+ readme_file: 'README.md'
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+ with:
+ platforms: ${{ matrix.platform }}
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and Push Docker Image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: ./Dockerfile
+ platforms: ${{ matrix.platform }}
+ push: true
+ tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPONAME }}:latest
\ No newline at end of file
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 42302dcda..334b3f84d 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -1,68 +1,123 @@
-name: Build toolchain docker image
+name: ci
on:
push:
- branches:
- - '*'
pull_request:
- branches:
- - '*'
+ workflow_dispatch:
+ repository_dispatch:
+ types: [run_build]
jobs:
- Docker:
- runs-on: ubuntu-latest
+ build:
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os: [ubuntu-latest]
+ architecture: [x64]
+ defaults:
+ run:
+ shell: bash
+
+ outputs:
+ sha8: ${{ steps.slug.outputs.sha8 }}
+ date: ${{ steps.date.outputs.date }}
+
steps:
- - name: Checkout
- uses: actions/checkout@v2
- with:
- fetch-depth: 1
- persist-credentials: false
- - name: Set up Docker Buildx
- if: success()
- id: buildx
- uses: crazy-max/ghaction-docker-buildx@v3
- with:
- buildx-version: latest
- qemu-version: latest
- - name: Prepare
- if: success()
- id: prepare
- run: |
- echo ::set-output name=docker_platforms::linux/amd64,linux/386
- echo ::set-output name=docker_username::miigotu
- echo ::set-output name=github_image::docker.pkg.github.com/${GITHUB_REPOSITORY,,}/ps3dev
- VERSION_TAG=${GITHUB_REF#refs/*/}
- echo ::set-output name=version::${VERSION_TAG%/merge}
- - name: Available platforms
- if: success()
- run: echo ${{ steps.buildx.outputs.platforms }}
- - name: Docker Login and set build command
- if: success()
- id: login
- env:
- GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
+ - uses: actions/checkout@v4
+
+ - name: Get short SHA
+ id: slug
+ run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
+
+ - name: Get current date
+ id: date
+ run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
+
+ - name: Get current arch
+ id: arch
+ run: echo "::set-output name=arch::$(uname -m)"
+
+ - name: Install Ubuntu requirements
+ if: startsWith(matrix.os, 'ubuntu')
run: |
- echo "${GITHUB_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin docker.pkg.github.com
- echo ::set-output name=buildx::$(echo docker buildx build --output type=image,name=${{ steps.prepare.outputs.github_image }},push=true \
- --platform ${{ steps.prepare.outputs.docker_platforms }} --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" \
- --tag "${{ steps.prepare.outputs.github_image }}:${{ steps.prepare.outputs.version }}")
- - name: Cache Docker layers
- uses: actions/cache@v2
- id: cache
- with:
- path: /tmp/.buildx-cache
- key: ${{ runner.os }}-buildx-${{ steps.prepare.outputs.version }}
- restore-keys: |
- ${{ runner.os }}-buildx-
- - name: Run Buildx (master)
- if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request'
+ sudo apt update
+ sudo apt -y install autoconf automake bison flex gcc g++ libelf-dev make texinfo libncurses5-dev patch python2-dev subversion wget zlib1g-dev libtool-bin python-dev-is-python3 bzip2 libgmp3-dev pkg-config libssl-dev && \
+ if [ "$(uname -m)" = "x86_64" ]; then sudo apt install -y nvidia-cg-toolkit ; fi
+
+ - name: Install macOS requirements
+ if: startsWith(matrix.os, 'macos')
+ # act -P macos-latest=-self-hosted --container-architecture linux/amd64
run: |
- ${{ steps.login.outputs.buildx }} --tag "${{ steps.prepare.outputs.github_image }}:latest" --file Dockerfile .
- - name: Run Buildx (non-master)
- if: success() && steps.prepare.outputs.version != 'master' && github.event_name != 'pull_request'
+ brew update
+ brew install autoconf automake openssl libelf ncurses zlib gmp wget pkg-config gnu-sed texinfo
+ echo "alias sed='gsed'" >> ~/.bashrc
+
+ # check current version
+ python --version
+ #python-config --libs
+
+ # install pyenv
+ brew install pyenv
+ # Initialize pyenv in the current shell
+ eval "$(pyenv init --path)"
+
+ # Install Python 3.11 using pyenv
+ pyenv install 3.11.0
+ # Set Python 3.11 as the global version
+ pyenv global 3.11.0
+ pip install python-config
+ echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
+ echo 'pyenv global 3.11.0' >> ~/.bashrc
+ echo 'echo bashrc loaded' >> ~/.bashrc
+
+ - name: Runs all the stages in the shell
run: |
- ${{ steps.login.outputs.buildx }} --file Dockerfile .
- - name: Clear
- if: always()
+ . ~/.bashrc
+ mkdir -p $PWD/ps3dev
+ export PS3DEV=$PWD/ps3dev
+ export PSL1GHT=$PS3DEV
+ export PATH=$PATH:$PS3DEV/bin
+ export PATH=$PATH:$PS3DEV/ppu/bin
+ export PATH=$PATH:$PS3DEV/spu/bin
+ export PATH=$PATH:$PS3DEV/portlibs/ppu/bin
+ export PKG_CONFIG_PATH=$PS3DEV/portlibs/ppu/lib/pkgconfig
+ ./toolchain.sh
+
+ - name: Compress ps3dev folder
run: |
- rm -rf ${HOME}/.docker/config.json
+ tar -zcvf ps3dev-${{matrix.os}}-${{steps.arch.outputs.arch}}-${{steps.date.outputs.date}}.tar.gz ps3dev
+
+ - name: Archive Folder
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{matrix.os}}-${{matrix.architecture}}
+ path: ps3dev-*.tar.gz
+
+ publish:
+ needs: build
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Download all Artifact
+ uses: actions/download-artifact@v4
+
+ - name: Set SemVer
+ id: semver
+ run: echo "::set-output name=semver::0.1.0+${{ needs.build.outputs.date }}.${{ needs.build.outputs.sha8 }}"
+
+ - name: Create Tag
+ uses: negz/create-tag@v1
+ with:
+ version: ${{ steps.semver.outputs.semver }}
+ message: "automatic tag creation"
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Create Release
+ id: create_release
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: ${{ steps.semver.outputs.semver }}
+ files: |
+ ${{ github.workspace }}/**/*.tar.gz
+
diff --git a/.gitignore b/.gitignore
index ae20c71b3..7a894455c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
build/
.idea/**
+.DS_Store
+ps3dev
+.vscode
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 4052d3d62..98590a9cc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,26 +1,49 @@
-FROM ubuntu:xenial
-LABEL maintainer="miigotu@gmail.com"
-
+FROM ubuntu:22.04 as base
+# Set the default shell to Bash
+SHELL ["/bin/bash", "-c"]
ENV PS3DEV /usr/local/ps3dev
ENV PSL1GHT ${PS3DEV}
-ENV PATH ${PATH}:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin
-
+ENV PATH ${PATH}:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin:${PS3DEV}/portlibs/ppu/bin
+ENV PKG_CONFIG_PATH ${PS3DEV}/portlibs/ppu/lib/pkgconfig
ENV DEBIAN_FRONTEND=noninteractive
+# last python version with diskutils module support
+ENV PYTHON_VERSION=3.10
+ENV PYENV_ROOT ${HOME}/.pyenv
+ENV PIP_ROOT_USER_ACTION=ignore
+ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:$PATH
+RUN apt update -y && \
+ apt --no-install-recommends install -y autoconf automake bison build-essential bzip2 \
+ ca-certificates cmake flex gettext-base git libelf-dev libgmp3-dev libncurses5-dev libssl-dev \
+ libtool libtool-bin make patch pkg-config texinfo wget xz-utils zlib1g-dev && \
+ # Fixes certificate errors with letsencrypt in ARMv7
+ echo 'ca_certificate=/etc/ssl/certs/ca-certificates.crt' >> /etc/wgetrc && \
+ # Install dependencies specific for amd64 architecture
+ if [ "$(uname -m)" = "x86_64" ]; then apt install -y nvidia-cg-toolkit ; fi && \
+ # pyenv
+ apt --no-install-recommends install -y zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
+ llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev curl git && \
+ echo 'cacert=/etc/ssl/certs/ca-certificates.crt' >> ~/.curlrc && \
+ git config --global http.sslverify 'false' && \
+ curl https://pyenv.run | bash && \
+ pyenv update && pyenv install $PYTHON_VERSION && pyenv global $PYTHON_VERSION && pyenv rehash && \
+ pip install pycrypto && \
+ # pyenv
+ apt -y clean autoclean autoremove
-RUN \
- apt-get -y update && \
- apt-get -y install \
- autoconf bison build-essential ca-certificates flex git libelf-dev\
- libgmp-dev libncurses5-dev libssl-dev libtool-bin pkg-config python-dev \
- texinfo wget zlib1g-dev && \
- apt-get -y clean autoclean autoremove && \
- rm -rf /var/lib/{apt,dpkg,cache,log}/
-
+FROM base as builder
RUN mkdir /build
WORKDIR /build
COPY . /build
-
-# Fixes certificate errors with letsencrypt in ARMv7
-RUN echo "\nca_certificate=/etc/ssl/certs/ca-certificates.crt" | tee -a /etc/wgetrc
RUN /build/toolchain.sh
+FROM base as runtime
+ENV PS3DEV /usr/local/ps3dev
+ENV PSL1GHT ${PS3DEV}
+ENV PATH ${PATH}:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin:${PS3DEV}/portlibs/ppu/bin
+ENV PKG_CONFIG_PATH ${PS3DEV}/portlibs/ppu/lib/pkgconfig
+COPY --from=builder ${PS3DEV} ${PS3DEV}
+
+# How to build and run a multi platform image
+# Tested platforms: linux/amd64 or linux/arm64
+# DOCKER_DEFAULT_PLATFORM=linux/arm64 docker build . -t ps3dev
+# DOCKER_DEFAULT_PLATFORM=linux/arm64 docker run -it -v `pwd`:/build -w /build ps3dev
\ No newline at end of file
diff --git a/patches/binutils-2.22-PS3.patch b/patches/binutils-2.22-PS3-SPU.patch
similarity index 100%
rename from patches/binutils-2.22-PS3.patch
rename to patches/binutils-2.22-PS3-SPU.patch
diff --git a/patches/binutils-2.42-PS3-PPU.patch b/patches/binutils-2.42-PS3-PPU.patch
new file mode 100644
index 000000000..e90893b99
--- /dev/null
+++ b/patches/binutils-2.42-PS3-PPU.patch
@@ -0,0 +1,75 @@
+# Original from https://github.com/ps3dev/ps3toolchain
+# Updated for binutils 2.40 by Darjan Krijan [https://disc-kuraudo.eu]
+diff '--color=auto' -urN a/ld/emulparams/elf32_spu.sh b/ld/emulparams/elf32_spu.sh
+--- a/ld/emulparams/elf32_spu.sh 2022-07-08 11:46:48.000000000 +0200
++++ b/ld/emulparams/elf32_spu.sh 2023-01-04 22:15:19.310575828 +0100
+@@ -6,6 +6,8 @@
+ ARCH=spu
+ MACHINE=
+ ALIGNMENT=16
++GENERATE_PIE_SCRIPT=yes
++GENERATE_COMBRELOC_SCRIPT=yes
+ TEXT_START_ADDR=0
+ INITIAL_READONLY_SECTIONS='.interrupt : { KEEP(*(.interrupt)) }'
+ if test -z "${CREATE_SHLIB}"; then
+diff '--color=auto' -urN a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em
+--- a/ld/emultempl/spuelf.em 2022-07-08 11:46:48.000000000 +0200
++++ b/ld/emultempl/spuelf.em 2023-01-04 22:17:32.998687355 +0100
+@@ -258,6 +258,14 @@
+ return total;
+ }
+
++static void
++spu_before_parse (void)
++{
++ gld${EMULATION_NAME}_before_parse ();
++
++ config.has_pie = `if test -n "$GENERATE_PIE_SCRIPT" ; then echo true ; else echo false ; fi`;
++}
++
+ /* Go find if we need to do anything special for overlays. */
+
+ static void
+@@ -851,5 +859,6 @@
+
+ LDEMUL_AFTER_OPEN=spu_after_open
+ LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
++LDEMUL_BEFORE_PARSE=spu_before_parse
+ LDEMUL_FINISH=gld${EMULATION_NAME}_finish
+ LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
+diff '--color=auto' -urN a/ld/ld.h b/ld/ld.h
+--- a/ld/ld.h 2022-07-08 11:46:48.000000000 +0200
++++ b/ld/ld.h 2023-01-04 22:24:33.832738444 +0100
+@@ -229,6 +229,9 @@
+ parameter. */
+ bool has_shared;
+
++ /* If TRUE, -pie is supported. */
++ bool has_pie;
++
+ /* If TRUE, build constructors. */
+ bool build_constructors;
+
+diff '--color=auto' -urN a/ld/ldmain.c b/ld/ldmain.c
+--- a/ld/ldmain.c 2022-07-08 11:46:48.000000000 +0200
++++ b/ld/ldmain.c 2023-01-04 22:16:46.319346843 +0100
+@@ -315,6 +315,7 @@
+ config.make_executable = true;
+ config.magic_demand_paged = true;
+ config.text_read_only = true;
++ config.has_pie = false;
+ config.print_map_discarded = true;
+ link_info.disable_target_specific_optimizations = -1;
+
+diff '--color=auto' -urN a/ld/lexsup.c b/ld/lexsup.c
+--- a/ld/lexsup.c 2022-07-08 11:46:48.000000000 +0200
++++ b/ld/lexsup.c 2023-01-04 22:17:19.218882047 +0100
+@@ -1286,6 +1286,8 @@
+ if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
+ link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
+ }
++ else if (config.has_pie)
++ link_info.type = type_pie;
+ else
+ einfo (_("%F%P: -shared not supported\n"));
+ break;
diff --git a/patches/gcc-13.2.0-PS3-PPU.patch b/patches/gcc-13.2.0-PS3-PPU.patch
new file mode 100644
index 000000000..9573bf1cf
--- /dev/null
+++ b/patches/gcc-13.2.0-PS3-PPU.patch
@@ -0,0 +1,698 @@
+# Original from https://github.com/ps3dev/ps3toolchain
+# Updated to gcc 9.5.0 by Darjan Krijan [https://disc-kuraudo.eu]
+# Updated to gcc 13.2.0 by luizfernandonb
+# Updated to gcc 13.2.0 by humbertodias
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 648b3dc..650d65f 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2863,6 +2863,15 @@ pdp11-*-*)
+ # tmake_file="${tmake_file} rs6000/t-fprules"
+ # extra_headers=
+ # ;;
++powerpc64-ps3-elf)
++ tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/default64.h"
++ tm_file="rs6000/biarch64.h ${tm_file} rs6000/cell64lv2.h"
++ if test x${enable_secureplt} = xyes; then
++ tm_file="rs6000/secureplt.h ${tm_file}"
++ fi
++ extra_options="${extra_options} rs6000/sysv4.opt"
++ tmake_file="rs6000/t-fprules rs6000/t-fprules-fpbit rs6000/t-ppcgas rs6000/t-ppccomm"
++ ;;
+ powerpc-*-darwin*)
+ extra_options="${extra_options} ${cpu_type}/darwin.opt"
+ case ${target} in
+diff --git a/gcc/config/rs6000/cell64lv2.h b/gcc/config/rs6000/cell64lv2.h
+new file mode 100644
+index 0000000..4a34fca
+--- /dev/null
++++ b/gcc/config/rs6000/cell64lv2.h
+@@ -0,0 +1,583 @@
++/* Definitions of target machine for GNU compiler,
++ for 64 bit PowerPC linux.
++ Copyright (C) 2000-2017 Free Software Foundation, Inc.
++
++ This file is part of GCC.
++
++ GCC is free software; you can redistribute it and/or modify it
++ under the terms of the GNU General Public License as published
++ by the Free Software Foundation; either version 3, or (at your
++ option) any later version.
++
++ GCC is distributed in the hope that it will be useful, but WITHOUT
++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
++ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
++ License for more details.
++
++ Under Section 7 of GPL version 3, you are granted additional
++ permissions described in the GCC Runtime Library Exception, version
++ 3.1, as published by the Free Software Foundation.
++
++ You should have received a copy of the GNU General Public License and
++ a copy of the GCC Runtime Library Exception along with this program;
++ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
++ . */
++
++#ifndef RS6000_BI_ARCH
++
++#undef TARGET_64BIT
++#define TARGET_64BIT 1
++
++#define DEFAULT_ARCH64_P 1
++#define RS6000_BI_ARCH_P 0
++
++#else
++
++#define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
++#define RS6000_BI_ARCH_P 1
++
++#endif
++
++#ifdef IN_LIBGCC2
++#undef TARGET_64BIT
++#ifdef __powerpc64__
++#define TARGET_64BIT 1
++#else
++#define TARGET_64BIT 0
++#endif
++#endif
++
++#undef TARGET_AIX
++#define TARGET_AIX TARGET_64BIT
++
++#ifdef HAVE_LD_NO_DOT_SYMS
++/* New ABI uses a local sym for the function entry point. */
++extern int dot_symbols;
++#undef DOT_SYMBOLS
++#define DOT_SYMBOLS dot_symbols
++#endif
++
++#undef TARGET_KEEP_LEAF_WHEN_PROFILED
++#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled
++
++#define TARGET_USES_LINUX64_OPT 1
++#ifdef HAVE_LD_LARGE_TOC
++#undef TARGET_CMODEL
++#define TARGET_CMODEL rs6000_current_cmodel
++#define SET_CMODEL(opt) rs6000_current_cmodel = opt
++#else
++#define SET_CMODEL(opt) do {} while (0)
++#endif
++
++#undef PROCESSOR_DEFAULT
++#define PROCESSOR_DEFAULT PROCESSOR_CELL
++#undef PROCESSOR_DEFAULT64
++#define PROCESSOR_DEFAULT64 PROCESSOR_CELL
++
++/* We don't need to generate entries in .fixup, except when
++ -mrelocatable or -mrelocatable-lib is given. */
++#undef RELOCATABLE_NEEDS_FIXUP
++#define RELOCATABLE_NEEDS_FIXUP \
++ (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
++
++#undef RS6000_ABI_NAME
++#define RS6000_ABI_NAME "linux"
++
++#define INVALID_64BIT "-m%s not supported in this configuration"
++#define INVALID_32BIT INVALID_64BIT
++
++#ifdef LINUX64_DEFAULT_ABI_ELFv2
++#define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
++#else
++#define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
++#endif
++
++#undef SUBSUBTARGET_OVERRIDE_OPTIONS
++#define SUBSUBTARGET_OVERRIDE_OPTIONS \
++ do \
++ { \
++ if (!global_options_set.x_rs6000_alignment_flags) \
++ rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
++ if (rs6000_isa_flags & OPTION_MASK_64BIT) \
++ { \
++ if (DEFAULT_ABI != ABI_AIX) \
++ { \
++ rs6000_current_abi = ABI_AIX; \
++ error (INVALID_64BIT, "call"); \
++ } \
++ dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
++ if (ELFv2_ABI_CHECK) \
++ { \
++ rs6000_current_abi = ABI_ELFv2; \
++ if (dot_symbols) \
++ error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \
++ } \
++ if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
++ { \
++ rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
++ error (INVALID_64BIT, "relocatable"); \
++ } \
++ if (rs6000_isa_flags & OPTION_MASK_EABI) \
++ { \
++ rs6000_isa_flags &= ~OPTION_MASK_EABI; \
++ error (INVALID_64BIT, "eabi"); \
++ } \
++ if (TARGET_PROTOTYPE) \
++ { \
++ target_prototype = 0; \
++ error (INVALID_64BIT, "prototype"); \
++ } \
++ if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
++ { \
++ rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
++ error ("-m64 requires a PowerPC64 cpu"); \
++ } \
++ if ((rs6000_isa_flags_explicit \
++ & OPTION_MASK_MINIMAL_TOC) != 0) \
++ { \
++ if (global_options_set.x_rs6000_current_cmodel \
++ && rs6000_current_cmodel != CMODEL_SMALL) \
++ error ("-mcmodel incompatible with other toc options"); \
++ SET_CMODEL (CMODEL_SMALL); \
++ } \
++ else \
++ { \
++ if (!global_options_set.x_rs6000_current_cmodel) \
++ SET_CMODEL (CMODEL_SMALL); \
++ if (rs6000_current_cmodel != CMODEL_SMALL) \
++ { \
++ if (!global_options_set.x_TARGET_NO_FP_IN_TOC) \
++ TARGET_NO_FP_IN_TOC \
++ = rs6000_current_cmodel == CMODEL_MEDIUM; \
++ if (!global_options_set.x_TARGET_NO_SUM_IN_TOC) \
++ TARGET_NO_SUM_IN_TOC = 0; \
++ } \
++ } \
++ } \
++ else \
++ { \
++ if (!RS6000_BI_ARCH_P) \
++ error (INVALID_32BIT, "32"); \
++ if (global_options_set.x_rs6000_current_cmodel) \
++ { \
++ SET_CMODEL (CMODEL_SMALL); \
++ error (INVALID_32BIT, "cmodel"); \
++ } \
++ } \
++ } \
++ while (0)
++
++#undef ASM_DEFAULT_SPEC
++#undef ASM_SPEC
++#undef LINK_SECURE_PLT_SPEC
++
++#ifndef RS6000_BI_ARCH
++#define ASM_DEFAULT_SPEC "-mcell"
++#define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%(link_os_lv2_spec64)"
++#define LINK_SECURE_PLT_SPEC ""
++#else
++#if DEFAULT_ARCH64_P
++#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
++#define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%{m32:%(link_os_lv2_spec32)}%{!m32:%(link_os_lv2_spec64)}"
++#define LINK_SECURE_PLT_SPEC "%{m32: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
++#else
++#define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
++#define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%{!m64:%(link_os_lv2_spec32)}%{m64:%(link_os_lv2_spec64)}"
++#define LINK_SECURE_PLT_SPEC "%{!m64: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
++#endif
++#endif
++
++#define ASM_SPEC32 "-a32 \
++%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
++%{memb|msdata=eabi: -memb}"
++
++#define ASM_SPEC64 "-a64"
++
++#define ASM_SPEC_COMMON "%(asm_cpu) \
++%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
++ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
++
++#undef SUBSUBTARGET_EXTRA_SPECS
++#define SUBSUBTARGET_EXTRA_SPECS \
++ { "asm_spec_common", ASM_SPEC_COMMON }, \
++ { "asm_spec32", ASM_SPEC32 }, \
++ { "asm_spec64", ASM_SPEC64 }, \
++ { "link_os_lv2_spec32", LINK_OS_LV2_SPEC32 }, \
++ { "link_os_lv2_spec64", LINK_OS_LV2_SPEC64 }, \
++ { "lib_lv2", LIB_LV2_SPEC }, \
++ { "startfile_lv2", STARTFILE_LV2_SPEC }, \
++ { "endfile_lv2", ENDFILE_LV2_SPEC }, \
++ { "link_start_lv2", LINK_START_LV2_SPEC }, \
++ { "link_os_lv2", LINK_OS_LV2_SPEC }, \
++ { "cpp_os_lv2", CPP_OS_LV2_SPEC }, \
++ { "link_os_extra_spec32", LINK_OS_EXTRA_SPEC32 }, \
++ { "link_os_extra_spec64", LINK_OS_EXTRA_SPEC64 }, \
++ { "link_os_new_dtags", LINK_OS_NEW_DTAGS_SPEC }, \
++ { "include_extra", INCLUDE_EXTRA_SPEC }, \
++ { "dynamic_linker_prefix", DYNAMIC_LINKER_PREFIX }
++
++/* Optional specs used for overriding the system include directory, default
++ -rpath links, and prefix for the dynamic linker. Normally, there are not
++ defined, but if the user configure with the --with-advance-toolchain=
++ option, the advance-toolchain.h file will override these. */
++#ifndef INCLUDE_EXTRA_SPEC
++#define INCLUDE_EXTRA_SPEC ""
++#endif
++
++#ifndef LINK_OS_EXTRA_SPEC32
++#define LINK_OS_EXTRA_SPEC32 ""
++#endif
++
++#ifndef LINK_OS_EXTRA_SPEC64
++#define LINK_OS_EXTRA_SPEC64 ""
++#endif
++
++#ifndef LINK_OS_NEW_DTAGS_SPEC
++#define LINK_OS_NEW_DTAGS_SPEC ""
++#endif
++
++#ifndef DYNAMIC_LINKER_PREFIX
++#define DYNAMIC_LINKER_PREFIX ""
++#endif
++
++#undef MULTILIB_DEFAULTS
++#if DEFAULT_ARCH64_P
++#define MULTILIB_DEFAULTS { "m64" }
++#else
++#define MULTILIB_DEFAULTS { "m32" }
++#endif
++
++/* Split stack is only supported for 64 bit, and requires glibc >= 2.18. */
++#if TARGET_GLIBC_MAJOR * 1000 + TARGET_GLIBC_MINOR >= 2018
++# ifndef RS6000_BI_ARCH
++# define TARGET_CAN_SPLIT_STACK
++# else
++# if DEFAULT_ARCH64_P
++/* Supported, and the default is -m64 */
++# define TARGET_CAN_SPLIT_STACK_64BIT 1
++# else
++/* Supported, and the default is -m32 */
++# define TARGET_CAN_SPLIT_STACK_64BIT 0
++# endif
++# endif
++#endif
++
++#ifndef RS6000_BI_ARCH
++
++/* 64-bit PowerPC Linux always has a TOC. */
++#undef TARGET_TOC
++#define TARGET_TOC 1
++
++/* Some things from sysv4.h we don't do when 64 bit. */
++#undef OPTION_RELOCATABLE
++#define OPTION_RELOCATABLE 0
++#undef OPTION_EABI
++#define OPTION_EABI 0
++#undef OPTION_PROTOTYPE
++#define OPTION_PROTOTYPE 0
++#undef RELOCATABLE_NEEDS_FIXUP
++#define RELOCATABLE_NEEDS_FIXUP 0
++
++#endif
++
++// TODO: Need to remove ?
++/* We use glibc _mcount for profiling. */
++#define NO_PROFILE_COUNTERS 1
++#define PROFILE_HOOK(LABEL) \
++ do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
++
++/* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
++#undef ADJUST_FIELD_ALIGN
++#define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
++ ((TARGET_64BIT \
++ && TARGET_ALIGN_NATURAL == 0 \
++ && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \
++ ? MIN ((COMPUTED), 32) \
++ : (COMPUTED))
++
++/* PowerPC64 Linux increases natural record alignment to doubleword if
++ the first field is an FP double, only if in power alignment mode. */
++#undef ROUND_TYPE_ALIGN
++#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
++ ((TARGET_64BIT \
++ && (TREE_CODE (STRUCT) == RECORD_TYPE \
++ || TREE_CODE (STRUCT) == UNION_TYPE \
++ || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
++ && TARGET_ALIGN_NATURAL == 0) \
++ ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
++ : MAX ((COMPUTED), (SPECIFIED)))
++
++/* Use the default for compiling target libs. */
++#ifdef IN_TARGET_LIBS
++#undef TARGET_ALIGN_NATURAL
++#define TARGET_ALIGN_NATURAL 1
++#endif
++
++/* Indicate that jump tables go in the text section. */
++#undef JUMP_TABLES_IN_TEXT_SECTION
++#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
++
++/* The linux ppc64 ABI isn't explicit on whether aggregates smaller
++ than a doubleword should be padded upward or downward. You could
++ reasonably assume that they follow the normal rules for structure
++ layout treating the parameter area as any other block of memory,
++ then map the reg param area to registers. i.e. pad upward.
++ Setting both of the following defines results in this behavior.
++ Setting just the first one will result in aggregates that fit in a
++ doubleword being padded downward, and others being padded upward.
++ Not a bad idea as this results in struct { int x; } being passed
++ the same way as an int. */
++#define AGGREGATE_PADDING_FIXED TARGET_64BIT
++#define AGGREGATES_PAD_UPWARD_ALWAYS 0
++
++/* Specify padding for the last element of a block move between
++ registers and memory. FIRST is nonzero if this is the only
++ element. */
++#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
++ (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
++
++/* Linux doesn't support saving and restoring 64-bit regs in a 32-bit
++ process. */
++#define OS_MISSING_POWERPC64 !TARGET_64BIT
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do \
++ { \
++ if (TARGET_64BIT) \
++ { \
++ builtin_define ("__PPU__"); \
++ builtin_define ("__PPC__"); \
++ builtin_define ("__PPC64__"); \
++ builtin_define ("__lv2ppu__"); \
++ builtin_define ("__powerpc__"); \
++ builtin_define ("__powerpc64__"); \
++ if (!DOT_SYMBOLS) \
++ builtin_define ("_CALL_LINUX"); \
++ builtin_assert ("cpu=powerpc64"); \
++ builtin_assert ("machine=powerpc64"); \
++ } \
++ else \
++ { \
++ builtin_define_std ("PPC"); \
++ builtin_define_std ("powerpc"); \
++ builtin_assert ("cpu=powerpc"); \
++ builtin_assert ("machine=powerpc"); \
++ TARGET_OS_SYSV_CPP_BUILTINS (); \
++ } \
++ } \
++ while (0)
++
++#undef CPP_OS_DEFAULT_SPEC
++#define CPP_OS_DEFAULT_SPEC "%(cpp_os_lv2) %(include_extra)"
++
++#undef LINK_SHLIB_SPEC
++#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
++
++#undef LIB_DEFAULT_SPEC
++#define LIB_DEFAULT_SPEC "%(lib_lv2)"
++
++#undef STARTFILE_DEFAULT_SPEC
++#define STARTFILE_DEFAULT_SPEC "%(startfile_lv2)"
++
++#undef ENDFILE_DEFAULT_SPEC
++#define ENDFILE_DEFAULT_SPEC "%(endfile_lv2)"
++
++#undef LINK_START_DEFAULT_SPEC
++#define LINK_START_DEFAULT_SPEC "%(link_start_lv2)"
++
++#undef LINK_OS_DEFAULT_SPEC
++#define LINK_OS_DEFAULT_SPEC "%(link_os_lv2)"
++
++#define LIB_LV2_SPEC "-L %:getenv(PSL1GHT /ppu/lib) --start-group -lsysbase -lc -lrt -llv2 --end-group"
++
++#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
++
++#define STARTFILE_LV2_SPEC "lv2-crti.o%s crtbegin.o%s lv2-crt0.o%s lv2-sprx.o%s"
++
++#define ENDFILE_LV2_SPEC "crtend.o%s lv2-crtn.o%s"
++
++#define LINK_START_LV2_SPEC "-T lv2.ld%s"
++
++#define LINK_OS_LV2_SPEC32 "-m elf32ppc"
++#define LINK_OS_LV2_SPEC64 "-m elf64ppc"
++
++#define CPP_OS_LV2_SPEC "-D__lv2ppu__ -ffunction-sections -fdata-sections"
++
++#undef DEFAULT_ASM_ENDIAN
++#if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
++#define DEFAULT_ASM_ENDIAN " -mlittle"
++#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
++ " -m elf32lppclinux", \
++ " -m elf32lppclinux")
++#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
++ " -m elf64lppc", \
++ " -m elf64lppc")
++#else
++#define DEFAULT_ASM_ENDIAN " -mbig"
++#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
++ " -m elf32lppclinux", \
++ " -m elf32ppclinux")
++#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
++ " -m elf64lppc", \
++ " -m elf64ppc")
++#endif
++
++#undef TOC_SECTION_ASM_OP
++#define TOC_SECTION_ASM_OP \
++ (TARGET_64BIT \
++ ? "\t.section\t\".toc\",\"aw\"" \
++ : "\t.section\t\".got\",\"aw\"")
++
++#undef MINIMAL_TOC_SECTION_ASM_OP
++#define MINIMAL_TOC_SECTION_ASM_OP \
++ (TARGET_64BIT \
++ ? "\t.section\t\".toc1\",\"aw\"" \
++ : (flag_pic \
++ ? "\t.section\t\".got2\",\"aw\"" \
++ : "\t.section\t\".got1\",\"aw\""))
++
++/* Must be at least as big as our pointer type. */
++#undef SIZE_TYPE
++#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
++
++#undef PTRDIFF_TYPE
++#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
++
++#undef WCHAR_TYPE
++#define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
++#undef WCHAR_TYPE_SIZE
++#define WCHAR_TYPE_SIZE 32
++
++#undef RS6000_MCOUNT
++#define RS6000_MCOUNT "_mcount"
++
++#ifdef __powerpc64__
++/* _init and _fini functions are built from bits spread across many
++ object files, each potentially with a different TOC pointer. For
++ that reason, place a nop after the call so that the linker can
++ restore the TOC pointer if a TOC adjusting call stub is needed. */
++#if DOT_SYMBOLS
++#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
++ asm (SECTION_OP "\n" \
++" bl ." #FUNC "\n" \
++" nop\n" \
++" .previous");
++#else
++#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
++ asm (SECTION_OP "\n" \
++" bl " #FUNC "\n" \
++" nop\n" \
++" .previous");
++#endif
++#endif
++
++/* FP save and restore routines. */
++#undef SAVE_FP_PREFIX
++#define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
++#undef SAVE_FP_SUFFIX
++#define SAVE_FP_SUFFIX ""
++#undef RESTORE_FP_PREFIX
++#define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
++#undef RESTORE_FP_SUFFIX
++#define RESTORE_FP_SUFFIX ""
++
++/* Dwarf2 debugging. */
++#undef PREFERRED_DEBUGGING_TYPE
++#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
++
++/* This is how to declare the size of a function. */
++#undef ASM_DECLARE_FUNCTION_SIZE
++#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
++ do \
++ { \
++ if (!flag_inhibit_size_directive) \
++ { \
++ fputs ("\t.size\t", (FILE)); \
++ if (TARGET_64BIT && DOT_SYMBOLS) \
++ putc ('.', (FILE)); \
++ assemble_name ((FILE), (FNAME)); \
++ fputs (",.-", (FILE)); \
++ rs6000_output_function_entry (FILE, FNAME); \
++ putc ('\n', (FILE)); \
++ } \
++ } \
++ while (0)
++
++/* Return nonzero if this entry is to be written into the constant
++ pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
++ or a CONST containing one of them. If -mfp-in-toc (the default),
++ we also do this for floating-point constants. We actually can only
++ do this if the FP formats of the target and host machines are the
++ same, but we can't check that since not every file that uses
++ the macros includes real.h. We also do this when we can write the
++ entry into the TOC and the entry is not larger than a TOC entry. */
++
++#undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
++#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
++ (TARGET_TOC \
++ && (GET_CODE (X) == SYMBOL_REF \
++ || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
++ && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
++ || GET_CODE (X) == LABEL_REF \
++ || (GET_CODE (X) == CONST_INT \
++ && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
++ || (GET_CODE (X) == CONST_DOUBLE \
++ && ((TARGET_64BIT \
++ && (TARGET_MINIMAL_TOC \
++ || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
++ && ! TARGET_NO_FP_IN_TOC))) \
++ || (!TARGET_64BIT \
++ && !TARGET_NO_FP_IN_TOC \
++ && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
++ && BITS_PER_WORD == HOST_BITS_PER_INT)))))
++
++/* Select a format to encode pointers in exception handling data. CODE
++ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
++ true if the symbol may be affected by dynamic relocations. */
++#undef ASM_PREFERRED_EH_DATA_FORMAT
++#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
++ (TARGET_64BIT || flag_pic \
++ ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
++ | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
++ : DW_EH_PE_absptr)
++
++/* For backward compatibility, we must continue to use the AIX
++ structure return convention. */
++#undef DRAFT_V4_STRUCT_RET
++#define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
++
++#ifdef TARGET_LIBC_PROVIDES_SSP
++/* ppc32 glibc provides __stack_chk_guard in -0x7008(2),
++ ppc64 glibc provides it at -0x7010(13). */
++#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008)
++#endif
++
++#define POINTERS_EXTEND_UNSIGNED 1
++
++/* ppc{32,64} linux has 128-bit long double support in glibc 2.4 and later. */
++#ifdef TARGET_DEFAULT_LONG_DOUBLE_128
++#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
++#endif
++
++/* Static stack checking is supported by means of probes. */
++#define STACK_CHECK_STATIC_BUILTIN 1
++
++/* The default value isn't sufficient in 64-bit mode. */
++#define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
++
++/* Support for TARGET_ATOMIC_ASSIGN_EXPAND_FENV without FPRs depends
++ on glibc 2.19 or greater. */
++#if TARGET_GLIBC_MAJOR > 2 \
++ || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 19)
++#define RS6000_GLIBC_ATOMIC_FENV 1
++#endif
++
++/* The IEEE 128-bit emulator is only built on Linux systems. Flag that we
++ should enable the type handling for KFmode on VSX systems even if we are not
++ enabling the __float128 keyword. */
++#undef TARGET_FLOAT128_ENABLE_TYPE
++#define TARGET_FLOAT128_ENABLE_TYPE 1
+\ No newline at end of file
+diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
+index 196bcbe..11430b8 100644
+--- a/gcc/config/rs6000/rs6000.cc
++++ b/gcc/config/rs6000/rs6000.cc
+@@ -1762,6 +1762,17 @@ static const struct attribute_spec rs6000_attribute_table[] =
+ #define TARGET_UPDATE_IPA_FN_TARGET_INFO rs6000_update_ipa_fn_target_info
+
+
++static bool rs6000_cell64lv2_valid_pointer_mode(scalar_int_mode);
++
++static bool
++rs6000_cell64lv2_valid_pointer_mode(scalar_int_mode mode)
++{
++ return (mode == SImode || (TARGET_64BIT && mode == DImode) || mode == ptr_mode || mode == Pmode);
++}
++
++#undef TARGET_VALID_POINTER_MODE
++#define TARGET_VALID_POINTER_MODE rs6000_cell64lv2_valid_pointer_mode
++
+ /* Processor table. */
+ struct rs6000_ptt
+ {
+@@ -3491,7 +3502,7 @@ rs6000_linux64_override_options ()
+ {
+ if (TARGET_PROFILE_KERNEL)
+ {
+- profile_kernel = 0;
++ //profile_kernel = 0; Why???
+ error (INVALID_32BIT, "profile-kernel");
+ }
+ if (OPTION_SET_P (rs6000_current_cmodel))
+diff --git a/gcc/configure b/gcc/configure
+index c7b26d1..85e83d3 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -30787,12 +30787,12 @@ $as_echo "#define HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE 1" >>confdefs.h
+ esac
+
+ case "$target:$tm_file" in
+- powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
++ powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc64-ps3-elf* | powerpc*-*-linux*rs6000/biarch64.h*)
+ case "$target" in
+ *le-*-linux*)
+ emul_name="-melf64lppc"
+ ;;
+- *-*-linux*)
++ *-*-linux* | *-ps3-elf*)
+ emul_name="-melf64ppc"
+ ;;
+ *le-*-freebsd*)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 9d72120..7ddde1d 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -1224,6 +1224,9 @@ powerpc-*-rtems*)
+ tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+ extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
+ ;;
++powerpc64-ps3-elf)
++ tmake_file="${tmake_file} rs6000/t-crtstuff-cell64lv2"
++ ;;
+ powerpc*-*-linux*)
+ tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-linux t-dfprules rs6000/t-ppc64-fp t-slibgcc-libgcc"
+ tmake_file="${tmake_file} t-stack rs6000/t-stack-rs6000"
+diff --git a/libgcc/config/rs6000/t-crtstuff-cell64lv2 b/libgcc/config/rs6000/t-crtstuff-cell64lv2
+new file mode 100644
+index 0000000..9eb9ca7
+--- /dev/null
++++ b/libgcc/config/rs6000/t-crtstuff-cell64lv2
+@@ -0,0 +1 @@
++CRTSTUFF_T_CFLAGS = -fno-asynchronous-unwind-tables
+\ No newline at end of file
+diff --git a/Makefile.in b/Makefile.in
+index 06a9398..7419f7e 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -28118,7 +28118,6 @@ check-libiberty:
+ .PHONY: install-libiberty maybe-install-libiberty
+ maybe-install-libiberty:
+ @if libiberty
+-maybe-install-libiberty: install-libiberty
+
+ install-libiberty: installdirs
+ @: $(MAKE); $(unstage)
diff --git a/patches/gcc-9.5.0-PS3-SPU.patch b/patches/gcc-9.5.0-PS3-SPU.patch
new file mode 100644
index 000000000..1292e356d
--- /dev/null
+++ b/patches/gcc-9.5.0-PS3-SPU.patch
@@ -0,0 +1,705 @@
+# Original from https://github.com/ps3dev/ps3toolchain
+# Updated to gcc 9.5.0 by Darjan Krijan [https://disc-kuraudo.eu]
+diff '--color=auto' -urN a/gcc/config/rs6000/cell64lv2.h b/gcc/config/rs6000/cell64lv2.h
+--- a/gcc/config/rs6000/cell64lv2.h 1970-01-01 01:00:00.000000000 +0100
++++ b/gcc/config/rs6000/cell64lv2.h 2023-01-01 17:58:23.274094209 +0100
+@@ -0,0 +1,587 @@
++/* Definitions of target machine for GNU compiler,
++ for 64 bit PowerPC linux.
++ Copyright (C) 2000-2017 Free Software Foundation, Inc.
++
++ This file is part of GCC.
++
++ GCC is free software; you can redistribute it and/or modify it
++ under the terms of the GNU General Public License as published
++ by the Free Software Foundation; either version 3, or (at your
++ option) any later version.
++
++ GCC is distributed in the hope that it will be useful, but WITHOUT
++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
++ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
++ License for more details.
++
++ Under Section 7 of GPL version 3, you are granted additional
++ permissions described in the GCC Runtime Library Exception, version
++ 3.1, as published by the Free Software Foundation.
++
++ You should have received a copy of the GNU General Public License and
++ a copy of the GCC Runtime Library Exception along with this program;
++ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
++ . */
++
++#ifndef RS6000_BI_ARCH
++
++#undef TARGET_64BIT
++#define TARGET_64BIT 1
++
++#define DEFAULT_ARCH64_P 1
++#define RS6000_BI_ARCH_P 0
++
++#else
++
++#define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
++#define RS6000_BI_ARCH_P 1
++
++#endif
++
++#ifdef IN_LIBGCC2
++#undef TARGET_64BIT
++#ifdef __powerpc64__
++#define TARGET_64BIT 1
++#else
++#define TARGET_64BIT 0
++#endif
++#endif
++
++#undef TARGET_AIX
++#define TARGET_AIX TARGET_64BIT
++
++#ifdef HAVE_LD_NO_DOT_SYMS
++/* New ABI uses a local sym for the function entry point. */
++extern int dot_symbols;
++#undef DOT_SYMBOLS
++#define DOT_SYMBOLS dot_symbols
++#endif
++
++#undef TARGET_KEEP_LEAF_WHEN_PROFILED
++#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled
++
++#define TARGET_USES_LINUX64_OPT 1
++#ifdef HAVE_LD_LARGE_TOC
++#undef TARGET_CMODEL
++#define TARGET_CMODEL rs6000_current_cmodel
++#define SET_CMODEL(opt) rs6000_current_cmodel = opt
++#else
++#define SET_CMODEL(opt) do {} while (0)
++#endif
++
++#undef PROCESSOR_DEFAULT
++#define PROCESSOR_DEFAULT PROCESSOR_CELL
++#undef PROCESSOR_DEFAULT64
++#define PROCESSOR_DEFAULT64 PROCESSOR_CELL
++
++/* We don't need to generate entries in .fixup, except when
++ -mrelocatable or -mrelocatable-lib is given. */
++#undef RELOCATABLE_NEEDS_FIXUP
++#define RELOCATABLE_NEEDS_FIXUP \
++ (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
++
++#undef RS6000_ABI_NAME
++#define RS6000_ABI_NAME "linux"
++
++#define INVALID_64BIT "-m%s not supported in this configuration"
++#define INVALID_32BIT INVALID_64BIT
++
++#ifdef LINUX64_DEFAULT_ABI_ELFv2
++#define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
++#else
++#define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
++#endif
++
++#undef SUBSUBTARGET_OVERRIDE_OPTIONS
++#define SUBSUBTARGET_OVERRIDE_OPTIONS \
++ do \
++ { \
++ if (!global_options_set.x_rs6000_alignment_flags) \
++ rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
++ if (rs6000_isa_flags & OPTION_MASK_64BIT) \
++ { \
++ if (DEFAULT_ABI != ABI_AIX) \
++ { \
++ rs6000_current_abi = ABI_AIX; \
++ error (INVALID_64BIT, "call"); \
++ } \
++ dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
++ if (ELFv2_ABI_CHECK) \
++ { \
++ rs6000_current_abi = ABI_ELFv2; \
++ if (dot_symbols) \
++ error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \
++ } \
++ if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
++ { \
++ rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
++ error (INVALID_64BIT, "relocatable"); \
++ } \
++ if (rs6000_isa_flags & OPTION_MASK_EABI) \
++ { \
++ rs6000_isa_flags &= ~OPTION_MASK_EABI; \
++ error (INVALID_64BIT, "eabi"); \
++ } \
++ if (TARGET_PROTOTYPE) \
++ { \
++ target_prototype = 0; \
++ error (INVALID_64BIT, "prototype"); \
++ } \
++ if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
++ { \
++ rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
++ error ("-m64 requires a PowerPC64 cpu"); \
++ } \
++ if ((rs6000_isa_flags_explicit \
++ & OPTION_MASK_MINIMAL_TOC) != 0) \
++ { \
++ if (global_options_set.x_rs6000_current_cmodel \
++ && rs6000_current_cmodel != CMODEL_SMALL) \
++ error ("-mcmodel incompatible with other toc options"); \
++ SET_CMODEL (CMODEL_SMALL); \
++ } \
++ else \
++ { \
++ if (!global_options_set.x_rs6000_current_cmodel) \
++ SET_CMODEL (CMODEL_SMALL); \
++ if (rs6000_current_cmodel != CMODEL_SMALL) \
++ { \
++ if (!global_options_set.x_TARGET_NO_FP_IN_TOC) \
++ TARGET_NO_FP_IN_TOC \
++ = rs6000_current_cmodel == CMODEL_MEDIUM; \
++ if (!global_options_set.x_TARGET_NO_SUM_IN_TOC) \
++ TARGET_NO_SUM_IN_TOC = 0; \
++ } \
++ } \
++ } \
++ else \
++ { \
++ if (!RS6000_BI_ARCH_P) \
++ error (INVALID_32BIT, "32"); \
++ if (global_options_set.x_rs6000_current_cmodel) \
++ { \
++ SET_CMODEL (CMODEL_SMALL); \
++ error (INVALID_32BIT, "cmodel"); \
++ } \
++ } \
++ } \
++ while (0)
++
++#undef ASM_DEFAULT_SPEC
++#undef ASM_SPEC
++#undef LINK_SECURE_PLT_SPEC
++
++#ifndef RS6000_BI_ARCH
++#define ASM_DEFAULT_SPEC "-mcell"
++#define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%(link_os_lv2_spec64)"
++#define LINK_SECURE_PLT_SPEC ""
++#else
++#if DEFAULT_ARCH64_P
++#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
++#define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%{m32:%(link_os_lv2_spec32)}%{!m32:%(link_os_lv2_spec64)}"
++#define LINK_SECURE_PLT_SPEC "%{m32: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
++#else
++#define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
++#define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
++#define LINK_OS_LV2_SPEC "%{!m64:%(link_os_lv2_spec32)}%{m64:%(link_os_lv2_spec64)}"
++#define LINK_SECURE_PLT_SPEC "%{!m64: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
++#endif
++#endif
++
++#define ASM_SPEC32 "-a32 \
++%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
++%{memb|msdata=eabi: -memb}"
++
++#define ASM_SPEC64 "-a64"
++
++#define ASM_SPEC_COMMON "%(asm_cpu) \
++%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
++ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
++
++#undef SUBSUBTARGET_EXTRA_SPECS
++#define SUBSUBTARGET_EXTRA_SPECS \
++ { "asm_spec_common", ASM_SPEC_COMMON }, \
++ { "asm_spec32", ASM_SPEC32 }, \
++ { "asm_spec64", ASM_SPEC64 }, \
++ { "link_os_lv2_spec32", LINK_OS_LV2_SPEC32 }, \
++ { "link_os_lv2_spec64", LINK_OS_LV2_SPEC64 }, \
++ { "lib_lv2", LIB_LV2_SPEC }, \
++ { "startfile_lv2", STARTFILE_LV2_SPEC }, \
++ { "endfile_lv2", ENDFILE_LV2_SPEC }, \
++ { "link_start_lv2", LINK_START_LV2_SPEC }, \
++ { "link_os_lv2", LINK_OS_LV2_SPEC }, \
++ { "cpp_os_lv2", CPP_OS_LV2_SPEC }, \
++ { "link_os_extra_spec32", LINK_OS_EXTRA_SPEC32 }, \
++ { "link_os_extra_spec64", LINK_OS_EXTRA_SPEC64 }, \
++ { "link_os_new_dtags", LINK_OS_NEW_DTAGS_SPEC }, \
++ { "include_extra", INCLUDE_EXTRA_SPEC }, \
++ { "dynamic_linker_prefix", DYNAMIC_LINKER_PREFIX }
++
++/* Optional specs used for overriding the system include directory, default
++ -rpath links, and prefix for the dynamic linker. Normally, there are not
++ defined, but if the user configure with the --with-advance-toolchain=
++ option, the advance-toolchain.h file will override these. */
++#ifndef INCLUDE_EXTRA_SPEC
++#define INCLUDE_EXTRA_SPEC ""
++#endif
++
++#ifndef LINK_OS_EXTRA_SPEC32
++#define LINK_OS_EXTRA_SPEC32 ""
++#endif
++
++#ifndef LINK_OS_EXTRA_SPEC64
++#define LINK_OS_EXTRA_SPEC64 ""
++#endif
++
++#ifndef LINK_OS_NEW_DTAGS_SPEC
++#define LINK_OS_NEW_DTAGS_SPEC ""
++#endif
++
++#ifndef DYNAMIC_LINKER_PREFIX
++#define DYNAMIC_LINKER_PREFIX ""
++#endif
++
++#undef MULTILIB_DEFAULTS
++#if DEFAULT_ARCH64_P
++#define MULTILIB_DEFAULTS { "m64" }
++#else
++#define MULTILIB_DEFAULTS { "m32" }
++#endif
++
++/* Split stack is only supported for 64 bit, and requires glibc >= 2.18. */
++#if TARGET_GLIBC_MAJOR * 1000 + TARGET_GLIBC_MINOR >= 2018
++# ifndef RS6000_BI_ARCH
++# define TARGET_CAN_SPLIT_STACK
++# else
++# if DEFAULT_ARCH64_P
++/* Supported, and the default is -m64 */
++# define TARGET_CAN_SPLIT_STACK_64BIT 1
++# else
++/* Supported, and the default is -m32 */
++# define TARGET_CAN_SPLIT_STACK_64BIT 0
++# endif
++# endif
++#endif
++
++#ifndef RS6000_BI_ARCH
++
++/* 64-bit PowerPC Linux always has a TOC. */
++#undef TARGET_TOC
++#define TARGET_TOC 1
++
++/* Some things from sysv4.h we don't do when 64 bit. */
++#undef OPTION_RELOCATABLE
++#define OPTION_RELOCATABLE 0
++#undef OPTION_EABI
++#define OPTION_EABI 0
++#undef OPTION_PROTOTYPE
++#define OPTION_PROTOTYPE 0
++#undef RELOCATABLE_NEEDS_FIXUP
++#define RELOCATABLE_NEEDS_FIXUP 0
++
++#endif
++
++// TODO: Need to remove ?
++/* We use glibc _mcount for profiling. */
++#define NO_PROFILE_COUNTERS 1
++#define PROFILE_HOOK(LABEL) \
++ do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
++
++/* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
++#undef ADJUST_FIELD_ALIGN
++#define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
++ (rs6000_special_adjust_field_align_p ((TYPE), (COMPUTED)) \
++ ? 128 \
++ : (TARGET_64BIT \
++ && TARGET_ALIGN_NATURAL == 0 \
++ && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \
++ ? MIN ((COMPUTED), 32) \
++ : (COMPUTED))
++
++/* PowerPC64 Linux increases natural record alignment to doubleword if
++ the first field is an FP double, only if in power alignment mode. */
++#undef ROUND_TYPE_ALIGN
++#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
++ ((TARGET_64BIT \
++ && (TREE_CODE (STRUCT) == RECORD_TYPE \
++ || TREE_CODE (STRUCT) == UNION_TYPE \
++ || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
++ && TARGET_ALIGN_NATURAL == 0) \
++ ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
++ : MAX ((COMPUTED), (SPECIFIED)))
++
++/* Use the default for compiling target libs. */
++#ifdef IN_TARGET_LIBS
++#undef TARGET_ALIGN_NATURAL
++#define TARGET_ALIGN_NATURAL 1
++#endif
++
++/* Indicate that jump tables go in the text section. */
++#undef JUMP_TABLES_IN_TEXT_SECTION
++#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
++
++/* The linux ppc64 ABI isn't explicit on whether aggregates smaller
++ than a doubleword should be padded upward or downward. You could
++ reasonably assume that they follow the normal rules for structure
++ layout treating the parameter area as any other block of memory,
++ then map the reg param area to registers. i.e. pad upward.
++ Setting both of the following defines results in this behavior.
++ Setting just the first one will result in aggregates that fit in a
++ doubleword being padded downward, and others being padded upward.
++ Not a bad idea as this results in struct { int x; } being passed
++ the same way as an int. */
++#define AGGREGATE_PADDING_FIXED TARGET_64BIT
++#define AGGREGATES_PAD_UPWARD_ALWAYS 0
++
++/* Specify padding for the last element of a block move between
++ registers and memory. FIRST is nonzero if this is the only
++ element. */
++#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
++ (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
++
++/* Linux doesn't support saving and restoring 64-bit regs in a 32-bit
++ process. */
++#define OS_MISSING_POWERPC64 !TARGET_64BIT
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do \
++ { \
++ if (TARGET_64BIT) \
++ { \
++ builtin_define ("__PPU__"); \
++ builtin_define ("__PPC__"); \
++ builtin_define ("__PPC64__"); \
++ builtin_define ("__lv2ppu__"); \
++ builtin_define ("__powerpc__"); \
++ builtin_define ("__powerpc64__"); \
++ if (!DOT_SYMBOLS) \
++ builtin_define ("_CALL_LINUX"); \
++ builtin_assert ("cpu=powerpc64"); \
++ builtin_assert ("machine=powerpc64"); \
++ } \
++ else \
++ { \
++ builtin_define_std ("PPC"); \
++ builtin_define_std ("powerpc"); \
++ builtin_assert ("cpu=powerpc"); \
++ builtin_assert ("machine=powerpc"); \
++ TARGET_OS_SYSV_CPP_BUILTINS (); \
++ } \
++ } \
++ while (0)
++
++#undef CPP_OS_DEFAULT_SPEC
++#define CPP_OS_DEFAULT_SPEC "%(cpp_os_lv2) %(include_extra)"
++
++#undef LINK_SHLIB_SPEC
++#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
++
++#undef LIB_DEFAULT_SPEC
++#define LIB_DEFAULT_SPEC "%(lib_lv2)"
++
++#undef STARTFILE_DEFAULT_SPEC
++#define STARTFILE_DEFAULT_SPEC "%(startfile_lv2)"
++
++#undef ENDFILE_DEFAULT_SPEC
++#define ENDFILE_DEFAULT_SPEC "%(endfile_lv2)"
++
++#undef LINK_START_DEFAULT_SPEC
++#define LINK_START_DEFAULT_SPEC "%(link_start_lv2)"
++
++#undef LINK_OS_DEFAULT_SPEC
++#define LINK_OS_DEFAULT_SPEC "%(link_os_lv2)"
++
++#define LIB_LV2_SPEC "-L %:getenv(PSL1GHT /ppu/lib) --start-group -lsysbase -lc -lrt -llv2 --end-group"
++
++#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
++
++#define STARTFILE_LV2_SPEC "lv2-crti.o%s crtbegin.o%s lv2-crt0.o%s lv2-sprx.o%s"
++
++#define ENDFILE_LV2_SPEC "crtend.o%s lv2-crtn.o%s"
++
++#define LINK_START_LV2_SPEC "-T lv2.ld%s"
++
++#define LINK_OS_LV2_SPEC32 "-m elf32ppc"
++#define LINK_OS_LV2_SPEC64 "-m elf64ppc"
++
++#define CPP_OS_LV2_SPEC "-D__lv2ppu__ -ffunction-sections -fdata-sections"
++
++#undef DEFAULT_ASM_ENDIAN
++#if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
++#define DEFAULT_ASM_ENDIAN " -mlittle"
++#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
++ " -m elf32lppclinux", \
++ " -m elf32lppclinux")
++#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
++ " -m elf64lppc", \
++ " -m elf64lppc")
++#else
++#define DEFAULT_ASM_ENDIAN " -mbig"
++#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
++ " -m elf32lppclinux", \
++ " -m elf32ppclinux")
++#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
++ " -m elf64lppc", \
++ " -m elf64ppc")
++#endif
++
++#undef TOC_SECTION_ASM_OP
++#define TOC_SECTION_ASM_OP \
++ (TARGET_64BIT \
++ ? "\t.section\t\".toc\",\"aw\"" \
++ : "\t.section\t\".got\",\"aw\"")
++
++#undef MINIMAL_TOC_SECTION_ASM_OP
++#define MINIMAL_TOC_SECTION_ASM_OP \
++ (TARGET_64BIT \
++ ? "\t.section\t\".toc1\",\"aw\"" \
++ : (flag_pic \
++ ? "\t.section\t\".got2\",\"aw\"" \
++ : "\t.section\t\".got1\",\"aw\""))
++
++/* Must be at least as big as our pointer type. */
++#undef SIZE_TYPE
++#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
++
++#undef PTRDIFF_TYPE
++#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
++
++#undef WCHAR_TYPE
++#define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
++#undef WCHAR_TYPE_SIZE
++#define WCHAR_TYPE_SIZE 32
++
++#undef RS6000_MCOUNT
++#define RS6000_MCOUNT "_mcount"
++
++#ifdef __powerpc64__
++/* _init and _fini functions are built from bits spread across many
++ object files, each potentially with a different TOC pointer. For
++ that reason, place a nop after the call so that the linker can
++ restore the TOC pointer if a TOC adjusting call stub is needed. */
++#if DOT_SYMBOLS
++#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
++ asm (SECTION_OP "\n" \
++" bl ." #FUNC "\n" \
++" nop\n" \
++" .previous");
++#else
++#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
++ asm (SECTION_OP "\n" \
++" bl " #FUNC "\n" \
++" nop\n" \
++" .previous");
++#endif
++#endif
++
++/* FP save and restore routines. */
++#undef SAVE_FP_PREFIX
++#define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
++#undef SAVE_FP_SUFFIX
++#define SAVE_FP_SUFFIX ""
++#undef RESTORE_FP_PREFIX
++#define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
++#undef RESTORE_FP_SUFFIX
++#define RESTORE_FP_SUFFIX ""
++
++/* Dwarf2 debugging. */
++#undef PREFERRED_DEBUGGING_TYPE
++#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
++
++/* This is how to declare the size of a function. */
++#undef ASM_DECLARE_FUNCTION_SIZE
++#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
++ do \
++ { \
++ if (!flag_inhibit_size_directive) \
++ { \
++ fputs ("\t.size\t", (FILE)); \
++ if (TARGET_64BIT && DOT_SYMBOLS) \
++ putc ('.', (FILE)); \
++ assemble_name ((FILE), (FNAME)); \
++ fputs (",.-", (FILE)); \
++ rs6000_output_function_entry (FILE, FNAME); \
++ putc ('\n', (FILE)); \
++ } \
++ } \
++ while (0)
++
++/* Return nonzero if this entry is to be written into the constant
++ pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
++ or a CONST containing one of them. If -mfp-in-toc (the default),
++ we also do this for floating-point constants. We actually can only
++ do this if the FP formats of the target and host machines are the
++ same, but we can't check that since not every file that uses
++ the macros includes real.h. We also do this when we can write the
++ entry into the TOC and the entry is not larger than a TOC entry. */
++
++#undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
++#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
++ (TARGET_TOC \
++ && (GET_CODE (X) == SYMBOL_REF \
++ || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
++ && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
++ || GET_CODE (X) == LABEL_REF \
++ || (GET_CODE (X) == CONST_INT \
++ && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
++ || (GET_CODE (X) == CONST_DOUBLE \
++ && ((TARGET_64BIT \
++ && (TARGET_MINIMAL_TOC \
++ || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
++ && ! TARGET_NO_FP_IN_TOC))) \
++ || (!TARGET_64BIT \
++ && !TARGET_NO_FP_IN_TOC \
++ && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
++ && BITS_PER_WORD == HOST_BITS_PER_INT)))))
++
++/* Select a format to encode pointers in exception handling data. CODE
++ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
++ true if the symbol may be affected by dynamic relocations. */
++#undef ASM_PREFERRED_EH_DATA_FORMAT
++#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
++ (TARGET_64BIT || flag_pic \
++ ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
++ | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
++ : DW_EH_PE_absptr)
++
++/* For backward compatibility, we must continue to use the AIX
++ structure return convention. */
++#undef DRAFT_V4_STRUCT_RET
++#define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
++
++#ifdef TARGET_LIBC_PROVIDES_SSP
++/* ppc32 glibc provides __stack_chk_guard in -0x7008(2),
++ ppc64 glibc provides it at -0x7010(13). */
++#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008)
++#endif
++
++#define POWERPC_CELL64LV2
++
++#define POINTERS_EXTEND_UNSIGNED 1
++
++/* ppc{32,64} linux has 128-bit long double support in glibc 2.4 and later. */
++#ifdef TARGET_DEFAULT_LONG_DOUBLE_128
++#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
++#endif
++
++/* Static stack checking is supported by means of probes. */
++#define STACK_CHECK_STATIC_BUILTIN 1
++
++/* The default value isn't sufficient in 64-bit mode. */
++#define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
++
++/* Support for TARGET_ATOMIC_ASSIGN_EXPAND_FENV without FPRs depends
++ on glibc 2.19 or greater. */
++#if TARGET_GLIBC_MAJOR > 2 \
++ || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 19)
++#define RS6000_GLIBC_ATOMIC_FENV 1
++#endif
++
++/* The IEEE 128-bit emulator is only built on Linux systems. Flag that we
++ should enable the type handling for KFmode on VSX systems even if we are not
++ enabling the __float128 keyword. */
++#undef TARGET_FLOAT128_ENABLE_TYPE
++#define TARGET_FLOAT128_ENABLE_TYPE 1
+diff '--color=auto' -urN a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
+--- a/gcc/config/rs6000/rs6000.c 2022-05-27 09:21:11.000000000 +0200
++++ b/gcc/config/rs6000/rs6000.c 2023-01-01 18:00:32.742783224 +0100
+@@ -1424,6 +1424,10 @@
+ static bool rs6000_keep_leaf_when_profiled () __attribute__ ((unused));
+ static tree rs6000_fold_builtin (tree, int, tree *, bool);
+
++#ifdef POWERPC_CELL64LV2
++static bool rs6000_cell64lv2_valid_pointer_mode(scalar_int_mode);
++#endif
++
+ /* Hash table stuff for keeping track of TOC entries. */
+
+ struct GTY((for_user)) toc_hash_struct
+@@ -39732,7 +39736,18 @@
+ return id;
+ }
+
+-
++#ifdef POWERPC_CELL64LV2
++#undef TARGET_VALID_POINTER_MODE
++#define TARGET_VALID_POINTER_MODE rs6000_cell64lv2_valid_pointer_mode
++
++static bool
++rs6000_cell64lv2_valid_pointer_mode(scalar_int_mode mode)
++{
++ return (mode == SImode || (TARGET_64BIT && mode == DImode) || mode == ptr_mode || mode == Pmode);
++}
++
++#endif
++
+ struct gcc_target targetm = TARGET_INITIALIZER;
+
+ #include "gt-rs6000.h"
+diff '--color=auto' -urN a/gcc/config.gcc b/gcc/config.gcc
+--- a/gcc/config.gcc 2022-05-27 09:21:10.000000000 +0200
++++ b/gcc/config.gcc 2023-01-01 14:28:35.684278963 +0100
+@@ -2587,6 +2587,15 @@
+ # tmake_file="${tmake_file} rs6000/t-fprules"
+ # extra_headers=
+ # ;;
++powerpc64-ps3-elf)
++ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/default64.h"
++ tm_file="rs6000/biarch64.h ${tm_file} rs6000/cell64lv2.h"
++ if test x${enable_secureplt} = xyes; then
++ tm_file="rs6000/secureplt.h ${tm_file}"
++ fi
++ extra_options="${extra_options} rs6000/sysv4.opt"
++ tmake_file="rs6000/t-fprules rs6000/t-fprules-fpbit rs6000/t-ppcgas rs6000/t-ppccomm"
++ ;;
+ powerpc-*-darwin*)
+ extra_options="${extra_options} ${cpu_type}/darwin.opt"
+ case ${target} in
+diff '--color=auto' -urN a/gcc/configure b/gcc/configure
+--- a/gcc/configure 2022-05-27 09:21:46.000000000 +0200
++++ b/gcc/configure 2023-01-01 14:52:19.312078588 +0100
+@@ -28944,12 +28944,12 @@
+ esac
+
+ case "$target:$tm_file" in
+- powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
++ powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc64-ps3-elf* | powerpc*-*-linux*rs6000/biarch64.h*)
+ case "$target" in
+ *le-*-linux*)
+ emul_name="-melf64lppc"
+ ;;
+- *-*-linux*)
++ *-*-linux* | *-ps3-elf*)
+ emul_name="-melf64ppc"
+ ;;
+ *le-*-freebsd*)
+diff '--color=auto' -urN a/gcc/configure.ac b/gcc/configure.ac
+--- a/gcc/configure.ac 2022-05-27 09:21:11.000000000 +0200
++++ b/gcc/configure.ac 2023-01-01 14:51:42.742384668 +0100
+@@ -5671,12 +5671,12 @@
+ esac
+
+ case "$target:$tm_file" in
+- powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
++ powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc64-ps3-elf* | powerpc*-*-linux*rs6000/biarch64.h*)
+ case "$target" in
+ *le-*-linux*)
+ emul_name="-melf64lppc"
+ ;;
+- *-*-linux*)
++ *-*-linux* | *-ps3-elf*)
+ emul_name="-melf64ppc"
+ ;;
+ *le-*-freebsd*)
+diff '--color=auto' -urN a/libgcc/config.host b/libgcc/config.host
+--- a/libgcc/config.host 2022-05-27 09:21:12.000000000 +0200
++++ b/libgcc/config.host 2023-01-01 14:29:07.913987821 +0100
+@@ -1134,6 +1134,8 @@
+ tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+ extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
+ ;;
++powerpc64-ps3-elf)
++ ;;
+ powerpc*-*-linux*)
+ tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-linux t-dfprules rs6000/t-ppc64-fp t-slibgcc-libgcc"
+ tmake_file="${tmake_file} t-stack rs6000/t-stack-rs6000"
+diff '--color=auto' -urN a/Makefile.in b/Makefile.in
+--- a/Makefile.in 2022-05-27 09:21:10.000000000 +0200
++++ b/Makefile.in 2023-01-01 14:54:20.241067239 +0100
+@@ -27294,7 +27294,6 @@
+ .PHONY: install-libiberty maybe-install-libiberty
+ maybe-install-libiberty:
+ @if libiberty
+-maybe-install-libiberty: install-libiberty
+
+ install-libiberty: installdirs
+ @: $(MAKE); $(unstage)
diff --git a/patches/gdb-8.3.1-PS3.patch b/patches/gdb-8.3.1-PS3.patch
index 979fa68ea..b2f3a1169 100644
--- a/patches/gdb-8.3.1-PS3.patch
+++ b/patches/gdb-8.3.1-PS3.patch
@@ -1,5 +1,48 @@
+# Updated for mac gdb 8.3.1-PS3 by humbertodias
+diff --git a/gdb/Makefile.in b/gdb/Makefile.in
+index 5614cc3386c..a7942e6c37f 100644
+--- a/gdb/Makefile.in
++++ b/gdb/Makefile.in
+@@ -1100,6 +1100,7 @@ COMMON_SFILES = \
+ remote-fileio.c \
+ remote-notif.c \
+ reverse.c \
++ run-on-main-thread.c \
+ rust-lang.c \
+ sentinel-frame.c \
+ ser-event.c \
+@@ -1362,6 +1363,7 @@ HFILES_NO_SRCDIR = \
+ riscv-tdep.h \
+ rs6000-aix-tdep.h \
+ rs6000-tdep.h \
++ run-on-main-thread.h \
+ s390-linux-tdep.h \
+ s390-tdep.h \
+ score-tdep.h \
+diff --git a/gdb/python/lib/gdb/command/prompt.py b/gdb/python/lib/gdb/command/prompt.py
+index 3d662a7d3f1..04b9e49c229 100644
+--- a/gdb/python/lib/gdb/command/prompt.py
++++ b/gdb/python/lib/gdb/command/prompt.py
+@@ -45,7 +45,7 @@ The currently defined substitutions are:
+ self.hook_set = False
+
+ def get_show_string (self, pvalue):
+- if self.value is not '':
++ if self.value:
+ return "The extended prompt is: " + self.value
+ else:
+ return "The extended prompt is not set."
+@@ -57,7 +57,7 @@ The currently defined substitutions are:
+ return ""
+
+ def before_prompt_hook(self, current):
+- if self.value is not '':
++ if self.value:
+ return gdb.prompt.substitute_prompt(self.value)
+ else:
+ return None
diff --git a/gdb/python/python.c b/gdb/python/python.c
-index 67f362b852d0..4bdd2201abc3 100644
+index c23db2c1261..422b61bedf6 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -28,14 +28,13 @@
@@ -18,7 +61,7 @@ index 67f362b852d0..4bdd2201abc3 100644
/* Declared constants and enum for python stack printing. */
static const char python_excp_none[] = "none";
-@@ -228,13 +227,37 @@
+@@ -228,13 +227,37 @@ gdbpy_enter::~gdbpy_enter ()
m_error->restore ();
@@ -57,7 +100,7 @@ index 67f362b852d0..4bdd2201abc3 100644
/* Set the quit flag. */
static void
-@@ -248,6 +271,10 @@
+@@ -248,6 +271,10 @@ gdbpy_set_quit_flag (const struct extension_language_defn *extlang)
static int
gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
{
@@ -68,7 +111,7 @@ index 67f362b852d0..4bdd2201abc3 100644
return PyOS_InterruptOccurred ();
}
-@@ -942,60 +969,54 @@
+@@ -942,60 +969,54 @@ gdbpy_source_script (const struct extension_language_defn *extlang,
/* A single event. */
struct gdbpy_event
{
@@ -81,25 +124,20 @@ index 67f362b852d0..4bdd2201abc3 100644
+ : m_func (func.release ())
+ {
+ }
-+
+
+-/* All pending events. */
+-static struct gdbpy_event *gdbpy_event_list;
+-/* The final link of the event list. */
+-static struct gdbpy_event **gdbpy_event_list_end;
+ gdbpy_event (gdbpy_event &&other)
+ : m_func (other.m_func)
+ {
+ other.m_func = nullptr;
+ }
--/* All pending events. */
--static struct gdbpy_event *gdbpy_event_list;
--/* The final link of the event list. */
--static struct gdbpy_event **gdbpy_event_list_end;
--
-/* So that we can wake up the main thread even when it is blocked in
- poll(). */
-static struct serial_event *gdbpy_serial_event;
--
--/* The file handler callback. This reads from the internal pipe, and
-- then processes the Python event queue. This will always be run in
-- the main gdb thread. */
+ gdbpy_event (const gdbpy_event &other)
+ : m_func (other.m_func)
+ {
@@ -107,23 +145,29 @@ index 67f362b852d0..4bdd2201abc3 100644
+ Py_XINCREF (m_func);
+ }
--static void
--gdbpy_run_events (int error, gdb_client_data client_data)
--{
-- gdbpy_enter enter_py (get_current_arch (), current_language);
+-/* The file handler callback. This reads from the internal pipe, and
+- then processes the Python event queue. This will always be run in
+- the main gdb thread. */
+ ~gdbpy_event ()
+ {
+ gdbpy_gil gil;
+ Py_XDECREF (m_func);
+ }
-+
+
+-static void
+-gdbpy_run_events (int error, gdb_client_data client_data)
+-{
+- gdbpy_enter enter_py (get_current_arch (), current_language);
+ gdbpy_event &operator= (const gdbpy_event &other) = delete;
- /* Clear the event fd. Do this before flushing the events list, so
- that any new event post afterwards is sure to re-awake the event
- loop. */
- serial_event_clear (gdbpy_serial_event);
--
++ void operator() ()
++ {
++ gdbpy_enter enter_py (get_current_arch (), current_language);
+
- while (gdbpy_event_list)
- {
- /* Dispatching the event might push a new element onto the event
@@ -132,10 +176,7 @@ index 67f362b852d0..4bdd2201abc3 100644
- gdbpy_event_list = gdbpy_event_list->next;
- if (gdbpy_event_list == NULL)
- gdbpy_event_list_end = &gdbpy_event_list;
-+ void operator() ()
-+ {
-+ gdbpy_enter enter_py (get_current_arch (), current_language);
-
+-
- gdbpy_ref<> call_result (PyObject_CallObject (item->event, NULL));
+ gdbpy_ref<> call_result (PyObject_CallObject (m_func, NULL));
if (call_result == NULL)
@@ -164,7 +205,7 @@ index 67f362b852d0..4bdd2201abc3 100644
if (!PyArg_ParseTuple (args, "O", &func))
return NULL;
-@@ -1007,38 +1028,13 @@
+@@ -1007,38 +1028,13 @@ gdbpy_post_event (PyObject *self, PyObject *args)
return NULL;
}
@@ -206,7 +247,7 @@ index 67f362b852d0..4bdd2201abc3 100644
/* This is the extension_language_ops.before_prompt "method". */
-@@ -1573,6 +1569,7 @@
+@@ -1573,6 +1569,7 @@ finalize_python (void *ignore)
Py_Finalize ();
@@ -214,7 +255,7 @@ index 67f362b852d0..4bdd2201abc3 100644
restore_active_ext_lang (previous_active);
}
-@@ -1701,7 +1698,6 @@
+@@ -1701,7 +1698,6 @@ do_start_initialization ()
|| gdbpy_initialize_linetable () < 0
|| gdbpy_initialize_thread () < 0
|| gdbpy_initialize_inferior () < 0
@@ -222,7 +263,7 @@ index 67f362b852d0..4bdd2201abc3 100644
|| gdbpy_initialize_eventregistry () < 0
|| gdbpy_initialize_py_events () < 0
|| gdbpy_initialize_event () < 0
-@@ -1736,8 +1732,7 @@
+@@ -1736,8 +1732,7 @@ do_start_initialization ()
return false;
/* Release the GIL while gdb runs. */
@@ -232,39 +273,11 @@ index 67f362b852d0..4bdd2201abc3 100644
make_final_cleanup (finalize_python, NULL);
---- /dev/null 2023-07-16 09:39:45.472000000 +0200
-+++ b/gdb/run-on-main-thread.h 2023-07-30 10:43:06.264134972 +0200
-@@ -0,0 +1,28 @@
-+/* Run a function on the main thread
-+ Copyright (C) 2019 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see . */
-+
-+#ifndef GDB_RUN_ON_MAIN_THREAD_H
-+#define GDB_RUN_ON_MAIN_THREAD_H
-+
-+#include
-+
-+/* Send a runnable to the main thread. */
-+
-+extern void run_on_main_thread (std::function &&);
-+
-+#endif /* GDB_RUN_ON_MAIN_THREAD_H */
---- /dev/null 2023-07-16 09:39:45.472000000 +0200
-+++ b/gdb/run-on-main-thread.c 2023-07-30 10:43:03.510435316 +0200
+diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
+new file mode 100644
+index 00000000000..86824b5af4a
+--- /dev/null
++++ b/gdb/run-on-main-thread.c
@@ -0,0 +1,97 @@
+/* Run a function on the main thread
+ Copyright (C) 2019 Free Software Foundation, Inc.
@@ -363,41 +376,53 @@ index 67f362b852d0..4bdd2201abc3 100644
+ runnable_event = make_serial_event ();
+ add_file_handler (serial_event_fd (runnable_event), run_events, nullptr);
+}
---- a/gdb/Makefile.in 2023-07-30 10:45:06.611621149 +0200
-+++ b/gdb/Makefile.in 2023-07-30 10:46:04.284435216 +0200
-@@ -1100,6 +1100,7 @@
- remote-fileio.c \
- remote-notif.c \
- reverse.c \
-+ run-on-main-thread.c \
- rust-lang.c \
- sentinel-frame.c \
- ser-event.c \
-@@ -1362,6 +1363,7 @@
- riscv-tdep.h \
- rs6000-aix-tdep.h \
- rs6000-tdep.h \
-+ run-on-main-thread.h \
- s390-linux-tdep.h \
- s390-tdep.h \
- score-tdep.h \
---- a/gdb/python/lib/gdb/command/prompt.py
-+++ b/gdb/python/lib/gdb/command/prompt.py
-@@ -45,7 +45,7 @@ def __init__(self):
- self.hook_set = False
+diff --git a/gdb/run-on-main-thread.h b/gdb/run-on-main-thread.h
+new file mode 100644
+index 00000000000..fd1a2c42532
+--- /dev/null
++++ b/gdb/run-on-main-thread.h
+@@ -0,0 +1,28 @@
++/* Run a function on the main thread
++ Copyright (C) 2019 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see . */
++
++#ifndef GDB_RUN_ON_MAIN_THREAD_H
++#define GDB_RUN_ON_MAIN_THREAD_H
++
++#include
++
++/* Send a runnable to the main thread. */
++
++extern void run_on_main_thread (std::function &&);
++
++#endif /* GDB_RUN_ON_MAIN_THREAD_H */
+diff --git a/readline/config.h.in b/readline/config.h.in
+index c194e761a45..07b04fceb56 100644
+--- a/readline/config.h.in
++++ b/readline/config.h.in
+@@ -234,7 +234,11 @@
+ /* Definitions pulled in from aclocal.m4. */
+ #undef VOID_SIGHANDLER
- def get_show_string (self, pvalue):
-- if self.value is not '':
-+ if self.value:
- return "The extended prompt is: " + self.value
- else:
- return "The extended prompt is not set."
-@@ -57,7 +57,7 @@ def get_set_string (self):
- return ""
++#if __APPLE__
++#define GWINSZ_IN_SYS_IOCTL
++#else
+ #undef GWINSZ_IN_SYS_IOCTL
++#endif
+
+ #undef STRUCT_WINSIZE_IN_SYS_IOCTL
- def before_prompt_hook(self, current):
-- if self.value is not '':
-+ if self.value:
- return gdb.prompt.substitute_prompt(self.value)
- else:
- return None
diff --git a/patches/newlib-1.20.0-PS3.patch b/patches/newlib-1.20.0-PS3.patch
index 2cab6e163..e20c4ee2e 100644
--- a/patches/newlib-1.20.0-PS3.patch
+++ b/patches/newlib-1.20.0-PS3.patch
@@ -13178,3 +13178,30 @@ index 6932de2..4c8bdbb 100644
/* Calculate the exponent. */
if (y < 0.0)
N = (int) (y * ONE_OVER_PI - 0.5);
+diff --git a/newlib/libc/sys/lv2/sys/dirent.h b/newlib/libc/sys/lv2/sys/dirent.h
+index 84780e9..d44d070 100644
+--- a/newlib/libc/sys/lv2/sys/dirent.h
++++ b/newlib/libc/sys/lv2/sys/dirent.h
+@@ -7,14 +7,14 @@
+
+ #define DT_INVALID 0xff
+ #define DT_UNKNOWN 0
+-#define DT_FIFO DT_INVALID
+-#define DT_CHR DT_INVALID
+-#define DT_DIR 1
+-#define DT_BLK DT_INVALID
+-#define DT_REG 2
+-#define DT_LNK 3
+-#define DT_SOCK DT_INVALID
+-#define DT_WHT DT_INVALID
++#define DT_FIFO 1
++#define DT_CHR 2
++#define DT_DIR 4
++#define DT_BLK 6
++#define DT_REG 8
++#define DT_LNK 10
++#define DT_SOCK 12
++#define DT_WHT 14
+
+ #define dirfd(dp) ((dp)->dd_fd)
+
diff --git a/scripts/001-binutils-PPU.sh b/scripts/001-binutils-PPU.sh
index 14e295cff..eb56593c1 100755
--- a/scripts/001-binutils-PPU.sh
+++ b/scripts/001-binutils-PPU.sh
@@ -1,7 +1,7 @@
#!/bin/sh -e
# binutils-PPU.sh by Naomi Peori (naomi@peori.ca)
-BINUTILS="binutils-2.22"
+BINUTILS="binutils-2.42"
if [ ! -d ${BINUTILS} ]; then
@@ -16,7 +16,7 @@ if [ ! -d ${BINUTILS} ]; then
tar xfvj ${BINUTILS}.tar.bz2
## Patch the source code.
- cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS}
+ cat ../patches/${BINUTILS}-PS3-PPU.patch | patch -p1 -d ${BINUTILS}
## Replace config.guess and config.sub
cp config.guess config.sub ${BINUTILS}
@@ -34,18 +34,20 @@ fi
cd ${BINUTILS}/build-ppu
## Configure the build.
+unset LDFLAGS
../configure --prefix="$PS3DEV/ppu" --target="powerpc64-ps3-elf" \
- --disable-nls \
- --disable-shared \
- --disable-debug \
- --disable-dependency-tracking \
- --disable-werror \
- --enable-64-bit-bfd \
- --with-gcc \
- --with-gnu-as \
- --with-gnu-ld
+ --with-gcc \
+ --with-gnu-as \
+ --with-gnu-ld \
+ --enable-64-bit-bfd \
+ --enable-lto \
+ --disable-nls \
+ --disable-shared \
+ --disable-debug \
+ --disable-dependency-tracking \
+ --disable-werror
## Compile and install.
PROCS="$(nproc --all 2>&1)" || ret=$?
if [ ! -z $ret ]; then PROCS=4; fi
-${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install
+${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=`pwd`/host-libs/lib install
diff --git a/scripts/002-gcc-newlib-PPU.sh b/scripts/002-gcc-newlib-PPU.sh
index b63da30d2..62a6c0703 100755
--- a/scripts/002-gcc-newlib-PPU.sh
+++ b/scripts/002-gcc-newlib-PPU.sh
@@ -1,7 +1,7 @@
-#!/bin/sh -e
+#!/bin/bash -e
# gcc-newlib-PPU.sh by Naomi Peori (naomi@peori.ca)
-GCC="gcc-7.2.0"
+GCC="gcc-13.2.0"
NEWLIB="newlib-1.20.0"
if [ ! -d ${GCC} ]; then
@@ -15,7 +15,7 @@ if [ ! -d ${GCC} ]; then
rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz
## Patch the source code.
- cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC}
+ cat ../patches/${GCC}-PS3-PPU.patch | patch -p1 -d ${GCC}
cat ../patches/${NEWLIB}-PS3.patch | patch -p1 -d ${NEWLIB}
## Enter the source code directory.
@@ -44,23 +44,27 @@ fi
cd ${GCC}/build-ppu
## Configure the build.
+
+
+# Avoid breakage
+CFLAGS="${CFLAGS/-Werror=format-security/}"
+CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"
../configure --prefix="$PS3DEV/ppu" --target="powerpc64-ps3-elf" \
- --disable-dependency-tracking \
- --disable-libcc1 \
- --disable-libstdcxx-pch \
- --disable-multilib \
- --disable-nls \
- --disable-shared \
- --disable-win32-registry \
- --enable-languages="c,c++" \
- --enable-long-double-128 \
- --enable-lto \
- --enable-threads \
- --with-cpu="cell" \
- --with-newlib \
- --enable-newlib-multithread \
- --enable-newlib-hw-fp \
- --with-system-zlib
+ --with-cpu="cell" \
+ --with-newlib \
+ --with-system-zlib \
+ --enable-languages="c,c++" \
+ --enable-long-double-128 \
+ --enable-lto \
+ --enable-threads \
+ --enable-newlib-multithread \
+ --enable-newlib-hw-fp \
+ --disable-dependency-tracking \
+ --disable-libcc1 \
+ --disable-multilib \
+ --disable-nls \
+ --disable-shared \
+ --disable-win32-registry
## Compile and install.
PROCS="$(nproc --all 2>&1)" || ret=$?
diff --git a/scripts/005-binutils-SPU.sh b/scripts/005-binutils-SPU.sh
index 0c993d411..11524598c 100755
--- a/scripts/005-binutils-SPU.sh
+++ b/scripts/005-binutils-SPU.sh
@@ -16,7 +16,7 @@ if [ ! -d ${BINUTILS} ]; then
tar xfvj ${BINUTILS}.tar.bz2
## Patch the source code.
- cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS}
+ cat ../patches/${BINUTILS}-PS3-SPU.patch | patch -p1 -d ${BINUTILS}
## Replace config.guess and config.sub
cp config.guess config.sub ${BINUTILS}
@@ -42,7 +42,8 @@ cd ${BINUTILS}/build-spu
--disable-werror \
--with-gcc \
--with-gnu-as \
- --with-gnu-ld
+ --with-gnu-ld \
+ --enable-lto
## Compile and install.
PROCS="$(nproc --all 2>&1)" || ret=$?
diff --git a/scripts/006-gcc-newlib-SPU.sh b/scripts/006-gcc-newlib-SPU.sh
index c51f73786..6e4f176e9 100755
--- a/scripts/006-gcc-newlib-SPU.sh
+++ b/scripts/006-gcc-newlib-SPU.sh
@@ -1,7 +1,7 @@
#!/bin/sh -e
# gcc-newlib-SPU.sh by Naomi Peori (naomi@peori.ca)
-GCC="gcc-7.2.0"
+GCC="gcc-9.5.0"
NEWLIB="newlib-1.20.0"
if [ ! -d ${GCC} ]; then
@@ -15,7 +15,7 @@ if [ ! -d ${GCC} ]; then
rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz
## Patch the source code.
- cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC}
+ cat ../patches/${GCC}-PS3-SPU.patch | patch -p1 -d ${GCC}
cat ../patches/${NEWLIB}-PS3.patch | patch -p1 -d ${NEWLIB}
## Enter the source code directory.
@@ -44,22 +44,22 @@ fi
cd ${GCC}/build-spu
## Configure the build.
+unset CFLAGS CXXFLAGS LDFLAGS
CFLAGS_FOR_TARGET="-Os -fpic -ffast-math -ftree-vectorize -funroll-loops -fschedule-insns -mdual-nops -mwarn-reloc" \
../configure --prefix="$PS3DEV/spu" --target="spu" \
- --disable-dependency-tracking \
- --disable-libcc1 \
- --disable-libssp \
- --disable-multilib \
- --disable-nls \
- --disable-shared \
- --disable-win32-registry \
- --enable-languages="c,c++" \
- --enable-lto \
- --enable-threads \
- --with-newlib \
- --enable-newlib-multithread \
- --enable-newlib-hw-fp \
- --with-pic
+ --enable-languages="c,c++" \
+ --enable-lto \
+ --enable-threads \
+ --enable-newlib-multithread \
+ --enable-newlib-hw-fp \
+ --enable-obsolete \
+ --disable-dependency-tracking \
+ --disable-libcc1 \
+ --disable-libssp \
+ --disable-multilib \
+ --disable-nls \
+ --disable-shared \
+ --disable-win32-registry
## Compile and install.
PROCS="$(nproc --all 2>&1)" || ret=$?
diff --git a/scripts/007-gdb-SPU.sh b/scripts/007-gdb-SPU.sh
index 8e227156f..d78de91e9 100755
--- a/scripts/007-gdb-SPU.sh
+++ b/scripts/007-gdb-SPU.sh
@@ -34,6 +34,7 @@ fi
cd ${GDB}/build-spu
## Configure the build.
+
../configure --prefix="$PS3DEV/spu" --target="spu" \
--disable-nls \
--disable-sim \
@@ -42,4 +43,4 @@ cd ${GDB}/build-spu
## Compile and install.
PROCS="$(nproc --all 2>&1)" || ret=$?
if [ ! -z $ret ]; then PROCS=4; fi
-${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install
+${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=`pwd`/host-libs/lib install
diff --git a/scripts/008-psl1ght.sh b/scripts/008-psl1ght.sh
index 0f66d90dc..1da1f8fab 100755
--- a/scripts/008-psl1ght.sh
+++ b/scripts/008-psl1ght.sh
@@ -1,14 +1,19 @@
#!/bin/sh -e
# psl1ght.sh by Naomi Peori (naomi@peori.ca)
-## Download the source code.
-wget --no-check-certificate https://github.com/ps3dev/PSL1GHT/tarball/master -O psl1ght.tar.gz
+PSL1GHT_DIR="PSL1GHT"
-## Unpack the source code.
-rm -Rf psl1ght && mkdir psl1ght && tar --strip-components=1 --directory=psl1ght -xvzf psl1ght.tar.gz
+if [ ! -d ${PSL1GHT_DIR} ]; then
-## Create the build directory.
-cd psl1ght
+ ## Download the source code.
+ wget --no-check-certificate https://github.com/ps3dev/$PSL1GHT_DIR/tarball/master -O $PSL1GHT_DIR.tar.gz
+
+ ## Unpack the source code.
+ rm -Rf $PSL1GHT_DIR && mkdir $PSL1GHT_DIR && tar --strip-components=1 --directory=$PSL1GHT_DIR -xvzf $PSL1GHT_DIR.tar.gz
+
+fi
+
+cd $PSL1GHT_DIR
## Compile and install.
-${MAKE:-make} install-ctrl && ${MAKE:-make} && ${MAKE:-make} install
+${MAKE:-make} install-ctrl && ${MAKE:-make} && ${MAKE:-make} install
\ No newline at end of file
diff --git a/scripts/009-ps3libraries.sh b/scripts/009-ps3libraries.sh
index 67fd2adc7..5e6c806bf 100755
--- a/scripts/009-ps3libraries.sh
+++ b/scripts/009-ps3libraries.sh
@@ -1,11 +1,19 @@
#!/bin/sh -e
# ps3libraries.sh by Naomi Peori (naomi@peori.ca)
-## Download the source code.
-wget --no-check-certificate https://github.com/ps3dev/ps3libraries/tarball/master -O ps3libraries.tar.gz
+PS3LIBRARIES="ps3libraries"
-## Unpack the source code.
-rm -Rf ps3libraries && mkdir ps3libraries && tar --strip-components=1 --directory=ps3libraries -xvzf ps3libraries.tar.gz && cd ps3libraries
+if [ ! -d ${PS3LIBRARIES} ]; then
+
+ ## Download the source code.
+ wget --no-check-certificate https://github.com/humbertodias/$PS3LIBRARIES/tarball/psl1ght-2.30.1 -O $PS3LIBRARIES.tar.gz
+
+ ## Unpack the source code.
+ rm -Rf $PS3LIBRARIES && mkdir $PS3LIBRARIES && tar --strip-components=1 --directory=$PS3LIBRARIES -xvzf $PS3LIBRARIES.tar.gz
+
+fi
+
+cd $PS3LIBRARIES
## Compile and install.
-./libraries.sh
+./libraries.sh
\ No newline at end of file