Page 1 of 1

GCC XCompile newlib (nearly there)

Posted: Tue Jun 16, 2015 1:03 am
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?

Re: GCC XCompile newlib (nearly there)

Posted: Mon Jun 22, 2015 1:02 pm
by noah
According to the GNU Documentation, srcdir has to point to GCC's root directory (the one where the MAINTAINERS file is).

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

Posted: Mon Jun 22, 2015 4:16 pm
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.

Re: GCC XCompile newlib (nearly there)

Posted: Sun Jun 28, 2015 7:37 am
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.

Re: GCC XCompile newlib (nearly there)

Posted: Tue Jun 30, 2015 1:28 am
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.

Re: GCC XCompile newlib (nearly there)

Posted: Sun Jul 12, 2015 10:28 pm
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++.

Re: GCC XCompile newlib (nearly there)

Posted: Wed Jul 15, 2015 4:11 am
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.