@@ -22,6 +22,10 @@ N64_BUILD=${N64_BUILD:-""}
2222N64_HOST=${N64_HOST:- " " }
2323N64_TARGET=${N64_TARGET:- mips64-elf}
2424
25+ # Toolchain configuration options.
26+ N64_USE_PICOLIBC=${N64_USE_PICOLIBC:- " false" }
27+ N64_USE_PICOLIBC_TINYSTDIO=${N64_USE_PICOLIBC_TINYSTDIO:- " false" }
28+
2529# Set N64_INST before calling the script to change the default installation directory path
2630INSTALL_PATH=" ${N64_INST} "
2731# Set PATH for newlib to compile using GCC for MIPS N64 (pass 1)
@@ -38,8 +42,9 @@ GCC_CONFIGURE_ARGS=()
3842BINUTILS_V=2.42
3943GCC_V=13.2.0
4044NEWLIB_V=4.4.0.20231231
41- GMP_V=6.3.0
42- MPC_V=1.3.1
45+ PICOLIBC_V=1.8.6
46+ GMP_V=6.3.0
47+ MPC_V=1.3.1
4348MPFR_V=4.2.1
4449MAKE_V=${MAKE_V:- " " }
4550
@@ -104,8 +109,13 @@ test -d "binutils-$BINUTILS_V" || tar -xzf "binutils-$BINUTILS_V.tar.gz"
104109test -f " gcc-$GCC_V .tar.gz" || download " https://ftp.gnu.org/gnu/gcc/gcc-$GCC_V /gcc-$GCC_V .tar.gz"
105110test -d " gcc-$GCC_V " || tar -xzf " gcc-$GCC_V .tar.gz"
106111
107- test -f " newlib-$NEWLIB_V .tar.gz" || download " https://sourceware.org/pub/newlib/newlib-$NEWLIB_V .tar.gz"
108- test -d " newlib-$NEWLIB_V " || tar -xzf " newlib-$NEWLIB_V .tar.gz"
112+ if [ " $N64_USE_PICOLIBC " == " true" ]; then
113+ test -f " picolibc-$PICOLIBC_V .tar.xz" || download " https://github.com/picolibc/picolibc/releases/download/$PICOLIBC_V /picolibc-$PICOLIBC_V .tar.xz"
114+ test -d " picolibc-$PICOLIBC_V " || tar -xf " picolibc-$PICOLIBC_V .tar.xz"
115+ else
116+ test -f " newlib-$NEWLIB_V .tar.gz" || download " https://sourceware.org/pub/newlib/newlib-$NEWLIB_V .tar.gz"
117+ test -d " newlib-$NEWLIB_V " || tar -xzf " newlib-$NEWLIB_V .tar.gz"
118+ fi
109119
110120if [ " $GMP_V " != " " ]; then
111121 test -f " gmp-$GMP_V .tar.bz2" || download " https://ftp.gnu.org/gnu/gmp/gmp-$GMP_V .tar.bz2"
@@ -221,19 +231,56 @@ make all-target-libgcc -j "$JOBS"
221231make install-target-libgcc || sudo make install-target-libgcc || su -c " make install-target-libgcc"
222232popd
223233
224- # Compile newlib for target.
225- mkdir -p newlib_compile_target
226- pushd newlib_compile_target
227- CFLAGS_FOR_TARGET=" -DHAVE_ASSERT_FUNC -O2" ../" newlib-$NEWLIB_V " /configure \
228- --prefix=" $CROSS_PREFIX " \
229- --target=" $N64_TARGET " \
230- --with-cpu=mips64vr4300 \
231- --disable-threads \
232- --disable-libssp \
233- --disable-werror
234- make -j " $JOBS "
235- make install || sudo env PATH=" $PATH " make install || su -c " env PATH=\" $PATH \" make install"
236- popd
234+ if [ " $N64_USE_PICOLIBC " == " true" ]; then
235+ # Compile picolibc for target.
236+ mkdir -p picolibc_compile_target
237+ pushd picolibc_compile_target
238+ meson setup \
239+ --cross-file=../../meson-cross.txt \
240+ -Dmultilib=false \
241+ -Dpicocrt=false \
242+ -Dpicolib=false \
243+ -Dsemihost=false \
244+ -Dspecsdir=none \
245+ -Dtests=false \
246+ -Dtinystdio=" $N64_USE_PICOLIBC_TINYSTDIO " \
247+ -Dfast-bufio=true \
248+ -Dio-long-long=true \
249+ -Dio-pos-args=" $N64_USE_PICOLIBC_TINYSTDIO " \
250+ -Dio-percent-b=true \
251+ -Dposix-console=true \
252+ -Dformat-default=double \
253+ -Dnewlib-fseek-optimization=true \
254+ -Dnewlib-fvwrite-in-streamio=true \
255+ -Dnewlib-io-float=true \
256+ -Dnewlib-stdio64=false \
257+ -Dnewlib-unbuf-stream-opt=true \
258+ -Dnewlib-nano-malloc=false \
259+ -Dnewlib-multithread=false \
260+ -Dnewlib-retargetable-locking=false \
261+ -Dthread-local-storage=false \
262+ -Dprefix=" $CROSS_PREFIX " \
263+ -Dlibdir=mips64-elf/lib \
264+ -Dincludedir=mips64-elf/include \
265+ ../" picolibc-$PICOLIBC_V "
266+ ninja -j " $JOBS "
267+ ninja install || sudo env PATH=" $PATH " ninja install || su -c " env PATH=\" $PATH \" ninja install"
268+ popd
269+ else
270+ # Compile newlib for target.
271+ mkdir -p newlib_compile_target
272+ pushd newlib_compile_target
273+ CFLAGS_FOR_TARGET=" -DHAVE_ASSERT_FUNC -O2" ../" newlib-$NEWLIB_V " /configure \
274+ --prefix=" $CROSS_PREFIX " \
275+ --target=" $N64_TARGET " \
276+ --with-cpu=mips64vr4300 \
277+ --disable-threads \
278+ --disable-libssp \
279+ --disable-werror
280+ make -j " $JOBS "
281+ make install || sudo env PATH=" $PATH " make install || su -c " env PATH=\" $PATH \" make install"
282+ popd
283+ fi
237284
238285# For a standard cross-compiler, the only thing left is to finish compiling the target libraries
239286# like libstd++. We can continue on the previous GCC build target.
0 commit comments