Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FREEMINT: Add FreeMiNT toolchain #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions check-versions/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@
('./toolchains/dreamcast/packages/toolchain-sh4/build.sh', 'GCC'): 'ignore',
('./toolchains/dreamcast/packages/toolchain-sh4/build.sh', 'NEWLIB'): 'ignore',

('./toolchains/freemint/packages/toolchain/build.sh', 'TOOLCHAIN'): {
'check': 'git commit',
'repository': 'https://github.com/mikrosk/m68k-atari-mint-build',
'branch': 'master',
},

# GCW0 packages (except toolchain) are set by old firmware
('./toolchains/gcw0/packages/alsa-lib/build.sh', 'ALSA_LIB'): 'ignore',
('./toolchains/gcw0/packages/etna_viv/build.sh', 'ETNA_VIV'): 'ignore',
Expand Down
2 changes: 1 addition & 1 deletion toolchains/common/packages/libsdl1.2/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do_make_bdir

do_http_fetch SDL "https://github.com/libsdl-org/SDL-1.2/archive/${SDL_VERSION}.tar.gz" 'tar xzf'
mikrosk marked this conversation as resolved.
Show resolved Hide resolved

do_configure
do_configure "$@"
do_make
do_make install

Expand Down
79 changes: 79 additions & 0 deletions toolchains/freemint/Dockerfile.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
m4_include(`paths.m4')m4_dnl
m4_include(`packages.m4')m4_dnl

m4_dnl Include Debian base preparation steps
m4_dnl This ensures all common steps are shared by all toolchains
m4_include(`debian-toolchain-base.m4')m4_dnl

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bison \
flex \
gcc \
g++ \
libgmp-dev \
libisl-dev \
libmpc-dev \
libmpfr-dev \
texinfo && \
rm -rf /var/lib/apt/lists/*

ENV HOST=m68k-atari-mint

local_package(toolchain)

ENV INSTALL_DIR=/root/gnu-tools/m68000 \
PREFIX=/root/gnu-tools/m68000/$HOST/sys-root/usr

# We add PATH here for *-config and platform specific binaries
ENV \
def_binaries(`${HOST}-', `ar, as, c++filt, ld, nm, objcopy, objdump, ranlib, readelf, strings, strip') \
def_binaries(`${HOST}-', `gcc, cpp, c++') \
CC=${HOST}-gcc \
def_aclocal(`${PREFIX}') \
def_pkg_config(`${PREFIX}') \
PATH=$PATH:${INSTALL_DIR}/bin:${PREFIX}/bin

# TODO: Build m68020-60 and m5475 libraries

helpers_package(zlib)

helpers_package(libpng1.6)

helpers_package(libjpeg-turbo, -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_SYSTEM_PROCESSOR=m68k -DWITH_SIMD=OFF)

helpers_package(giflib,,CFLAGS="${CFLAGS} -fno-PIC")

helpers_package(libmad)

helpers_package(libogg)

helpers_package(libvorbis)

helpers_package(libvorbisidec)

helpers_package(libtheora)

helpers_package(flac, --with-pic=no)

helpers_package(faad2)

# rgb.c:46:22: error: alignment of 'dither' is greater than maximum object file alignment 2
# helpers_package(mpeg2dec)

helpers_package(a52dec)

# TODO: openssl and curl

# fluidsynth is unlikely to be fast enough.

helpers_package(freetype)

helpers_package(fribidi)

# TODO: GEM, LDG and pth, for SDL
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gemlib can be installed from https://github.com/freemint/gemlib

IMHO pth is an overkill even for the SDL port, there's no real use case for threads on our platform. Also, it makes the port really FreeMiNT-specific (it isn't the only OS for the Atari platform), so I've always used --disable-threads in my SDL builds.

LDG can be found at https://sourceforge.net/projects/ldg and it has a bit awkward build process (especially for 68020+ and ColdFire) but I can help you out if you want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO pth is an overkill even for the SDL port, there's no real use case for threads on our platform. Also, it makes the port really FreeMiNT-specific (it isn't the only OS for the Atari platform), so I've always used --disable-threads in my SDL builds.

Does SDL audio work without threads? I know that using interrupts is unreliable on other platforms like the Nintendo DS because the mixer isn't always fast enough.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have always disabled them and released quite a few SDL ports, I'm inclined to say that it does. There could be some corner cases but I'm not aware of them.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the worst case we can again re-enable them.


# COPY packages/libsdl1.2 lib-helpers/packages/libsdl1.2/
helpers_package(libsdl1.2, --disable-video-opengl --disable-threads)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so you actually do disable them. In that case pth is really not needed.


helpers_package(sdl-net1.2)
20 changes: 20 additions & 0 deletions toolchains/freemint/packages/toolchain/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/sh

# TODO: Use fixed revisions for binutils, gcc, mintlib, mintbin and fdlibm
TOOLCHAIN_VERSION=b115a55c606cbf4c07a5fd199b2c2eb5b28c4725

PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
HELPERS_DIR=$PACKAGE_DIR/../..
. $HELPERS_DIR/functions.sh

do_make_bdir

do_http_fetch m68k-atari-mint-build "https://github.com/mikrosk/m68k-atari-mint-build/archive/${TOOLCHAIN_VERSION}.tar.gz" 'tar xzf'

# TODO: Build the m68020-60 and 5475 toolchains as well
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I have now realised that you don't need to build those at all.

They are useful only for building native (68020+ / ColdFire) compilers. The usual way on our platform is to override CFLAGS / CXXFLAGS, i.e. adding -m68020-60 / -mcpu=5475, usually along with -fomit-frame-pointer (which is not very useful and has a performance hit).

Another approach would be to override ENV INSTALL_DIR and PREFIX so they point to the proper sys-root for given CPU (i.e. no multilib setup but separated environment for every CPU) but mintlib, gemlib and others require some tweaks for such scenario (i.e. not to build their multilib variants what is done by default).

do_make m68000-skip-native

do_clean_bdir

# Cleanup wget HSTS
rm -f $HOME/.wget-hsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 20657c9ec506a369ed96c909cbb2979f405d11c8 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <ccawley2011@gmail.com>
Date: Mon, 20 Feb 2023 14:44:54 +0000
Subject: [PATCH] Work around a bug in MiNTLib

---
Makefile | 1 +
mintlib.patch | 13 +++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 mintlib.patch

diff --git a/Makefile b/Makefile
index 42a0461..be4a40c 100644
--- a/Makefile
+++ b/Makefile
@@ -174,6 +174,7 @@ gcc-${VERSION_GCC}.ok: gmp.patch download_prerequisites.patch
mintlib.ok:
rm -rf $@ ${FOLDER_MINTLIB}
$(URLGET) ${GITHUB_URL_MINTLIB} | $(UNTAR) > /dev/null
+ cd ${FOLDER_MINTLIB} && patch -p1 < ../mintlib.patch
touch $@

mintbin.ok:
diff --git a/mintlib.patch b/mintlib.patch
new file mode 100644
index 0000000..21c75b1
--- /dev/null
+++ b/mintlib.patch
@@ -0,0 +1,13 @@
+diff --git a/syscall/Makefile b/syscall/Makefile
+index a7d0684..0202962 100644
+--- a/syscall/Makefile
++++ b/syscall/Makefile
+@@ -49,7 +49,7 @@ gen-syscall: $(gen_objs)
+ $(CC) $(gen_objs) -o $@
+
+ pars.c pars.h: pars.y
+- if bison --defines=pars.h.tmp$$$$ --output=pars.c $<; then mv pars.h.tmp$$$$ pars.h; else rm -f pars.h.tmp$$$$; exit 1; fi
++ bison --defines=pars.h --output=pars.c $< || (rm -f pars.h; exit 1)
+
+ pars.o: pars.c pars.h
+
--
2.30.2