Skip to content

Instantly share code, notes, and snippets.

@geky
Last active January 9, 2020 16:34
Show Gist options
  • Save geky/fceece09c8e56445d7837e8a448dd366 to your computer and use it in GitHub Desktop.
Save geky/fceece09c8e56445d7837e8a448dd366 to your computer and use it in GitHub Desktop.
Build newlib-nano with -Os and -DPREFER_SIZE_OVER_SPEED (defaults to -O2)
#!/bin/bash
mkdir newlib-pico
PREFIX=$(pwd)/newlib-pico
cd newlib-pico
echo "Created $(pwd)"
git clone git://sourceware.org/git/newlib-cygwin.git newlib-source
cd newlib-source
echo "Created $(pwd)"
CFLAGS_FOR_TARGET="-DPREFER_SIZE_OVER_SPEED=1 -Os" ./configure --target=arm-none-eabi --prefix=$PREFIX --disable-newlib-supplied-syscalls --enable-newlib-reent-small --disable-newlib-fvwrite-in-streamio --disable-newlib-fseek-optimization --disable-newlib-wide-orient --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-lite-exit --enable-newlib-global-atexit --enable-newlib-nano-formatted-io --disable-nls
make -j
make install
echo
echo "Done, now add something like this to your Makefile:"
echo "override LFLAGS += -L$PREFIX/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/softfp"
echo "override LFLAGS += -L$PREFIX/arm-none-eabi/lib"
echo "override LFLAGS += -Wl,--start-group"
echo "override LFLAGS += -lc"
echo "override LFLAGS += -lnosys"
echo "override LFLAGS += -Wl,--end-group"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment