mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] musl how to use hard float with aarch64-none-elf-gcc
@ 2022-02-16  9:50 SIMONE MIONE
  2022-02-16 10:24 ` Jeffrey Walton
  0 siblings, 1 reply; 13+ messages in thread
From: SIMONE MIONE @ 2022-02-16  9:50 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

I am trying to integrate musl in a baremetal environment. I already have
float support but I can't manage to disable soft-float by musl.

I configure with:
./configure --target=aarch64-none-elf --enable-debug --disable-shared
And simple compile with:
make

Does anyone know how to use hardfloat instead of soft float? Is there any
option or flag? Thank you

[-- Attachment #2: Type: text/html, Size: 772 bytes --]

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16  9:50 [musl] musl how to use hard float with aarch64-none-elf-gcc SIMONE MIONE
@ 2022-02-16 10:24 ` Jeffrey Walton
  2022-02-16 11:29   ` Szabolcs Nagy
  0 siblings, 1 reply; 13+ messages in thread
From: Jeffrey Walton @ 2022-02-16 10:24 UTC (permalink / raw)
  To: musl

On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <205212@studenti.unimore.it> wrote:
>
> I am trying to integrate musl in a baremetal environment. I already have float support but I can't manage to disable soft-float by musl.
>
> I configure with:
> ./configure --target=aarch64-none-elf --enable-debug --disable-shared
> And simple compile with:
> make
>
> Does anyone know how to use hardfloat instead of soft float? Is there any option or flag? Thank you

The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
later versions of GCC, you can also use -mfpu=auto (sometimes).

You usually stuff them in CFLAGS and CXXFLAGS during make or when you
setup the environment before running configure.

Jeff

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16 10:24 ` Jeffrey Walton
@ 2022-02-16 11:29   ` Szabolcs Nagy
  2022-02-16 11:32     ` Jeffrey Walton
  0 siblings, 1 reply; 13+ messages in thread
From: Szabolcs Nagy @ 2022-02-16 11:29 UTC (permalink / raw)
  To: Jeffrey Walton, SIMONE MIONE; +Cc: musl

* Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <205212@studenti.unimore.it> wrote:
> >
> > I am trying to integrate musl in a baremetal environment. I already have float support but I can't manage to disable soft-float by musl.
> >
> > I configure with:
> > ./configure --target=aarch64-none-elf --enable-debug --disable-shared
> > And simple compile with:
> > make
> >
> > Does anyone know how to use hardfloat instead of soft float? Is there any option or flag? Thank you
> 
> The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> later versions of GCC, you can also use -mfpu=auto (sometimes).

that's for 32bit arm

there is no soft float abi for aarch64, so i'm not sure what's going on.

what does 'soft-float by musl' mean?

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16 11:29   ` Szabolcs Nagy
@ 2022-02-16 11:32     ` Jeffrey Walton
  2022-02-16 11:59       ` SIMONE MIONE
  0 siblings, 1 reply; 13+ messages in thread
From: Jeffrey Walton @ 2022-02-16 11:32 UTC (permalink / raw)
  To: Jeffrey Walton, SIMONE MIONE, musl

On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net> wrote:
>
> * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <205212@studenti.unimore.it> wrote:
> > >
> > > I am trying to integrate musl in a baremetal environment. I already have float support but I can't manage to disable soft-float by musl.
> > >
> > > I configure with:
> > > ./configure --target=aarch64-none-elf --enable-debug --disable-shared
> > > And simple compile with:
> > > make
> > >
> > > Does anyone know how to use hardfloat instead of soft float? Is there any option or flag? Thank you
> >
> > The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> > later versions of GCC, you can also use -mfpu=auto (sometimes).
>
> that's for 32bit arm
>
> there is no soft float abi for aarch64, so i'm not sure what's going on.

Oh, you're right My bad. I did not notice it was Aarch64.

Jeff

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16 11:32     ` Jeffrey Walton
@ 2022-02-16 11:59       ` SIMONE MIONE
  2022-02-16 14:57         ` Rich Felker
  0 siblings, 1 reply; 13+ messages in thread
From: SIMONE MIONE @ 2022-02-16 11:59 UTC (permalink / raw)
  To: noloader; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

Thank you all for your reply.
I meant when I add musl's lib*.a into my makefile, the compiler complains
about "undefined reference to __addtf3" (and others). Isn't that
soft-float? Or emulation float?
My supervisor told me "we already have float implementation so we don't
need those functions". So I was wondering if I need to disable it in some
way.


Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <noloader@gmail.com>
ha scritto:

> On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net> wrote:
> >
> > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> 205212@studenti.unimore.it> wrote:
> > > >
> > > > I am trying to integrate musl in a baremetal environment. I already
> have float support but I can't manage to disable soft-float by musl.
> > > >
> > > > I configure with:
> > > > ./configure --target=aarch64-none-elf --enable-debug --disable-shared
> > > > And simple compile with:
> > > > make
> > > >
> > > > Does anyone know how to use hardfloat instead of soft float? Is
> there any option or flag? Thank you
> > >
> > > The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> >
> > that's for 32bit arm
> >
> > there is no soft float abi for aarch64, so i'm not sure what's going on.
>
> Oh, you're right My bad. I did not notice it was Aarch64.
>
> Jeff
>

[-- Attachment #2: Type: text/html, Size: 2344 bytes --]

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16 11:59       ` SIMONE MIONE
@ 2022-02-16 14:57         ` Rich Felker
  2022-02-25 15:21           ` SIMONE MIONE
  0 siblings, 1 reply; 13+ messages in thread
From: Rich Felker @ 2022-02-16 14:57 UTC (permalink / raw)
  To: SIMONE MIONE; +Cc: noloader, musl

On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> Thank you all for your reply.
> I meant when I add musl's lib*.a into my makefile, the compiler complains
> about "undefined reference to __addtf3" (and others). Isn't that
> soft-float? Or emulation float?

It's the implementation of long double which is IEEE quad in the
aarch64 ABI.

> My supervisor told me "we already have float implementation so we don't
> need those functions". So I was wondering if I need to disable it in some
> way.

No, you need them because there is no fpu implementation of quad.


> Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <noloader@gmail.com>
> ha scritto:
> 
> > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net> wrote:
> > >
> > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > 205212@studenti.unimore.it> wrote:
> > > > >
> > > > > I am trying to integrate musl in a baremetal environment. I already
> > have float support but I can't manage to disable soft-float by musl.
> > > > >
> > > > > I configure with:
> > > > > ./configure --target=aarch64-none-elf --enable-debug --disable-shared
> > > > > And simple compile with:
> > > > > make
> > > > >
> > > > > Does anyone know how to use hardfloat instead of soft float? Is
> > there any option or flag? Thank you
> > > >
> > > > The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> > > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> > >
> > > that's for 32bit arm
> > >
> > > there is no soft float abi for aarch64, so i'm not sure what's going on.
> >
> > Oh, you're right My bad. I did not notice it was Aarch64.
> >
> > Jeff
> >

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-16 14:57         ` Rich Felker
@ 2022-02-25 15:21           ` SIMONE MIONE
  2022-02-25 16:41             ` Damian McGuckin
  2022-02-25 18:01             ` Rich Felker
  0 siblings, 2 replies; 13+ messages in thread
From: SIMONE MIONE @ 2022-02-25 15:21 UTC (permalink / raw)
  To: Rich Felker; +Cc: noloader, musl

[-- Attachment #1: Type: text/plain, Size: 2235 bytes --]

And what if I don't want quad precision?
I mean, when I try to print a float, vfprintf casts the float to a double
(and that's ok), but it seems like musl uses double as long double, so it
tries to cast the double to long double.
Is it true? Can I use a double (or float) as a double precision instead of
quad precision?

Il giorno mer 16 feb 2022 alle ore 15:57 Rich Felker <dalias@libc.org> ha
scritto:

> On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> > Thank you all for your reply.
> > I meant when I add musl's lib*.a into my makefile, the compiler complains
> > about "undefined reference to __addtf3" (and others). Isn't that
> > soft-float? Or emulation float?
>
> It's the implementation of long double which is IEEE quad in the
> aarch64 ABI.
>
> > My supervisor told me "we already have float implementation so we don't
> > need those functions". So I was wondering if I need to disable it in some
> > way.
>
> No, you need them because there is no fpu implementation of quad.
>
>
> > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <
> noloader@gmail.com>
> > ha scritto:
> >
> > > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net> wrote:
> > > >
> > > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> > > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > > 205212@studenti.unimore.it> wrote:
> > > > > >
> > > > > > I am trying to integrate musl in a baremetal environment. I
> already
> > > have float support but I can't manage to disable soft-float by musl.
> > > > > >
> > > > > > I configure with:
> > > > > > ./configure --target=aarch64-none-elf --enable-debug
> --disable-shared
> > > > > > And simple compile with:
> > > > > > make
> > > > > >
> > > > > > Does anyone know how to use hardfloat instead of soft float? Is
> > > there any option or flag? Thank you
> > > > >
> > > > > The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> > > > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> > > >
> > > > that's for 32bit arm
> > > >
> > > > there is no soft float abi for aarch64, so i'm not sure what's going
> on.
> > >
> > > Oh, you're right My bad. I did not notice it was Aarch64.
> > >
> > > Jeff
> > >
>

[-- Attachment #2: Type: text/html, Size: 3328 bytes --]

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-25 15:21           ` SIMONE MIONE
@ 2022-02-25 16:41             ` Damian McGuckin
  2022-02-25 16:48               ` SIMONE MIONE
  2022-02-25 18:01             ` Rich Felker
  1 sibling, 1 reply; 13+ messages in thread
From: Damian McGuckin @ 2022-02-25 16:41 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker, noloader

On Fri, 25 Feb 2022, SIMONE MIONE wrote:

> And what if I don't want quad precision?

What is the value of the

 	FLT_EVAL_METHOD

macro within your programs please?

Stay safe - Damian

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-25 16:41             ` Damian McGuckin
@ 2022-02-25 16:48               ` SIMONE MIONE
  0 siblings, 0 replies; 13+ messages in thread
From: SIMONE MIONE @ 2022-02-25 16:48 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker, noloader

[-- Attachment #1: Type: text/plain, Size: 857 bytes --]

I am targetting aarch64, and the content of
"musl/arch/aarch64/bits/float.h" is:

#define FLT_EVAL_METHOD 0

#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L

#define LDBL_MANT_DIG 113
#define LDBL_MIN_EXP (-16381)
#define LDBL_MAX_EXP 16384

#define LDBL_DIG 33
#define LDBL_MIN_10_EXP (-4931)
#define LDBL_MAX_10_EXP 4932

#define DECIMAL_DIG 36

Il giorno ven 25 feb 2022 alle ore 17:42 Damian McGuckin <damianm@esi.com.au>
ha scritto:

> On Fri, 25 Feb 2022, SIMONE MIONE wrote:
>
> > And what if I don't want quad precision?
>
> What is the value of the
>
>         FLT_EVAL_METHOD
>
> macro within your programs please?
>
> Stay safe - Damian
>

[-- Attachment #2: Type: text/html, Size: 1276 bytes --]

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-25 15:21           ` SIMONE MIONE
  2022-02-25 16:41             ` Damian McGuckin
@ 2022-02-25 18:01             ` Rich Felker
  2022-03-01  8:36               ` SIMONE MIONE
  1 sibling, 1 reply; 13+ messages in thread
From: Rich Felker @ 2022-02-25 18:01 UTC (permalink / raw)
  To: SIMONE MIONE; +Cc: noloader, musl

On Fri, Feb 25, 2022 at 04:21:59PM +0100, SIMONE MIONE wrote:
> And what if I don't want quad precision?

Then you don't have to use it, but at least some minimal amount of the
support code for it will be linked if you're using printf, since
linking can't see what format strings you're using with printf.

> I mean, when I try to print a float, vfprintf casts the float to a double
> (and that's ok), but it seems like musl uses double as long double, so it
> tries to cast the double to long double.
> Is it true?

Yes, the vfprintf converts all types up to the largest width/precision
one when loading them so that there are not duplicate code paths. In
the case of floating point, this is completely inconsequential because
only a very small number of operations are performed on the floating
point type to extract the exponent and mantissa and rounding
direction. After that it's all integer arithmetic. And of course the
result is not affected by this because all values of the narrower type
are representable in the wider type (that's the whole point).

> Can I use a double (or float) as a double precision instead of
> quad precision?

In short, no. There is no defined or supported ABI for aarch64 like
that.

In theory it would be possible to define, with assistance from the
tooling (compiler etc), an ABI for aarch64 where long double is just a
copy of double, but I'm unclear what value you'd be hoping to get out
of that. Saving a small amount of .text size?

Rich


> Il giorno mer 16 feb 2022 alle ore 15:57 Rich Felker <dalias@libc.org> ha
> scritto:
> 
> > On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> > > Thank you all for your reply.
> > > I meant when I add musl's lib*.a into my makefile, the compiler complains
> > > about "undefined reference to __addtf3" (and others). Isn't that
> > > soft-float? Or emulation float?
> >
> > It's the implementation of long double which is IEEE quad in the
> > aarch64 ABI.
> >
> > > My supervisor told me "we already have float implementation so we don't
> > > need those functions". So I was wondering if I need to disable it in some
> > > way.
> >
> > No, you need them because there is no fpu implementation of quad.
> >
> >
> > > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <
> > noloader@gmail.com>
> > > ha scritto:
> > >
> > > > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net> wrote:
> > > > >
> > > > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48 -0500]:
> > > > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > > > 205212@studenti.unimore.it> wrote:
> > > > > > >
> > > > > > > I am trying to integrate musl in a baremetal environment. I
> > already
> > > > have float support but I can't manage to disable soft-float by musl.
> > > > > > >
> > > > > > > I configure with:
> > > > > > > ./configure --target=aarch64-none-elf --enable-debug
> > --disable-shared
> > > > > > > And simple compile with:
> > > > > > > make
> > > > > > >
> > > > > > > Does anyone know how to use hardfloat instead of soft float? Is
> > > > there any option or flag? Thank you
> > > > > >
> > > > > > The GCC options for hard-floats are -mfpu=neon -mfloat-abi=hard. In
> > > > > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> > > > >
> > > > > that's for 32bit arm
> > > > >
> > > > > there is no soft float abi for aarch64, so i'm not sure what's going
> > on.
> > > >
> > > > Oh, you're right My bad. I did not notice it was Aarch64.
> > > >
> > > > Jeff
> > > >
> >

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-02-25 18:01             ` Rich Felker
@ 2022-03-01  8:36               ` SIMONE MIONE
  2022-03-01 13:10                 ` Rich Felker
  0 siblings, 1 reply; 13+ messages in thread
From: SIMONE MIONE @ 2022-03-01  8:36 UTC (permalink / raw)
  To: Rich Felker; +Cc: noloader, musl

[-- Attachment #1: Type: text/plain, Size: 4159 bytes --]

My problem is I don't know how to implement such functions. I mean,
functions like "__extenddftf2" and so on.
Does someone know how to do that? Does someone have some reference I can
check to implement those functions?

I already have integrated newlib into my system and I didn't have these
issues. Now I want to integrate musl but I can't because of this. What am I
missing?

Il giorno ven 25 feb 2022 alle ore 19:01 Rich Felker <dalias@libc.org> ha
scritto:

> On Fri, Feb 25, 2022 at 04:21:59PM +0100, SIMONE MIONE wrote:
> > And what if I don't want quad precision?
>
> Then you don't have to use it, but at least some minimal amount of the
> support code for it will be linked if you're using printf, since
> linking can't see what format strings you're using with printf.
>
> > I mean, when I try to print a float, vfprintf casts the float to a double
> > (and that's ok), but it seems like musl uses double as long double, so it
> > tries to cast the double to long double.
> > Is it true?
>
> Yes, the vfprintf converts all types up to the largest width/precision
> one when loading them so that there are not duplicate code paths. In
> the case of floating point, this is completely inconsequential because
> only a very small number of operations are performed on the floating
> point type to extract the exponent and mantissa and rounding
> direction. After that it's all integer arithmetic. And of course the
> result is not affected by this because all values of the narrower type
> are representable in the wider type (that's the whole point).
>
> > Can I use a double (or float) as a double precision instead of
> > quad precision?
>
> In short, no. There is no defined or supported ABI for aarch64 like
> that.
>
> In theory it would be possible to define, with assistance from the
> tooling (compiler etc), an ABI for aarch64 where long double is just a
> copy of double, but I'm unclear what value you'd be hoping to get out
> of that. Saving a small amount of .text size?
>
> Rich
>
>
> > Il giorno mer 16 feb 2022 alle ore 15:57 Rich Felker <dalias@libc.org>
> ha
> > scritto:
> >
> > > On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> > > > Thank you all for your reply.
> > > > I meant when I add musl's lib*.a into my makefile, the compiler
> complains
> > > > about "undefined reference to __addtf3" (and others). Isn't that
> > > > soft-float? Or emulation float?
> > >
> > > It's the implementation of long double which is IEEE quad in the
> > > aarch64 ABI.
> > >
> > > > My supervisor told me "we already have float implementation so we
> don't
> > > > need those functions". So I was wondering if I need to disable it in
> some
> > > > way.
> > >
> > > No, you need them because there is no fpu implementation of quad.
> > >
> > >
> > > > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <
> > > noloader@gmail.com>
> > > > ha scritto:
> > > >
> > > > > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net>
> wrote:
> > > > > >
> > > > > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48
> -0500]:
> > > > > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > > > > 205212@studenti.unimore.it> wrote:
> > > > > > > >
> > > > > > > > I am trying to integrate musl in a baremetal environment. I
> > > already
> > > > > have float support but I can't manage to disable soft-float by
> musl.
> > > > > > > >
> > > > > > > > I configure with:
> > > > > > > > ./configure --target=aarch64-none-elf --enable-debug
> > > --disable-shared
> > > > > > > > And simple compile with:
> > > > > > > > make
> > > > > > > >
> > > > > > > > Does anyone know how to use hardfloat instead of soft float?
> Is
> > > > > there any option or flag? Thank you
> > > > > > >
> > > > > > > The GCC options for hard-floats are -mfpu=neon
> -mfloat-abi=hard. In
> > > > > > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> > > > > >
> > > > > > that's for 32bit arm
> > > > > >
> > > > > > there is no soft float abi for aarch64, so i'm not sure what's
> going
> > > on.
> > > > >
> > > > > Oh, you're right My bad. I did not notice it was Aarch64.
> > > > >
> > > > > Jeff
> > > > >
> > >
>

[-- Attachment #2: Type: text/html, Size: 5833 bytes --]

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-03-01  8:36               ` SIMONE MIONE
@ 2022-03-01 13:10                 ` Rich Felker
  2022-03-25  9:08                   ` SIMONE MIONE
  0 siblings, 1 reply; 13+ messages in thread
From: Rich Felker @ 2022-03-01 13:10 UTC (permalink / raw)
  To: SIMONE MIONE; +Cc: noloader, musl

On Tue, Mar 01, 2022 at 09:36:44AM +0100, SIMONE MIONE wrote:
> My problem is I don't know how to implement such functions. I mean,
> functions like "__extenddftf2" and so on.
> Does someone know how to do that? Does someone have some reference I can
> check to implement those functions?

They come from the compiler runtime -- part of the compiler's contract
in generating calls to these functions to implement floating point
arithmetic is that it will *provide* them. This is via libgcc.a if
you're using gcc, or compiler-rt if you're using clang/LLVM. Other
compilers should either document that they expect you to use one of
these or provide their own (for example, PCC has its own).

> I already have integrated newlib into my system and I didn't have these
> issues. Now I want to integrate musl but I can't because of this. What am I
> missing?

It could be that configure didn't detect "LIBCC" correctly for you, or
that you're building in some way not using the configure script in
which case you'll need to make sure it's set. There's nothing
OS/distro-specific about these functions so, short of having something
else, you can just use libgcc.a from an aarch64 gcc toolchain if
needed.

Rich


> Il giorno ven 25 feb 2022 alle ore 19:01 Rich Felker <dalias@libc.org> ha
> scritto:
> 
> > On Fri, Feb 25, 2022 at 04:21:59PM +0100, SIMONE MIONE wrote:
> > > And what if I don't want quad precision?
> >
> > Then you don't have to use it, but at least some minimal amount of the
> > support code for it will be linked if you're using printf, since
> > linking can't see what format strings you're using with printf.
> >
> > > I mean, when I try to print a float, vfprintf casts the float to a double
> > > (and that's ok), but it seems like musl uses double as long double, so it
> > > tries to cast the double to long double.
> > > Is it true?
> >
> > Yes, the vfprintf converts all types up to the largest width/precision
> > one when loading them so that there are not duplicate code paths. In
> > the case of floating point, this is completely inconsequential because
> > only a very small number of operations are performed on the floating
> > point type to extract the exponent and mantissa and rounding
> > direction. After that it's all integer arithmetic. And of course the
> > result is not affected by this because all values of the narrower type
> > are representable in the wider type (that's the whole point).
> >
> > > Can I use a double (or float) as a double precision instead of
> > > quad precision?
> >
> > In short, no. There is no defined or supported ABI for aarch64 like
> > that.
> >
> > In theory it would be possible to define, with assistance from the
> > tooling (compiler etc), an ABI for aarch64 where long double is just a
> > copy of double, but I'm unclear what value you'd be hoping to get out
> > of that. Saving a small amount of .text size?
> >
> > Rich
> >
> >
> > > Il giorno mer 16 feb 2022 alle ore 15:57 Rich Felker <dalias@libc.org>
> > ha
> > > scritto:
> > >
> > > > On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> > > > > Thank you all for your reply.
> > > > > I meant when I add musl's lib*.a into my makefile, the compiler
> > complains
> > > > > about "undefined reference to __addtf3" (and others). Isn't that
> > > > > soft-float? Or emulation float?
> > > >
> > > > It's the implementation of long double which is IEEE quad in the
> > > > aarch64 ABI.
> > > >
> > > > > My supervisor told me "we already have float implementation so we
> > don't
> > > > > need those functions". So I was wondering if I need to disable it in
> > some
> > > > > way.
> > > >
> > > > No, you need them because there is no fpu implementation of quad.
> > > >
> > > >
> > > > > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <
> > > > noloader@gmail.com>
> > > > > ha scritto:
> > > > >
> > > > > > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net>
> > wrote:
> > > > > > >
> > > > > > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48
> > -0500]:
> > > > > > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > > > > > 205212@studenti.unimore.it> wrote:
> > > > > > > > >
> > > > > > > > > I am trying to integrate musl in a baremetal environment. I
> > > > already
> > > > > > have float support but I can't manage to disable soft-float by
> > musl.
> > > > > > > > >
> > > > > > > > > I configure with:
> > > > > > > > > ./configure --target=aarch64-none-elf --enable-debug
> > > > --disable-shared
> > > > > > > > > And simple compile with:
> > > > > > > > > make
> > > > > > > > >
> > > > > > > > > Does anyone know how to use hardfloat instead of soft float?
> > Is
> > > > > > there any option or flag? Thank you
> > > > > > > >
> > > > > > > > The GCC options for hard-floats are -mfpu=neon
> > -mfloat-abi=hard. In
> > > > > > > > later versions of GCC, you can also use -mfpu=auto (sometimes).
> > > > > > >
> > > > > > > that's for 32bit arm
> > > > > > >
> > > > > > > there is no soft float abi for aarch64, so i'm not sure what's
> > going
> > > > on.
> > > > > >
> > > > > > Oh, you're right My bad. I did not notice it was Aarch64.
> > > > > >
> > > > > > Jeff
> > > > > >
> > > >
> >

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

* Re: [musl] musl how to use hard float with aarch64-none-elf-gcc
  2022-03-01 13:10                 ` Rich Felker
@ 2022-03-25  9:08                   ` SIMONE MIONE
  0 siblings, 0 replies; 13+ messages in thread
From: SIMONE MIONE @ 2022-03-25  9:08 UTC (permalink / raw)
  To: Rich Felker; +Cc: noloader, musl

[-- Attachment #1: Type: text/plain, Size: 5698 bytes --]

Thank you, I have fix that with your hints. Musl couldn't find libgcc.a
from my toolchain, so I have "manually" added it and it worked fine!

Il giorno mar 1 mar 2022 alle ore 14:10 Rich Felker <dalias@libc.org> ha
scritto:

> On Tue, Mar 01, 2022 at 09:36:44AM +0100, SIMONE MIONE wrote:
> > My problem is I don't know how to implement such functions. I mean,
> > functions like "__extenddftf2" and so on.
> > Does someone know how to do that? Does someone have some reference I can
> > check to implement those functions?
>
> They come from the compiler runtime -- part of the compiler's contract
> in generating calls to these functions to implement floating point
> arithmetic is that it will *provide* them. This is via libgcc.a if
> you're using gcc, or compiler-rt if you're using clang/LLVM. Other
> compilers should either document that they expect you to use one of
> these or provide their own (for example, PCC has its own).
>
> > I already have integrated newlib into my system and I didn't have these
> > issues. Now I want to integrate musl but I can't because of this. What
> am I
> > missing?
>
> It could be that configure didn't detect "LIBCC" correctly for you, or
> that you're building in some way not using the configure script in
> which case you'll need to make sure it's set. There's nothing
> OS/distro-specific about these functions so, short of having something
> else, you can just use libgcc.a from an aarch64 gcc toolchain if
> needed.
>
> Rich
>
>
> > Il giorno ven 25 feb 2022 alle ore 19:01 Rich Felker <dalias@libc.org>
> ha
> > scritto:
> >
> > > On Fri, Feb 25, 2022 at 04:21:59PM +0100, SIMONE MIONE wrote:
> > > > And what if I don't want quad precision?
> > >
> > > Then you don't have to use it, but at least some minimal amount of the
> > > support code for it will be linked if you're using printf, since
> > > linking can't see what format strings you're using with printf.
> > >
> > > > I mean, when I try to print a float, vfprintf casts the float to a
> double
> > > > (and that's ok), but it seems like musl uses double as long double,
> so it
> > > > tries to cast the double to long double.
> > > > Is it true?
> > >
> > > Yes, the vfprintf converts all types up to the largest width/precision
> > > one when loading them so that there are not duplicate code paths. In
> > > the case of floating point, this is completely inconsequential because
> > > only a very small number of operations are performed on the floating
> > > point type to extract the exponent and mantissa and rounding
> > > direction. After that it's all integer arithmetic. And of course the
> > > result is not affected by this because all values of the narrower type
> > > are representable in the wider type (that's the whole point).
> > >
> > > > Can I use a double (or float) as a double precision instead of
> > > > quad precision?
> > >
> > > In short, no. There is no defined or supported ABI for aarch64 like
> > > that.
> > >
> > > In theory it would be possible to define, with assistance from the
> > > tooling (compiler etc), an ABI for aarch64 where long double is just a
> > > copy of double, but I'm unclear what value you'd be hoping to get out
> > > of that. Saving a small amount of .text size?
> > >
> > > Rich
> > >
> > >
> > > > Il giorno mer 16 feb 2022 alle ore 15:57 Rich Felker <
> dalias@libc.org>
> > > ha
> > > > scritto:
> > > >
> > > > > On Wed, Feb 16, 2022 at 12:59:13PM +0100, SIMONE MIONE wrote:
> > > > > > Thank you all for your reply.
> > > > > > I meant when I add musl's lib*.a into my makefile, the compiler
> > > complains
> > > > > > about "undefined reference to __addtf3" (and others). Isn't that
> > > > > > soft-float? Or emulation float?
> > > > >
> > > > > It's the implementation of long double which is IEEE quad in the
> > > > > aarch64 ABI.
> > > > >
> > > > > > My supervisor told me "we already have float implementation so we
> > > don't
> > > > > > need those functions". So I was wondering if I need to disable
> it in
> > > some
> > > > > > way.
> > > > >
> > > > > No, you need them because there is no fpu implementation of quad.
> > > > >
> > > > >
> > > > > > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey Walton <
> > > > > noloader@gmail.com>
> > > > > > ha scritto:
> > > > > >
> > > > > > > On Wed, Feb 16, 2022 at 6:29 AM Szabolcs Nagy <nsz@port70.net>
> > > wrote:
> > > > > > > >
> > > > > > > > * Jeffrey Walton <noloader@gmail.com> [2022-02-16 05:24:48
> > > -0500]:
> > > > > > > > > On Wed, Feb 16, 2022 at 4:51 AM SIMONE MIONE <
> > > > > > > 205212@studenti.unimore.it> wrote:
> > > > > > > > > >
> > > > > > > > > > I am trying to integrate musl in a baremetal
> environment. I
> > > > > already
> > > > > > > have float support but I can't manage to disable soft-float by
> > > musl.
> > > > > > > > > >
> > > > > > > > > > I configure with:
> > > > > > > > > > ./configure --target=aarch64-none-elf --enable-debug
> > > > > --disable-shared
> > > > > > > > > > And simple compile with:
> > > > > > > > > > make
> > > > > > > > > >
> > > > > > > > > > Does anyone know how to use hardfloat instead of soft
> float?
> > > Is
> > > > > > > there any option or flag? Thank you
> > > > > > > > >
> > > > > > > > > The GCC options for hard-floats are -mfpu=neon
> > > -mfloat-abi=hard. In
> > > > > > > > > later versions of GCC, you can also use -mfpu=auto
> (sometimes).
> > > > > > > >
> > > > > > > > that's for 32bit arm
> > > > > > > >
> > > > > > > > there is no soft float abi for aarch64, so i'm not sure
> what's
> > > going
> > > > > on.
> > > > > > >
> > > > > > > Oh, you're right My bad. I did not notice it was Aarch64.
> > > > > > >
> > > > > > > Jeff
> > > > > > >
> > > > >
> > >
>

[-- Attachment #2: Type: text/html, Size: 8197 bytes --]

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

end of thread, other threads:[~2022-03-25  9:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16  9:50 [musl] musl how to use hard float with aarch64-none-elf-gcc SIMONE MIONE
2022-02-16 10:24 ` Jeffrey Walton
2022-02-16 11:29   ` Szabolcs Nagy
2022-02-16 11:32     ` Jeffrey Walton
2022-02-16 11:59       ` SIMONE MIONE
2022-02-16 14:57         ` Rich Felker
2022-02-25 15:21           ` SIMONE MIONE
2022-02-25 16:41             ` Damian McGuckin
2022-02-25 16:48               ` SIMONE MIONE
2022-02-25 18:01             ` Rich Felker
2022-03-01  8:36               ` SIMONE MIONE
2022-03-01 13:10                 ` Rich Felker
2022-03-25  9:08                   ` SIMONE MIONE

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).