Discussion:
building libc_nano and libg_nano
Robert Newberry
2018-11-18 00:38:05 UTC
Permalink
Hi.

I'm trying to build a cross-development system, targeting arm-none-eabi from Mac OS X.

I've got almost everything built from source -- lots of GNU dependencies (like gmp, etc), binutils, and GCC.

And I've built newlib. A few times.

Then I tried to use my cross-dev system to build something using my new toolchain. And it works -- until it tries to link, and it complains that it can't find "libc_nano.a". The makefile has a "LDFLAGS += -specs=nano.specs" line in it.

I've done a bunch of reading on this front today -- found lots of information.

This was particularly enlightening:

https://stackoverflow.com/questions/50154137/how-to-rebuild-newlib-and-newlib-nano-of-gnu-arm-embedded-toolchain <https://stackoverflow.com/questions/50154137/how-to-rebuild-newlib-and-newlib-nano-of-gnu-arm-embedded-toolchain>

As was this discussion:

https://sourceware.org/ml/newlib/2014/msg00278.html <https://sourceware.org/ml/newlib/2014/msg00278.html>

But in the end, I can't seem to figure out how to get the newlib system to build and install "libc_nano.a" and "libg_nano.a" -- at least not in a way that's obvious to me.
configure --target=arm-none-eabi --prefix=/Volumes/Code/Test1 --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls
make
make install
configure --target=arm-none-eabi --prefix=/Volumes/Code/Test2 --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
make
make install
But when I do this, neither one of them produces a "libg_nano.a" or a "libc_nano.a".

I looked at the launchpad logs (per the stackoverflow suggestion) and can see a spot, just after "make install", in that does thew following:

cp -f /<<PKGBUILDDIR>>/build-native/target-libs/arm-none-eabi/lib/./libc.a /<<PKGBUILDDIR>>/install-native/arm-none-eabi/lib/./libc_nano.a

but I don't find anything like this in the "newlib" sources.

Is this magic available somewhere? If I try to replicate it by hand, I'm afraid I'll goof it up...

Rob
Freddie Chopin
2018-11-18 08:05:01 UTC
Permalink
Post by Robert Newberry
I looked at the launchpad logs (per the stackoverflow suggestion) and
can see a spot, just after "make install", in that does thew
cp -f /<<PKGBUILDDIR>>/build-native/target-libs/arm-none-
eabi/lib/./libc.a /<<PKGBUILDDIR>>/install-native/arm-none-
eabi/lib/./libc_nano.a
but I don't find anything like this in the "newlib" sources.
Is this magic available somewhere? If I try to replicate it by hand,
I'm afraid I'll goof it up...
There's nothing in newlib sources that does the copying. You are
supposed to do this by hand. This is also the same thing I'm doing in
my bleeding-edge-toolchain script:

https://github.com/FreddieChopin/bleeding-edge-toolchain

around line 487 of the main script there's the copying. But please note
that it is not only newlib's libc that has to be compiled differently,
renamed and copied to proper places - this also affects 4 other .a
archives.

BTW - from what you wrote it seems that you try to accomplish the same
goal as my bleeding-edge-toolchain script (; I never used it on Mac,
but maybe you could give it a try if you find it interesting and then
let me know whether it worked or not? (;

Regards,
FCh
Rob Newberry
2018-11-19 04:47:46 UTC
Permalink
Thanks, this was very helpful.

I’ve made a lot of progress — though it was painful. I’d been trying to build GCC 8.2, but still has an issue with ARMv8 and picking up an “include_next <stdint.h>” during the bootstrap build. Found information about this issue here:

<https://bugs.launchpad.net/gcc-arm-embedded/+bug/1717502>

and basically realized I might not need to blaze this trail quite so aggressively.

I decided to retrench and build the GCC ARM tag from that build:

svn co svn:://gcc.gnu.org/svn/gcc/tags/ARM/embedded-7-branch-2018q2

I’m now part way through building the “full” GCC, and I’m hopeful it’ll make it through.

One thing I noticed from your recommendation — when I built newlib and newlib nano (which I was doing immediately after building the GCC bootstrap), I did not get libstdc++ or libsupc++. Reading your script, it looks like you do an ADDITIONAL GCC bootstrap build immediately after building newlib nano libraries, and I’m guessing that’s why I don’t have them.

Your script does indeed do pretty much everything I need to do and more although I was really trying to roll my own because I wanted to understand what was going on. Thanks for this valuable asset. I will see if I can give it a whirl on my Mac.

Rob
Post by Freddie Chopin
Post by Robert Newberry
I looked at the launchpad logs (per the stackoverflow suggestion) and
can see a spot, just after "make install", in that does thew
cp -f /<<PKGBUILDDIR>>/build-native/target-libs/arm-none-
eabi/lib/./libc.a /<<PKGBUILDDIR>>/install-native/arm-none-
eabi/lib/./libc_nano.a
but I don't find anything like this in the "newlib" sources.
Is this magic available somewhere? If I try to replicate it by hand,
I'm afraid I'll goof it up...
There's nothing in newlib sources that does the copying. You are
supposed to do this by hand. This is also the same thing I'm doing in
https://github.com/FreddieChopin/bleeding-edge-toolchain
around line 487 of the main script there's the copying. But please note
that it is not only newlib's libc that has to be compiled differently,
renamed and copied to proper places - this also affects 4 other .a
archives.
BTW - from what you wrote it seems that you try to accomplish the same
goal as my bleeding-edge-toolchain script (; I never used it on Mac,
but maybe you could give it a try if you find it interesting and then
let me know whether it worked or not? (;
Regards,
FCh
Loading...