compiling newlib

Jeff Johnston jjohnstn@redhat.com
Mon Aug 24 19:41:11 GMT 2020


Responses below:

On Fri, Aug 21, 2020 at 4:21 AM Paul Zimmermann <Paul.Zimmermann@inria.fr>
wrote:

>        Hi,
>
> I am new to this list. I have two questions:
>
> 1) I have a file newlib/libm/libm.a, that I have downloaded somewhere, but
>    I don't remember where. I'd like to know to which version of newlib it
>    corresponds. Is there a way to do this?
>
> Offhand, I don't know how to tell this.  It does bring up a good point
that we should have the version embedded in the .a files somewhere.

2) I downloaded newlib-3.3.0 from ftp://sourceware.org/pub/newlib/,
>    but I am unable to compile it on x86_64 under Linux.
>    Here is what I did:
>    $ tar xf /tmp/newlib-3.3.0.tar.gz
>    $ cd newlib-3.3.0
>    $ mkdir build
>    $ cd build
>    $ ../configure --prefix=/tmp # runs ok
>    $ make
>
>    The make command returns almost immediately, and there is no libm.a
>    file created.
>

This is because by default you cannot build newlib natively - it must be a
cross-build (usually native users use glibc).  You can force build newlib
for linux on
x86_64 by specifying --with-newlib but this may not be working lately
(newlib for native linux shares headers between newlib
and locally installed headers so it gets broken easily when local headers
change).  If you want to play with building newlib, you want to have some
gnu cross tools installed or built locally (e.g. aarch64-elf, m32-elf,
etc..).

You can download one for arm here:


https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads


>    I tried also the following:
>    $ tar xf /tmp/newlib-3.3.0.tar.gz
>    $ cd newlib-3.3.0
>    $ mkdir build
>    $ cd build
>    $ ../configure --prefix=/tmp --target=x86_64
>    $ make
>
>    Then make seems to do more job, however it fails with:
>
>    /bin/bash: line 2: x86_64-ar: command not found
>
> The tools used for the cross-build are constructed from your target.  If
you specify x86_64-elf then it will look for x86_64-elf-ar, x86_64-elf-gcc,
etc..
in your path.

Note: item 1 of the FAQ on https://sourceware.org/newlib/ refers to
> ${FULL_PATH_TO_SRC}/src/configure --prefix=`pwd` --target=XXX but there
> is no src directory in the newlib-3.3.0.tar.gz tarball.
>
> That is a mistake.

What am I doing wrong?
>

Nothing.  It is a bit of a learning experience.  You can try reading the
README and the faq on sourceware.org/newlib to get some other information.

-- Jeff J.


> Best regards,
> Paul Zimmermann
>
>
>


More information about the Newlib mailing list