public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* compiling newlib
@ 2020-08-21  8:20 Paul Zimmermann
  2020-08-24 19:41 ` Jeff Johnston
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Zimmermann @ 2020-08-21  8:20 UTC (permalink / raw)
  To: newlib

       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?

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.

   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

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.

What am I doing wrong?

Best regards,
Paul Zimmermann
   

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: compiling newlib
  2020-08-21  8:20 compiling newlib Paul Zimmermann
@ 2020-08-24 19:41 ` Jeff Johnston
  2020-08-25  6:42   ` Paul Zimmermann
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Johnston @ 2020-08-24 19:41 UTC (permalink / raw)
  To: Paul Zimmermann; +Cc: Newlib

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
>
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: compiling newlib
  2020-08-24 19:41 ` Jeff Johnston
@ 2020-08-25  6:42   ` Paul Zimmermann
  2020-08-25  7:37     ` Christophe MONAT
  2020-08-25 17:04     ` Keith Packard
  0 siblings, 2 replies; 10+ messages in thread
From: Paul Zimmermann @ 2020-08-25  6:42 UTC (permalink / raw)
  To: Jeff Johnston; +Cc: newlib

thank you Jeff for your answer.

In return I found I believe an issue with newlib's tgammaf function, for
input -0, where it gives +inf instead of -inf:

$ cat e.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#ifdef NEWLIB
/* without this, newlib says: undefined reference to `__errno' */
int errno;
int* __errno () { return &errno; }
#endif

int
main (int argc, char *argv[])
{
  float x = -0.0;
  float y = tgammaf (x);
  printf ("x=%.9e y=%.9e\n", x, y);
  return 0;
}

With glibc :

$ gcc e.c -lm
$ ./a.out 
x=-0.000000000e+00 y=-inf

With NEWLIB :

$ gcc -DNEWLIB e.c /localdisk/zimmerma/newlib/libm/libm.a
$ ./a.out 
x=-0.000000000e+00 y=inf

Best regards,
Paul


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: compiling newlib
  2020-08-25  6:42   ` Paul Zimmermann
@ 2020-08-25  7:37     ` Christophe MONAT
  2020-08-25  8:39       ` Paul Zimmermann
  2020-08-25 17:04     ` Keith Packard
  1 sibling, 1 reply; 10+ messages in thread
From: Christophe MONAT @ 2020-08-25  7:37 UTC (permalink / raw)
  To: Paul Zimmermann; +Cc: newlib, Jeff Johnston

Paul,

+ #include <errno.h>
probably would have avoided the trouble to add newlib-specific code.

It looks also that errno differs between glibc and newlib.

From my memory glibc has a quite thorough libm test suite checking among other things the edge cases, I don't know what exist in this domain for newlib.

Regards,
--C


-----Original Message-----
From: Newlib <newlib-bounces@sourceware.org> On Behalf Of Paul Zimmermann
Sent: Tuesday, August 25, 2020 8:42 AM
To: Jeff Johnston <jjohnstn@redhat.com>
Cc: newlib@sourceware.org
Subject: Re: compiling newlib

thank you Jeff for your answer.

In return I found I believe an issue with newlib's tgammaf function, for input -0, where it gives +inf instead of -inf:

$ cat e.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#ifdef NEWLIB
/* without this, newlib says: undefined reference to `__errno' */ int errno;
int* __errno () { return &errno; }
#endif

int
main (int argc, char *argv[])
{
  float x = -0.0;
  float y = tgammaf (x);
  printf ("x=%.9e y=%.9e\n", x, y);
  return 0;
}

With glibc :

$ gcc e.c -lm
$ ./a.out
x=-0.000000000e+00 y=-inf

With NEWLIB :

$ gcc -DNEWLIB e.c /localdisk/zimmerma/newlib/libm/libm.a
$ ./a.out
x=-0.000000000e+00 y=inf

Best regards,
Paul


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: compiling newlib
  2020-08-25  7:37     ` Christophe MONAT
@ 2020-08-25  8:39       ` Paul Zimmermann
  2020-08-25  8:50         ` Christophe MONAT
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Zimmermann @ 2020-08-25  8:39 UTC (permalink / raw)
  To: Christophe MONAT; +Cc: newlib, jjohnstn

       Dear Christophe,

> + #include <errno.h>
> probably would have avoided the trouble to add newlib-specific code.

of course I tried, but I get with #include <errno.h>:

$ gcc e.c /localdisk/zimmerma/newlib/libm/libm.a
/usr/bin/ld: /localdisk/zimmerma/newlib/libm/libm.a(lib_a-k_standard.o): in function `__kernel_standard':
k_standard.c:(.text+0x39): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0x59): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0x7f): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0xa1): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0xc1): undefined reference to `__errno'
/usr/bin/ld: /localdisk/zimmerma/newlib/libm/libm.a(lib_a-k_standard.o):k_standard.c:(.text+0xe9): more undefined references to `__errno' follow
collect2: error: ld returned 1 exit status

Best regards,
Paul

PS: I discovered that while comparing different libraries for single-precision
functions: <https://members.loria.fr/PZimmermann/papers/accuracy.pdf>




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: compiling newlib
  2020-08-25  8:39       ` Paul Zimmermann
@ 2020-08-25  8:50         ` Christophe MONAT
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe MONAT @ 2020-08-25  8:50 UTC (permalink / raw)
  To: Paul Zimmermann; +Cc: newlib, jjohnstn

Paul,

My bad -- probably the mix of glibc and libm-newlib at link-time, sorry for the noise.

Thanks for your pointer, indeed I was aware of your work on that topic ("Accuracy of Mathematical Functions in Single Precision") . Claude-Pierre Jeannerod mentioned it to me some time ago and I had a look - I encourage readers of the list interested by that topic to read it too.

Best regards,
--C

-----Original Message-----
From: Paul Zimmermann <Paul.Zimmermann@inria.fr> 
Sent: Tuesday, August 25, 2020 10:39 AM
To: Christophe MONAT <christophe.monat@st.com>
Cc: newlib@sourceware.org; jjohnstn@redhat.com
Subject: Re: compiling newlib

       Dear Christophe,

> + #include <errno.h>
> probably would have avoided the trouble to add newlib-specific code.

of course I tried, but I get with #include <errno.h>:

$ gcc e.c /localdisk/zimmerma/newlib/libm/libm.a
/usr/bin/ld: /localdisk/zimmerma/newlib/libm/libm.a(lib_a-k_standard.o): in function `__kernel_standard':
k_standard.c:(.text+0x39): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0x59): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0x7f): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0xa1): undefined reference to `__errno'
/usr/bin/ld: k_standard.c:(.text+0xc1): undefined reference to `__errno'
/usr/bin/ld: /localdisk/zimmerma/newlib/libm/libm.a(lib_a-k_standard.o):k_standard.c:(.text+0xe9): more undefined references to `__errno' follow
collect2: error: ld returned 1 exit status

Best regards,
Paul

PS: I discovered that while comparing different libraries for single-precision
functions: <https://members.loria.fr/PZimmermann/papers/accuracy.pdf>




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: compiling newlib
  2020-08-25  6:42   ` Paul Zimmermann
  2020-08-25  7:37     ` Christophe MONAT
@ 2020-08-25 17:04     ` Keith Packard
  1 sibling, 0 replies; 10+ messages in thread
From: Keith Packard @ 2020-08-25 17:04 UTC (permalink / raw)
  To: Paul Zimmermann, Jeff Johnston; +Cc: newlib


[-- Attachment #1.1: Type: text/plain, Size: 313 bytes --]

Paul Zimmermann <Paul.Zimmermann@inria.fr> writes:

> thank you Jeff for your answer.
>
> In return I found I believe an issue with newlib's tgammaf function, for
> input -0, where it gives +inf instead of -inf:

Yeah, it's easy to fix the underlying __ieee754_lgamma functions to
adjust the sign of the return:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-libm-Fix-sign-value-returned-from-__ieee754_lgamma-_.patch --]
[-- Type: text/x-diff, Size: 1630 bytes --]

From 0cba5165a7f6cd69aca95bf82a9f1437bfa144dc Mon Sep 17 00:00:00 2001
From: Keith Packard <keithp@keithp.com>
Date: Tue, 25 Aug 2020 09:32:35 -0700
Subject: [PATCH] libm: Fix sign value returned from __ieee754_lgamma*_r(-0)

The sign of the INFINITY returned from these cases needs to match the
sign of the zero.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 newlib/libm/math/er_lgamma.c  | 6 +++++-
 newlib/libm/math/erf_lgamma.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/newlib/libm/math/er_lgamma.c b/newlib/libm/math/er_lgamma.c
index 386a8a73b..36408382f 100644
--- a/newlib/libm/math/er_lgamma.c
+++ b/newlib/libm/math/er_lgamma.c
@@ -225,7 +225,11 @@ static double zero=  0.00000000000000000000e+00;
 	*signgamp = 1;
 	ix = hx&0x7fffffff;
 	if(ix>=0x7ff00000) return x*x;
-	if((ix|lx)==0) return one/zero;
+	if((ix|lx)==0) {
+	    if(hx<0)
+	        *signgamp = -1;
+	    return one/zero;
+	}
 	if(ix<0x3b900000) {	/* |x|<2**-70, return -log(|x|) */
 	    if(hx<0) {
 	        *signgamp = -1;
diff --git a/newlib/libm/math/erf_lgamma.c b/newlib/libm/math/erf_lgamma.c
index 3c6ba02af..a45423949 100644
--- a/newlib/libm/math/erf_lgamma.c
+++ b/newlib/libm/math/erf_lgamma.c
@@ -160,7 +160,11 @@ static float zero=  0.0000000000e+00;
 	*signgamp = 1;
 	ix = hx&0x7fffffff;
 	if(ix>=0x7f800000) return x*x;
-	if(ix==0) return one/zero;
+	if(ix==0) {
+	    if(hx<0)
+	        *signgamp = -1;
+	    return one/zero;
+	}
 	if(ix<0x1c800000) {	/* |x|<2**-70, return -log(|x|) */
 	    if(hx<0) {
 	        *signgamp = -1;
-- 
2.28.0


[-- Attachment #1.3: Type: text/plain, Size: 740 bytes --]


There's a bit of a mess with the gamma functions. There are _r
versions of these functions that pass through the sign return pointer
instead of applying it locally as they should. That reduces the set of
gamma functions as follows:

Reentrant functions:

        double                  float
        __ieee754_lgamma_r      __ieee754_lgammaf_r
        __ieee754_gamma         __ieee754_gammaf
        
        lgamma_r                lgammaf_r
        tgamma                  tgammaf

gamma/gammaf should be alternate names for tgamma/tgammaf, and would
thus be re-entrant.

Non-reentrant functions:

        __ieee754_lgamma        __ieee754_lgammaf        

        lgamma                  lgammaf

-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* compiling newlib
@ 2003-11-26 21:57 Xavier Pegenaute
  0 siblings, 0 replies; 10+ messages in thread
From: Xavier Pegenaute @ 2003-11-26 21:57 UTC (permalink / raw)
  To: newlib

Hi,

ok,i want to compile the newlib library, what Linux i have to install,
it works with the last RedHat ?

Thanks.
Xavi.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: compiling newlib
  2000-12-19 22:59 HenrySimmons17
@ 2000-12-19 23:39 ` Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2000-12-19 23:39 UTC (permalink / raw)
  To: HenrySimmons17; +Cc: newlib

On Dec 20, 2000, HenrySimmons17@aol.com wrote:

> m68k-elf-gcc: installation problem, cannot exec `cpp': No such file or 

This is the problem: your installation of GCC is broken.  It has
nothing to do with newlib.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 10+ messages in thread

* compiling newlib
@ 2000-12-19 22:59 HenrySimmons17
  2000-12-19 23:39 ` Alexandre Oliva
  0 siblings, 1 reply; 10+ messages in thread
From: HenrySimmons17 @ 2000-12-19 22:59 UTC (permalink / raw)
  To: newlib

Hello
When I try to compile newlib with the tools form uClinux-coldfire I get an 
error message here at this point. Can someone tell me what I am doing missing.
thanks
Henry

/home/uClinux-coldfire/tools/m68k-elf-gcc -DPACKAGE=\"newlib\" 
-DVERSION=\"1.9.0\"  -I. -I../../../../../newlib/libc/stdlib  -O2 
-DMISSING_SYSCALL_NAMES -I../../targ-include 
-I../../../../../newlib/libc/../libc/include -fno-builtin      -g
-O2 -c ../../../../../newlib/libc/stdlib/__adjust.c
m68k-elf-gcc: installation problem, cannot exec `cpp': No such file or 
directorymake[3]: *** [__adjust.o] Error 1
make[3]: Leaving directory 
`/home/newlib/newlib-1.9.0/m5200/m68k-elf/newlib/libc/stdlib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory 
`/home/newlib/newlib-1.9.0/m5200/m68k-elf/newlib/libc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/newlib/newlib-1.9.0/m5200/m68k-elf/newlib'
make: *** [all-target-newlib] Error 2
[root@localhost m5200]

                       

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-25 17:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21  8:20 compiling newlib Paul Zimmermann
2020-08-24 19:41 ` Jeff Johnston
2020-08-25  6:42   ` Paul Zimmermann
2020-08-25  7:37     ` Christophe MONAT
2020-08-25  8:39       ` Paul Zimmermann
2020-08-25  8:50         ` Christophe MONAT
2020-08-25 17:04     ` Keith Packard
  -- strict thread matches above, loose matches on Subject: below --
2003-11-26 21:57 Xavier Pegenaute
2000-12-19 22:59 HenrySimmons17
2000-12-19 23:39 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).