9

I downloaded the toolchain “gcc-arm-none-eabi-6-2017-q2-update-win32-sha1.exe” (Windows) from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads and installed it on my Windows 10 PC.

The installation folder contains a release.txt in “../share/doc/gcc-arm-none-eabi/” which tells:

This release includes the following items:

  • newlib and newlib-nano : git://sourceware.org/git/newlib-cygwin.git commit 0d79b021a4ec4e6b9aa1a9f6db0e29a137005ce7

And also the readme.txt in “../share/doc/gcc-arm-none-eabi/” contains:

  • C Libraries usage *

This toolchain is released with two prebuilt C libraries based on newlib: one is the standard newlib (libc.a) and the other is newlib-nano (libc_nano.a) for code size.

Now I want exactly rebuild all the libc.a and libc_nano.a contained in “../arm-none-eabi/lib/thumb

At the moment I can build on Ubuntu with “gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2

$ # Downloaded newlib-cygwin (with corresponding hash) into folder newlib-cygwin
$ mkdir build
$ cd build
$ ../newlib-cygwin/configure --target=arm-none-eabi --disable-newlib-supplied-syscalls
$ make

How do I have to configure the newlib to build the exact copies of libc.a and for libc_nano.a contained in gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2?

$ # Downloaded newlib-cygwin (with corresponding hash) into folder newlib-cygwin
$ mkdir build
$ cd build
$ ../newlib-cygwin/configure --target=arm-none-eabi --???
$ make
ge45mue
  • 677
  • 8
  • 23
  • You have to configure it the way you want. If you want newlib supplied syscall calls then don't disable them. Does `../newlib-cygwin/configure --target=arm-none-eabi` fail to run on windows? What's the error? – KamilCuk May 09 '18 at 10:35
  • No it don't fail to run on windows but with cygwin the build it takes very long to build the library. Yes, for me it's clear that I can configure it like I want, but I like to configure it exactly like the GNU ARM Toolchain. The only problem is I don't know where I can find this configuration options. – ge45mue May 14 '18 at 13:11

3 Answers3

15

If i understand you correctly, a more detailed question is:
What configure options did 'GNU Arm Embedded Toolchain' developers used when building newlib libraries shipped in gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 archive?
These ones for newlib:

--target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls

And these ones for newlib-nano:

--target=arm-none-eabi --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

How I got it? Let's walk through the process:
These packages are build on launchpad, where from you find all the builds that took place on lanuchpad. I picked gcc-arm-none-eabi 6-2017q2-1 from 2017-10-24. There i can find the buildlog. I grepped the buildlog with | grep "^+ " | grep "configure " | grep 'src/newlib' and i was left with:

+ /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/install-native --infodir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls + /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/build-native/target-libs --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

A bit of Sherlock Holmes and i deduced that the second line is newlib configured to build as newlib-nano (--enable-newlib-reent-small), the first is newlib configured to build as full newlib.
To answer your topic question, to recompile newlib and newlib-nano the same way pass the options I have posted above to newlib ./configure script.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • 1
    Thanks you very much. I will try today. I think another possible to search in https://github.com/gnu-mcu-eclipse/arm-none-eabi-gcc-build/blob/master/scripts/container-gcc-functions-source.sh – ge45mue May 16 '18 at 06:40
  • 4
    For newer versions of the ARM toolchain that are not on launchpad, on ARM's download page if you download the "Source Tarball" there is a file called build-toolchain.sh and there is section that has the configuration options for newlib and newlib-nano. You can find them by searching the script for $SRCDIR/$NEWLIB/configure and $SRCDIR/$NEWLIB_NANO/configure respectively – tbejos Dec 07 '21 at 21:01
  • @tbejos The configure commands are also in the binary packages release from ARM. They have a file in the root of the archive that ends in the `*arm-none-eabi-manifest.txt`. That particular file has the set of configuration flags for gcc, newlib and other bundled packages. – silvergasp Dec 30 '22 at 18:50
2

Hints about how the compiler was configured are found in:

  • $COMPILER_PATH/arm-none-eabi/include/newlib.h
  • $COMPILER_PATH/arm-none-eabi/include/newlib-nano/newlib.h

The #defines there have a close correspondence to the options that were passed to 'configure', when newlib was built.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
bpaddock
  • 21
  • 2
1

I figured it would be useful to give the default configuration of the ARM built newlib/newlib-nano as of 2023 (for GCC 10):

For Newlib:

--enable-newlib-io-long-long
--enable-newlib-io-c99-formats
--enable-newlib-reent-check-verify
--enable-newlib-register-fini
--enable-newlib-retargetable-locking
--disable-newlib-supplied-syscalls
--disable-nls

For Newlib-nano:

--disable-newlib-supplied-syscalls
--enable-newlib-reent-check-verify
--enable-newlib-reent-small
--enable-newlib-retargetable-locking
--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

Ref: https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53310/gcc-arm-none-eabi-what-were-the-newlib-compilation-options

DarkFranX
  • 361
  • 2
  • 13