From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29461 invoked from network); 25 Mar 2022 09:08:56 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 25 Mar 2022 09:08:56 -0000 Received: (qmail 31922 invoked by uid 550); 25 Mar 2022 09:08:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 31882 invoked from network); 25 Mar 2022 09:08:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=studenti.unimore.it; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xjkGtPhBWfYu+yc5Icr10GU7Oo8Slz354a+Duhw/WZc=; b=QdQXt5YD+6rkPWPouoCGSIGiJr/AS1MJGp2woRta74OGMN0ajmFzEI1RioyRScRkbe 2MTEOdphI5fS3+/iAp9fD7LIg4pkbE0JdgxlO5+krHnjvUcD9KgymSaHyCJCwGiPeAC+ aMoXZ1o8ZKKg22akWHR/0phuq6V5Yvd3Jx0uxohPaBhGWnV0DhPeG+v8+95TvmN0wb2P 8m5XLSyzEVTUWOyatXArxv7xf3E0fE1bGt7CUW45YePxLYC1E/2A1dS1ek2oL3Q31+cG 0aEt8umzFJ6edMT/oy/xSSytdo/E25zW7jv5/p/UqVgBpUS0T8cxAQGrBLriBu+Na/nA cUgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xjkGtPhBWfYu+yc5Icr10GU7Oo8Slz354a+Duhw/WZc=; b=aaxuH6dL+ePgq8X/UKZ7yP3vAeEWraJBA7kFFBB08TWsn+6qgbf/Qvif8/ewALqL1X IjX4edw/hfvGvjJ7AW4xVlHK8mbzSTPSqITMS3+DVWITfquxE9qdki63XUEXev+rQ5z5 kfTcmrXNKsdmETThcaIUvgV8SyNYjPoknoEEIfzhS5GLd/MVEEAoR0n1ysIRg9H5IFfp NMTegvhxLU+c8EbLk8GGBCzAxM0E8s3OWuR5lvGG4j2eCEaVhUnRRIQHKwWLJ4OAGpgI +VYVxmz2Hf+DmQKcNlsh3g/3T1wl4PIaiEdP/bmUMNf9lfaMPJMszVN1mOYBl1OCFKx6 z6nA== X-Gm-Message-State: AOAM531q4ip6eTHdMhYtneDNfNceJ5QpU57SpuqeW53GvkTiDcq7QuJv 8bUbiltJ6VWzYwKGjcj6R8cHFI3qQrV0eSTGMT/Xsg== X-Google-Smtp-Source: ABdhPJzd55d62Ny3H+r8RmtenQDgppVN3eVkyhXTO3ZiEu6pOZT9bbfhP2ERKYXWk0keiZOFfBGprkdQwsoLvDjDVKI= X-Received: by 2002:a0d:fc83:0:b0:2e5:b0f4:c125 with SMTP id m125-20020a0dfc83000000b002e5b0f4c125mr9361599ywf.347.1648199318473; Fri, 25 Mar 2022 02:08:38 -0700 (PDT) MIME-Version: 1.0 References: <20220216112924.GG1320090@port70.net> <20220216145736.GN7074@brightrain.aerifal.cx> <20220225180114.GZ7074@brightrain.aerifal.cx> <20220301131037.GF7074@brightrain.aerifal.cx> In-Reply-To: <20220301131037.GF7074@brightrain.aerifal.cx> From: SIMONE MIONE <205212@studenti.unimore.it> Date: Fri, 25 Mar 2022 10:08:27 +0100 Message-ID: To: Rich Felker Cc: noloader@gmail.com, musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000e5a1b705db074e77" Subject: Re: [musl] musl how to use hard float with aarch64-none-elf-gcc --000000000000e5a1b705db074e77 Content-Type: text/plain; charset="UTF-8" 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 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 > 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 > > > wrote: > > > > > > > > > > > > > > > > * Jeffrey Walton [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 > > > > > > > > > > > > > > > > --000000000000e5a1b705db074e77 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you, I have fix that with your hints. Musl couldn= 9;t find libgcc.a from my toolchain, so I have "manually" added i= t and it worked fine!

Il giorno mar 1 mar 2022 alle ore 14:10 Rich Felke= r <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 c= an
> check to implement those functions?

They come from the compiler runtime -- part of the compiler's contract<= br> 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<= br> 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 fo= r 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 amou= nt of the
> > support code for it will be linked if you're using printf, si= nce
> > linking can't see what format strings you're using with p= rintf.
> >
> > > I mean, when I try to print a float, vfprintf casts the floa= t to a double
> > > (and that's ok), but it seems like musl uses double as l= ong 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/prec= ision
> > one when loading them so that there are not duplicate code paths.= In
> > the case of floating point, this is completely inconsequential be= cause
> > only a very small number of operations are performed on the float= ing
> > point type to extract the exponent and mantissa and rounding
> > direction. After that it's all integer arithmetic. And of cou= rse 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 li= ke
> > that.
> >
> > In theory it would be possible to define, with assistance from th= e
> > tooling (compiler etc), an ABI for aarch64 where long double is j= ust a
> > copy of double, but I'm unclear what value you'd be hopin= g 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 makef= ile, 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 IEE= E 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 implementatio= n of quad.
> > > >
> > > >
> > > > > Il giorno mer 16 feb 2022 alle ore 12:32 Jeffrey W= alton <
> > > > 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 SIM= ONE 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=3Daarch64= -none-elf --enable-debug
> > > > --disable-shared
> > > > > > > > > And simple compile with:
> > > > > > > > > make
> > > > > > > > >
> > > > > > > > > Does anyone know how to use ha= rdfloat instead of soft float?
> > Is
> > > > > > there any option or flag? Thank you
> > > > > > > >
> > > > > > > > The GCC options for hard-floats are= -mfpu=3Dneon
> > -mfloat-abi=3Dhard. In
> > > > > > > > later versions of GCC, you can also= use -mfpu=3Dauto (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
> > > > > >
> > > >
> >
--000000000000e5a1b705db074e77--