I normally would build the toolchain from the ground up, but it seems that ARM does not post the source for their releases, just the prebuilt toolchains. I need to rebuild the toolchain with the newlib flag --disable-newlib-mb
in an effort to reduce unneeded space. The ARM GCC version I am using is 12.2 off the ARM developer website: arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi.tar.xz
. Using this since it implements C++ 20 features.
Is there a way to change this flag under a prebuilt toolchain and consequently rebuild newlib? Or better yet, build an ARM GCC toolchain from the ground up? I would appreciate any help with this as I have been scouring the internet for some time now.
I've tried following the Linaro ABE tool, but I wasn't able to specifically change the configuration of newlib.
Is there a way to change this flag under a prebuilt toolchain and consequently rebuild newlib?
You need to retrieve the identical version of newlib. The updated options should match the application. For instance, I have used this to create a PIC version of newlib.
The file '12.2.mpacbti-rel1-x86_64-arm-none-eabi-manifest.txt' contains configure options for newlib.
newlib_configure=' --disable-newlib-supplied-syscalls --enable-newlib-retargetable-locking --enable-newlib-reent-check-verify --enable-newlib-io-long-long --enable-newlib-io-c99-formats --enable-newlib-register-fini --enable-newlib-mb --target=arm-none-eabi --prefix=/'
newlib_nano_configure=' --disable-newlib-supplied-syscalls --enable-newlib-retargetable-locking --enable-newlib-reent-check-verify --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-newlib-reent-small --disable-newlib-fseek-optimization --enable-newlib-nano-formatted-io --disable-newlib-fvwrite-in-streamio --disable-newlib-wide-orient --enable-lite-exit --enable-newlib-global-atexit --target=arm-none-eabi --prefix=/'
According to 'arm-none-eabi/include/_newlib_version.h' it is using newlib 4.3.0. You can get a copy form https://sourceware.org/newlib/ and checkout this tag and then rebuild with the modified configure options. Then you must use a custom 'spec' file or alter the link commands to target your custom built newlib.
It is possible that ARM is not using the standard newlib version. It is GPL, so they should provide you the source if it is not from the sourceware.org link above.
Or better yet, build an ARM GCC toolchain from the ground up? I would appreciate any help with this as I have been scouring the internet for some time now.
https://crosstool-ng.github.io/ is generally what most gcc packages are built with. However, this means you need to distribute the entire tool-chain yourself. The newlib is much smaller and requires less support. Expect several days of compute time to build gcc versus a newlib might take a few hours for some machine. Ie, it is much easier to build newlib. Often there are small patches needed to get gcc to build, but you must wait several hours to see if a patch worked as it is built with several sub-packages; especially for cross compilers as we are discussing.
Getting and fixing newlib is the easier option. Building your own cross gcc is far more complex.