GCC XCompile newlib (nearly there)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
hubris
Member
Member
Posts: 28
Joined: Sun May 24, 2015 12:38 am
Location: Brisbane, Australia

GCC XCompile newlib (nearly there)

Post by hubris »

So after nearly a week and many, many experiments, I can almost build. The current, hopefully last step is the newlib and I am after the correct configuration (I think).

What I think I want, still learning, is to build the nosys version of the newlib which is a series of stubs to satisfy the linker without providing any true implementation.

The newlib docs refer to an argument --srcdir is this an argument that should be provided to the gcc configure e.g.

../gcc-x.y.z/configure --target=$T prefix=$P --with-sysroot --disable-nls --enable-languages=c,c++ --srcdir=?

if this is the case what should I define this as? The root of the newlib directory under the gcc source tree, I have simple copied the entire newlib untarred distribution into a directory called newlib under the gcc source tree. Although the documents say that newlib will default to this I get the following error:

Code: Select all

make[3]: Leaving directory '/cygdrive/c/kabuta/cross/gnu/gcc-5.1.0.build/i686-elf/libgcc'
make[2]: Leaving directory '/cygdrive/c/kabuta/cross/gnu/gcc-5.1.0.build/i686-elf/libgcc'
Checking multilib configuration for newlib...
mkdir -p -- i686-elf/newlib
Configuring in i686-elf/newlib
configure: creating cache ./config.cache
configure: error: cannot run /bin/sh ../../../gcc-5.1.0/newlib/config.sub
Makefile:12478: recipe for target 'configure-target-newlib' failed
make[1]: *** [configure-target-newlib] Error 1
make[1]: Leaving directory '/cygdrive/c/kabuta/cross/gnu/gcc-5.1.0.build'
Makefile:878: recipe for target 'all' failed
A little opaque as to the location of make when the error is notified, but when I look I can see that the file config.sub does exist so I suspect that I need the --srcdir to correctly position so that the relative path to config.sub is correct.

Is this the case, and if so where should I point srcdir to correctly build nosys or am I well off the track?
noah
Posts: 9
Joined: Mon Jun 22, 2015 12:55 pm

Re: GCC XCompile newlib (nearly there)

Post by noah »

According to the GNU Documentation, srcdir has to point to GCC's root directory (the one where the MAINTAINERS file is).
hubris
Member
Member
Posts: 28
Joined: Sun May 24, 2015 12:38 am
Location: Brisbane, Australia

Re: GCC XCompile newlib (nearly there) [SOLVED]

Post by hubris »

Thank you for the hint. But I have solved the problem by starting again. Completely removed all traces of cygwin, installed a minimum cygwin according to the video, modified some of the files to repair known bugs in the script and configure files, and now have a complete cross compile of binutils-2.25, gcc-5.1.0, and libgcc.
I still do no know that the problem was but it seemed to be my environment so as a last effort a complete scrub, reinstall, and rebuild did the trick.
nbdd0121
Member
Member
Posts: 60
Joined: Thu Jul 25, 2013 8:10 am

Re: GCC XCompile newlib (nearly there)

Post by nbdd0121 »

I just build newlib and GCC separately. The only con for this is that you need to build gcc twice - you first need to build a GCC with freestanding environment only, then your newlib should be able to be built. After building newlib, you now can build the GCC as if the target is hosted.
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Re: GCC XCompile newlib (nearly there)

Post by max »

I made this page explaining how to properly setup Cygwin for creating a cross compiler.
nbdd0121 wrote:I just build newlib and GCC separately. The only con for this is that you need to build gcc twice - you first need to build a GCC with freestanding environment only, then your newlib should be able to be built. After building newlib, you now can build the GCC as if the target is hosted.
No, you don't have to build GCC twice. You first build binutils, then you build GCC "--without-headers" and "--with-newlib", and then you build newlib using the compiler.

Pro-tip: don't use newlib.
nbdd0121
Member
Member
Posts: 60
Joined: Thu Jul 25, 2013 8:10 am

Re: GCC XCompile newlib (nearly there)

Post by nbdd0121 »

max wrote:Pro-tip: don't use newlib.
I do found that newlib somehow bloated and its malloc is not suitable for OS develop. What's a better alternative? I build newlib because otherwise it will be difficult to build libsupc++.
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Re: GCC XCompile newlib (nearly there)

Post by max »

nbdd0121 wrote:
max wrote:Pro-tip: don't use newlib.
I do found that newlib somehow bloated and its malloc is not suitable for OS develop. What's a better alternative? I build newlib because otherwise it will be difficult to build libsupc++.
If I'd start again I'd probably try my best with musl. Imho writing your own library is the best way, as you can make it suit your OS perfectly. And it's not too hard to get libstdc++-v3/libsupc++ running with a custom lib - I have them too and my libc is far from complete.
Post Reply