Skip to content

Commit

Permalink
first try at patching gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Mar 1, 2024
1 parent 4ff0395 commit e63f34d
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 13 deletions.
21 changes: 8 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,29 @@ RUN apt-get update -y && apt-get upgrade -y && \
RUN python3 -m venv ${VIRTUALENV}
ENV PATH=${VIRTUALENV}/bin:${PATH}


# get the RTEMS Source Builder
WORKDIR ${RTEMS_BASE}
RUN curl https://ftp.rtems.org/pub/rtems/releases/${RTEMS_MAJOR}/rc/${RTEMS_VERSION}/sources/rtems-source-builder-${RTEMS_VERSION}.tar.xz \
| tar -xJ && \
mv rtems-source-builder-${RTEMS_VERSION} rsb

# build the cross compilation tool suite
# and minimize the size of the installation - limiting to m7400 processors only
# add in a gcc patch to only build for m7400
COPY patches /
RUN /patches/patch-rsb.sh

# build the cross compilation tool suite and strip symbols to minimize size
WORKDIR rsb/rtems
RUN ../source-builder/sb-set-builder --prefix=${RTEMS_PREFIX} ${RTEMS_MAJOR}/rtems-${RTEMS_ARCH} && \
strip $(find ${RTEMS_PREFIX}) 2> /dev/null || true && \
ranlib $(find ${RTEMS_PREFIX} -name '*.a') && \
for i in m403 m505 m603e m604 m8540 m860 me6500 nof m7400/nof ; do \
rm -r ${RTEMS_PREFIX}/lib/gcc/powerpc-rtems6/*/${i} ; \
rm -r ${RTEMS_PREFIX}/powerpc-rtems6/lib/${i} ; \
done

ranlib $(find ${RTEMS_PREFIX} -name '*.a')

# get the kernel
WORKDIR ${RTEMS_BASE}
RUN curl https://ftp.rtems.org/pub/rtems/releases/${RTEMS_MAJOR}/rc/${RTEMS_VERSION}/sources/rtems-${RTEMS_VERSION}.tar.xz \
| tar -xJ && \
mv rtems-${RTEMS_VERSION} kernel

# # patch the kernel
# patch the kernel
WORKDIR ${RTEMS_BASE}/kernel
COPY VMEConfig.patch .
RUN git apply VMEConfig.patch && \
Expand All @@ -82,8 +79,6 @@ RUN git submodule init && \

from environment AS runtime

# To make this container much smaller we take just the BSP and remove any
# unecessary files.

# To make this container target smaller we take just the BSP
COPY --from=developer ${RTEMS_PREFIX} ${RTEMS_PREFIX}

48 changes: 48 additions & 0 deletions patches/gcc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--- gcc-13.2.0/gcc/config/rs6000/t-rtems
+++ gcc-13.2.0/gcc/config/rs6000/t-rtems
@@ -24,20 +24,9 @@ MULTILIB_MATCHES =
MULTILIB_EXCEPTIONS =
MULTILIB_REQUIRED =

-MULTILIB_OPTIONS += mcpu=403/mcpu=505/mcpu=603e/mcpu=604/mcpu=860/mcpu=7400/mcpu=8540/mcpu=e6500
-MULTILIB_DIRNAMES += m403 m505 m603e m604 m860 m7400 m8540 me6500
-
-MULTILIB_OPTIONS += m32/m64
-MULTILIB_DIRNAMES += m32 m64
-
-MULTILIB_OPTIONS += msoft-float
-MULTILIB_DIRNAMES += nof
-
-MULTILIB_OPTIONS += mno-altivec
-MULTILIB_DIRNAMES += noaltivec
-
-MULTILIB_OPTIONS += mvrsave
-MULTILIB_DIRNAMES += vrsave
+# only build for the m7400 powerpc variant
+MULTILIB_OPTIONS += mcpu=7400
+MULTILIB_DIRNAMES += m7400

MULTILIB_MATCHES += ${MULTILIB_MATCHES_ENDIAN}
MULTILIB_MATCHES += ${MULTILIB_MATCHES_SYSV}
@@ -61,19 +50,6 @@ MULTILIB_MATCHES += mcpu?8540=mcpu?8548

# Enumeration of multilibs

-MULTILIB_REQUIRED += msoft-float
-MULTILIB_REQUIRED += mcpu=403
-MULTILIB_REQUIRED += mcpu=505
-MULTILIB_REQUIRED += mcpu=603e
-MULTILIB_REQUIRED += mcpu=603e/msoft-float
-MULTILIB_REQUIRED += mcpu=604
-MULTILIB_REQUIRED += mcpu=604/msoft-float
+# MULTILIB_REQUIRED += msoft-float
MULTILIB_REQUIRED += mcpu=7400
-MULTILIB_REQUIRED += mcpu=7400/msoft-float
-MULTILIB_REQUIRED += mcpu=8540/msoft-float
-MULTILIB_REQUIRED += mcpu=860
-MULTILIB_REQUIRED += mcpu=e6500/m32
-MULTILIB_REQUIRED += mcpu=e6500/m32/mvrsave
-MULTILIB_REQUIRED += mcpu=e6500/m32/msoft-float/mno-altivec
-MULTILIB_REQUIRED += mcpu=e6500/m64
-MULTILIB_REQUIRED += mcpu=e6500/m64/mvrsave
+# MULTILIB_REQUIRED += mcpu=7400/msoft-float
9 changes: 9 additions & 0 deletions patches/patch-rsb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

THIS=$(realpath $(dirname $0))
RSB=$(realpath ${THIS}/../rsb)
set -xe

cp $THIS/gcc.patch $RSB/rtems/patches
cp $THIS/rtems-gcc-13.2-newlib-head.cfg $RSB/rtems/config/tools
cp $THIS/rtems-default-tools.bset $RSB/rtems/config/tools
29 changes: 29 additions & 0 deletions patches/rtems-default-tools.bset
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Default tools build
#

# GCC requires a GNU sed so build an internal version if one is not
# available
#
%define _internal_gsed_path %{_tmpinternal}
%defineifnot with_rtems_gsed textproc/gsed-internal

# GNU tools need texinfo for makeinfo to build documentation
%define _internal_texinfo_path %{_tmpinternal}
%defineifnot with_rtems_texinfo print/texinfo-internal

#
# Build gdb first to raise the Python install error as early as
# possible.
#
# GCC and GDB need GMP.
#
%{with_rtems_dtc}
%{with_rtems_expat}
%{with_rtems_gmp}
%{with_rtems_gsed}
%{with_rtems_texinfo}
%{with_rtems_gdb}
%{with_rtems_binutils}
%{with_rtems_gcc}
%{with_rtems_tools}
24 changes: 24 additions & 0 deletions patches/rtems-gcc-13.2-newlib-head.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg

%define gcc_version 13.2.0
%source set gcc https://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.xz
%hash sha512 gcc-%{gcc_version}.tar.xz \
2Z5IJqcNsEUERn40np+67apYcHZs2nxcq1DN6+3EvnVevKW3ieEjKjSiC+GgtgCX3pKA7+R723HHMlHjCwhiog==

%define newlib_version 3cacedb
%define newlib_external 1
%define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
%source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version}
%hash sha512 newlib-%{newlib_version}.tar.gz \
ia0ce+bdENUO3qYj00jrZB8FjSejmTWuRqEdNE8nI2llf30mh8leUn5fCoHB0Oa7rRVBjEu3n0F12ZK9skuegQ==

%patch add gcc file:///gcc.patch
%hash sha256 gcc.patch f3fd225acc18ddd16543e02d014a2cc1541216c9d9e9dd0143aa5cf74c09b54b

%define with_threads 1
%define with_plugin 0
%define with_iconv 1

%include %{_configdir}/gcc-13.cfg

0 comments on commit e63f34d

Please sign in to comment.