Compiling newlib and newlib-nano

Asked by Jonathan Dumaresq

Hi,

I try to get newlib and newlib nano compiled localy to have the debug information not stripped.

I have mingw as build environnement and this look good for now.

The main problem is that my build doesn't include the function _libc_init_array. This should be in the libc.a file but for now, I could get in.

I'm using the 4.9 2014q4 source file.
here my configure script. (extracted from the source 7.z file)

TARGET=arm-none-eabi
ROOT=/C/tools/IDE/gcc/lib_build
INSTALLDIR_NATIVE=$ROOT/install-native.newLib
INSTALLDIR_NATIVE_DOC=$INSTALLDIR_NATIVE/share/doc/gcc-arm-none-eabi

echo Creating build directory...
mkdir newlib.build

echo Entering build directory...
cd newlib.build

export CFLAGS='-ffunction-sections -fdata-sections'

# run configure program to configure the build
echo Configuring newlib build...
../gcc-arm-none-eabi-4_9-2014q4-20141203/src/newlib/configure \
  --target=$TARGET \
  --prefix=$INSTALLDIR_NATIVE \
  --infodir=$INSTALLDIR_NATIVE_DOC/info \
  --mandir=$INSTALLDIR_NATIVE_DOC/man \
  --htmldir=$INSTALLDIR_NATIVE_DOC/html \
  --pdfdir=$INSTALLDIR_NATIVE_DOC/pdf \
  --enable-newlib-io-long-long \
  --enable-newlib-register-fini \
  --disable-newlib-supplied-syscalls \
  --disable-nls

make -j

everything get compiled without error.

When I compile the nano version with this script, I see the _linbc_init_array in the .a file (looked with text editor).
export CFLAGS='-g -Os -ffunction-sections -fdata-sections'
echo Configuring newlib-nano build...
../gcc-arm-none-eabi-4_9-2014q4-20141203/src/newlib-nano/configure \
  --target=$TARGET \
    --prefix=$BUILDDIR_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

echo Building newlib-nano...
make -j

Any help will be appreciated !

Regards

Jonathan

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Jonathan Dumaresq
Solved:
Last query:
Last reply:
Revision history for this message
Tony Liu (mrtoniliu) said :
#1

Hi,

Unfortunately we cannot reproduce this problem. Could you check your build log if the libc/misc/init.c is compiled properly? Or could you attached your build scripts and libraries so we can make some analysis?

BR,
Tony

Revision history for this message
Jonathan Dumaresq (jdumaresq) said :
#2

Hi,

here the build script

http://pastebin.com/BhrvABqx

I try to find the build log, but could not find it. Here it's look like the config.log for the libc

http://pastebin.com/NjMyHDYS

Is there a way to enable the build log ?

Here the compiled libs

http://www.cimeq.qc.ca/files/install-native.newLib.7z

Thanx for your help

Jonathan

Revision history for this message
Tony Liu (mrtoniliu) said :
#3

Hi Jonathan,

Normally you can add "2>&1 | tee build.log" after the commands you used in terminal, then you can check libc/misc/init.c in the build.log to see how it was compiled.

BR,
Tony

Revision history for this message
Jonathan Dumaresq (jdumaresq) said :
#4

Hi,

here the build log

http://www.cimeq.qc.ca/files/build.7z

regards

Jonathan

Revision history for this message
Tony Liu (mrtoniliu) said :
#5

Hi,

It seems the build log is fine to me. Actually I can find the symbol __libc_init_array in the libc.a of your lib.

...
lib_a-init.o:
         U _init
         w __init_array_end
         w __init_array_start
00000000 T __libc_init_array
         w __preinit_array_end
         w __preinit_array_start
...

So how did you notice it is missing?

P.S. we haven't tested our build scripts on the mingw environment.

BR,
Tony

Revision history for this message
Jonathan Dumaresq (jdumaresq) said :
#6

Hi,

I have strated from scratch, and now it's working. At least for the newlib. I need to try the nano version of it.

I have no idea whats get wrong the first time.

Sorry fo the lost time on your side.

Regards

Jonathan

Revision history for this message
rekha (rekha.k) said :
#7

Hi,

I would like to compile Nano C library for cortex-m4 target . I have tried to compile it using CooCox CoIDE but it is giving many errors. Can somebody provide the procedure to compile this on Windows/Linux platforms as soon as possible.

Thanks
Rekha

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#8

Hi Rekha,

You can find in the script build-toolchain in our source tarball the configure line used to build newlib. Try adapting it to your need and it should work.

Best regards.

Revision history for this message
rekha (rekha.k) said :
#9

Hi Thomas,

Thank you for your reply.

I have gone through the 'configure script file my source directory and i could not find the line build-toolchain in that and i am new to the linux environment hence can you please give more explanation.

I have tried to build with below command and the log is as below
./configure --target arm-none-eabi --disable-newlib-supplied-syscalls

Configuring for a x86_64-unknown-linux host.
Invalid configuration `x86_64-unknown-linux': machine `x86_64-unknown' not recognized
Invalid configuration `arm-none-eabi': system `none-eabi' not recognized
Invalid configuration `x86_64-unknown-linux': machine `x86_64-unknown' not recognized
Invalid configuration `arm-none-eabi': system `none-eabi' not recognized

Please suggest how to fix the above.

Thanks
Rekha