-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from iratahack/master
Use crosstool-ng to build latest m68k version of gcc for repo workflow
- Loading branch information
Showing
7 changed files
with
60 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "tools/sjasm"] | ||
path = tools/sjasm | ||
url = https://github.com/Konamiman/Sjasm.git | ||
[submodule "tools/musicg"] | ||
path = tools/musicg | ||
url = https://github.com/loisaidasam/musicg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,151 +1,39 @@ | ||
ARG ALPINE_VERSION=3.18.3 | ||
|
||
ARG CROSSTOOL_VERSION=1.26.0 | ||
ARG BASEDIR=/tmp/work | ||
|
||
FROM alpine:$ALPINE_VERSION as build | ||
ARG BASEDIR | ||
ARG _binu_ver=2.37 | ||
ARG _gcc_ver=6.3.0 | ||
ARG _mpfrver=4.1.0 | ||
ARG _mpcver=1.2.1 | ||
ARG _gmpver=6.2.1 | ||
ARG _newlib_ver=4.1.0 | ||
ARG PARALLEL_BUILD=1 | ||
|
||
ENV TARGET=m68k-elf | ||
ENV TARGET_CPU=m68000 | ||
|
||
ENV BASEDIR=$BASEDIR | ||
ENV BINUTILS=binutils-${_binu_ver} | ||
ENV GCC=gcc-${_gcc_ver} | ||
ENV MPFR=mpfr-${_mpfrver} | ||
ENV MPC=mpc-${_mpcver} | ||
ENV GMP=gmp-${_gmpver} | ||
ENV NEWLIB=newlib-${_newlib_ver} | ||
|
||
ENV SRCDIR="$BASEDIR/src" | ||
ENV BUILDDIR="$BASEDIR/build" | ||
ENV INSTALLDIR="$BASEDIR/install" | ||
ENV STAGINGDIR="$BASEDIR/staging" | ||
ENV PARALLEL_BUILD="$PARALLEL_BUILD" | ||
|
||
# Choose parallel build or not. Parallel builds can cause issues with | ||
# low-memory hosts or emulation. If parallel builds are disabled, replace | ||
# nproc so it always says "1". | ||
RUN echo "nproc = $(nproc)" | ||
RUN echo "PARALLEL_BUILD = $PARALLEL_BUILD" | ||
RUN if [[ "$PARALLEL_BUILD" == 0 ]]; then echo -e "#!/bin/sh\necho 1" > /usr/local/bin/nproc; chmod 755 /usr/local/bin/nproc; fi | ||
RUN echo "which nproc = $(which nproc)" | ||
|
||
RUN mkdir -p "$SRCDIR" | ||
RUN mkdir -p "$BUILDDIR" | ||
RUN mkdir -p "$INSTALLDIR" | ||
RUN mkdir -p "$STAGINGDIR" | ||
|
||
WORKDIR $SRCDIR | ||
RUN wget http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.xz -O - | tar -xJ | ||
RUN wget http://ftp.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.bz2 -O - | tar -xj | ||
RUN wget http://ftp.gnu.org/gnu/mpfr/${MPFR}.tar.xz -O - | tar -xJ | ||
RUN wget http://ftp.gnu.org/gnu/mpc/${MPC}.tar.gz -O - | tar -xz | ||
RUN wget http://ftp.gnu.org/gnu/gmp/${GMP}.tar.xz -O - | tar -xJ | ||
RUN wget ftp://sourceware.org/pub/newlib/${NEWLIB}.tar.gz -O - | tar -xz | ||
|
||
RUN apk add --no-cache bash build-base zlib-dev | ||
|
||
################################################################################# | ||
########################## Building binutils ############################## | ||
################################################################################# | ||
WORKDIR $BUILDDIR/$BINUTILS | ||
RUN $SRCDIR/$BINUTILS/configure \ | ||
--prefix=/usr \ | ||
--target=$TARGET \ | ||
--disable-multilib \ | ||
--with-cpu=$TARGET_CPU \ | ||
--disable-nls | ||
ARG CROSSTOOL_VERSION | ||
|
||
RUN make -j"$(nproc)" | ||
RUN make prefix=$INSTALLDIR/$BINUTILS/usr install | ||
RUN rm -rf $INSTALLDIR/$BINUTILS/usr/share | ||
RUN rm $INSTALLDIR/$BINUTILS/usr/lib/bfd-plugins/libdep.so | ||
RUN cp -r $INSTALLDIR/$BINUTILS/usr/ $STAGINGDIR | ||
RUN cp -r $INSTALLDIR/$BINUTILS/usr/* /usr/ | ||
################################################################################# | ||
######################### Building GCC bootstrap ########################## | ||
########################## Install required packages ###################### | ||
################################################################################# | ||
WORKDIR $SRCDIR/$GCC | ||
RUN ln -fs ../$MPFR mpfr | ||
RUN ln -fs ../$MPC mpc | ||
RUN ln -fs ../$GMP gmp | ||
|
||
WORKDIR $BUILDDIR/$GCC-bootstrap | ||
# These flags are required to build older versions of GCC | ||
ENV CFLAGS="$CFLAGS -Wno-implicit-fallthrough -Wno-cast-function-type -fpermissive" | ||
ENV CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough -Wno-cast-function-type -fpermissive" | ||
RUN $SRCDIR/$GCC/configure \ | ||
--prefix=/usr \ | ||
--target=$TARGET \ | ||
--enable-languages="c" \ | ||
--disable-multilib \ | ||
--with-cpu=$TARGET_CPU \ | ||
--with-system-zlib \ | ||
--with-libgloss \ | ||
--without-headers \ | ||
--disable-shared \ | ||
--disable-nls | ||
RUN apk update && apk upgrade && apk add cmake alpine-sdk wget xz git bash autoconf automake bison flex texinfo help2man gawk libtool ncurses-dev gettext-dev python3-dev rsync openjdk11 ninja | ||
|
||
RUN make -j"$(nproc)" all-gcc | ||
RUN make DESTDIR="$INSTALLDIR/$GCC-bootstrap" install-strip-gcc | ||
RUN rm -rf "$INSTALLDIR/$GCC-bootstrap/usr/share" | ||
RUN cp -r "$INSTALLDIR/$GCC-bootstrap/usr/"* /usr/ | ||
################################################################################# | ||
############################# Building NewLib ############################# | ||
############################ Building crosstool-ng ######################## | ||
################################################################################# | ||
WORKDIR $BUILDDIR/$NEWLIB | ||
ENV CFLAGS_FOR_TARGET="-Os -g -ffunction-sections -fdata-sections -fomit-frame-pointer -ffast-math" | ||
WORKDIR /root | ||
RUN git clone --branch crosstool-ng-$CROSSTOOL_VERSION --depth=1 https://github.com/crosstool-ng/crosstool-ng.git | ||
WORKDIR /root/crosstool-ng | ||
RUN ./bootstrap && ./configure --enable-local | ||
RUN make | ||
ENV PATH=/root/crosstool-ng:$PATH | ||
COPY samples/m68k-elf ./samples/m68k-elf | ||
|
||
RUN "$SRCDIR/$NEWLIB/configure" \ | ||
--prefix=/usr \ | ||
--target=$TARGET \ | ||
--enable-languages="c" \ | ||
--disable-newlib-supplied-syscalls \ | ||
--disable-multilib \ | ||
--with-cpu=$TARGET_CPU \ | ||
--disable-nls | ||
|
||
RUN make -j"$(nproc)" | ||
RUN DESTDIR=$INSTALLDIR/$NEWLIB make install | ||
RUN cp -r "$INSTALLDIR/$NEWLIB/usr/" "$STAGINGDIR" | ||
RUN cp -r "$INSTALLDIR/$NEWLIB/usr/"* /usr/ | ||
ENV CFLAGS_FOR_TARGET="" | ||
################################################################################# | ||
############################ Building final GCC ########################### | ||
############################### Building gcc ############################### | ||
################################################################################# | ||
WORKDIR $BUILDDIR/$GCC | ||
|
||
RUN "$SRCDIR/$GCC/configure" \ | ||
--prefix=/usr \ | ||
--target=$TARGET \ | ||
--enable-languages="c,c++" \ | ||
--disable-multilib \ | ||
--with-cpu=$TARGET_CPU \ | ||
--with-system-zlib \ | ||
--with-newlib \ | ||
--with-libgloss \ | ||
--disable-shared \ | ||
--disable-nls | ||
|
||
RUN make -j"$(nproc)" | ||
RUN make DESTDIR="$INSTALLDIR/$GCC" install-strip | ||
RUN rm -rf "$INSTALLDIR/$GCC/usr/share" | ||
RUN rm "$INSTALLDIR/$GCC/usr/lib/libcc1.so" | ||
RUN rm "$INSTALLDIR/$GCC/usr/lib/libcc1.so.0" | ||
RUN rm "$INSTALLDIR/$GCC/usr/lib/libcc1.so.0.0.0" | ||
|
||
RUN cp -ar "$INSTALLDIR/$GCC/usr/" "$STAGINGDIR" | ||
|
||
WORKDIR $BASEDIR | ||
ENV CT_EXPERIMENTAL=y | ||
ENV CT_ALLOW_BUILD_AS_ROOT=y | ||
ENV CT_ALLOW_BUILD_AS_ROOT_SURE=y | ||
# Configure and build the tools | ||
RUN ct-ng m68k-elf | ||
RUN ct-ng build | ||
|
||
# Second stage, just copy the built files | ||
FROM scratch | ||
ARG BASEDIR | ||
WORKDIR /m68k | ||
COPY --from=build $BASEDIR/staging/usr/ ./ | ||
COPY --from=build /root/x-tools/m68k-elf/ . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CT_CONFIG_VERSION="4" | ||
CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES=y | ||
CT_ARCH_M68K=y | ||
CT_ARCH_CPU="68000" | ||
CT_OMIT_TARGET_VENDOR=y | ||
CT_BINUTILS_PLUGINS=y | ||
CT_LIBC_NONE=y | ||
CT_COMP_TOOLS_AUTOCONF=y | ||
CT_COMP_TOOLS_AUTOMAKE=y | ||
CT_COMP_TOOLS_LIBTOOL=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
reporter_name="IrataHack" | ||
reporter_url="" | ||
reporter_comment="m68k bare-metal tools for SGDK." |