Skip to content

Commit

Permalink
Switch Emscripten FPU emulation to mpfr
Browse files Browse the repository at this point in the history
Matches the arm64 build, and avoids precision issues with the vanilla
double path in fpu_ieee.cpp.

There is a slowdown (Speedometer 4.0 FPU benchmark goes from 7.7 to 2.4),
but it's worth it to avoid quirks that prevent things like the scroll
thumbs in Mac OS 8 from positioning correctly.

Updates mihaip/infinite-mac#6
  • Loading branch information
mihaip committed Nov 16, 2022
1 parent bf15acf commit 3d111bc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
33 changes: 33 additions & 0 deletions BasiliskII/src/Unix/_em_build_mpfr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -euo pipefail

mkdir -p /emlibs
cd /tmp

wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
tar xf gmp-6.2.1.tar.lz
cd gmp-6.2.1
emconfigure ./configure \
--disable-assembly \
--with-readline=no \
--enable-cxx \
--host none \
--prefix=/emlibs
make -j6
make install
cd ..

wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.xz
tar xf mpfr-4.1.0.tar.xz
cd mpfr-4.1.0
emconfigure ./configure \
--enable-assert=none \
--disable-thread-safe \
--disable-float128 \
--disable-decimal-float \
--host none \
--with-gmp=/emlibs \
--prefix=/emlibs
make -j6
make install
cd ..
7 changes: 6 additions & 1 deletion BasiliskII/src/Unix/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1872,11 +1872,16 @@ for fpe in $FPE_CORE_TEST_ORDER; do
ieee)
case $ac_cv_c_float_format in
IEEE*)
if [[ "$target_cpu" = "arm" -o "$target_cpu" = "aarch64" ]]; then
if [[ "$target_cpu" = "arm" -o "$target_cpu" = "aarch64" -o "x$WANT_EMSCRIPTEN" = "xyes" ]]; then
FPE_CORE="IEEE fpu core (MPFR)"
DEFINES="$DEFINES -DFPU_MPFR"
FPUSRCS="$UAE_PATH/fpu/fpu_mpfr.cpp"
LIBS="$LIBS -lgmp -lmpfr"
if [[ "x$WANT_EMSCRIPTEN" = "xyes" ]]; then
dnl Emscripten version of gmp and mpfr built by _em_build_mpfr.sh
CPPFLAGS="$CPPFLAGS -I/emlibs/include"
LDFLAGS="$LDFLAGS -L/emlibs/lib"
fi
else
FPE_CORE="IEEE fpu core"
DEFINES="$DEFINES -DFPU_IEEE"
Expand Down

0 comments on commit 3d111bc

Please sign in to comment.