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,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7579 invoked from network); 13 Oct 2021 05:36:05 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 13 Oct 2021 05:36:05 -0000 Received: (qmail 1404 invoked by uid 550); 13 Oct 2021 05:36:03 -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 1367 invoked from network); 13 Oct 2021 05:36:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=98uGtEP8SgweshjxptkqAWGWGOvYt18qLGAxN7HCqIw=; b=Rp54v3pWApxWhDOGZ1EXxUCIx2AFGfygjIUfTIdBvlMB4FecYIivqXyHhXhKT/Hl/1 qClh7o4nYdCl8ryPzb5n3mrt7jqeDRazUJOjli+yHuXldbUb39Pphh5z1v0EEd5Q6r8K wYdvpkmigAd4LvzG4HzxLvQlACtoxjcmeQw0vHePiA3ftlwKOZQBzM2UIM9sJTd1oDdM YF1O5RBP8VktOoSZik0v/WoRQITdY7Mk+/i5f9WEO2IzOZPSSObfXw9gdhxueQN3U48v HHWIKHlE132wqo3/KVysMJ3yv2oD3EAAsiv/sPKAaQMUEz0iLhPhLFNHb+cgE5QWdEJb jrGA== 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; bh=98uGtEP8SgweshjxptkqAWGWGOvYt18qLGAxN7HCqIw=; b=4dbWZTO1vfrW31NlQmMpA1NXUviTRhHVC3r26RXJiFIKvE+9aRzxf4AQuddrrOR9jC bSJRf/my0m2McV65+bV8MsM6EXbwKt8JbBV412WWrsZ/8PGYe2ngao0TE44DdaVeHfAF yv/5qqeQS3LerbDSdSLzaz5J3NcXquGJ5oSCjBpky2ZP6bEvVznZ5jlKERUvAGV4yWwQ vCahuPwtKDNs4lVc/lIc3sSM4wwtThMKVBvt7uoJIbkmLcWBEomCuXKIIsAXbYW2CiGz kPqpJaE/6GH/d11h3tft4DnxZlig2twiPT1sEZw90aKEJI/S2Bgs3X06sl4tn0LDkGgs IEDA== X-Gm-Message-State: AOAM533s9KdOjEH5ZOW7ALfHmQi+GX9JDhXvz+CC24lJ4XQb7xGp+Hcf GDidmKfS10tHqB3MMTLQKLdA/Hf71mF0LmF7X5tS4Ps3 X-Google-Smtp-Source: ABdhPJzzDrorWycZqUcd/+a2ANZ+vq2CbznorkFHN+8tEjyNGMopND3uM3Dw2pIGfSbt9+TzxZ8uT8erI10d6iqlP9I= X-Received: by 2002:a05:6602:2b06:: with SMTP id p6mr28805552iov.17.1634103349701; Tue, 12 Oct 2021 22:35:49 -0700 (PDT) MIME-Version: 1.0 References: <20211011004346.13768de6@tpx.quinq.eu.org> In-Reply-To: From: Nagakamira Date: Tue, 12 Oct 2021 22:35:30 -0700 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000af70bd05ce3555cb" Subject: Re: [musl] Newbie cross compiling with LLVM --000000000000af70bd05ce3555cb Content-Type: text/plain; charset="UTF-8" you need to compile compiler-rt builtins and put them in clang folder and then pass LIBCC="$(clang --target=blah-blah-blah -print-libgcc-file-name)" On Tue, Oct 12, 2021 at 7:34 PM Matt Andrews wrote: > I'm currently using this to compile with LLVM > > AR=/usr/lib/llvm-13/bin/llvm-ar \ > RANLIB=/usr/lib/llvm-13/bin/llvm-ranlib \ > CC=/usr/lib/llvm-13/bin/clang \ > CFLAGS="-fuse-ld=/usr/lib/llvm-13/bin/ld.lld --rtlib=compiler-rt > --target=armv7a-linux-eabihf -mcpu=cortex-a8" \ > LIBCC=-lcompiler_rt \ > ./configure \ > --prefix=$PREFIX/usr \ > --syslibdir=$PREFIX/lib \ > --target=armv7a-linux-eabihf \ > && make \ > && make install > > This is the output from ./configure > > checking for C compiler... /usr/lib/llvm-13/bin/clang > checking whether C compiler works... yes > checking whether compiler accepts -Werror=unknown-warning-option... yes > checking whether compiler accepts -Werror=unused-command-line-argument... > yes > checking whether compiler accepts -Werror=ignored-optimization-argument... > yes > checking whether linker accepts -Werror=unknown-warning-option... yes > checking whether linker accepts -Werror=unused-command-line-argument... yes > checking for C compiler family... clang > checking for toolchain wrapper to build... clang > checking target system type... armv7a-linux-eabihf > checking whether compiler accepts -std=c99... yes > checking whether compiler accepts -nostdinc... yes > checking whether compiler accepts -ffreestanding... yes > checking whether compiler accepts -fexcess-precision=standard... no > checking whether compiler accepts -frounding-math... yes > checking whether compiler needs attribute((may_alias)) suppression... no > checking whether compiler accepts -Wa,--noexecstack... yes > checking whether compiler accepts -fno-stack-protector... yes > checking whether compiler accepts -fno-tree-loop-distribute-patterns... no > checking whether we should preprocess assembly to add debugging > information... no > checking for optimization settings... using defaults > checking whether compiler accepts -Os... yes > components to be optimized for speed: internal malloc string > checking whether compiler accepts -pipe... yes > checking whether compiler accepts -fomit-frame-pointer... yes > checking whether compiler accepts -fno-unwind-tables... yes > checking whether compiler accepts -fno-asynchronous-unwind-tables... yes > checking whether compiler accepts -ffunction-sections... yes > checking whether compiler accepts -fdata-sections... yes > checking whether compiler accepts -w... yes > checking whether compiler accepts -Wno-pointer-to-int-cast... yes > checking whether compiler accepts -Werror=implicit-function-declaration... > yes > checking whether compiler accepts -Werror=implicit-int... yes > checking whether compiler accepts -Werror=pointer-sign... yes > checking whether compiler accepts -Werror=pointer-arith... yes > checking whether compiler accepts -Werror=int-conversion... yes > checking whether compiler accepts -Werror=incompatible-pointer-types... yes > checking whether compiler accepts -Werror=discarded-qualifiers... no > checking whether compiler accepts -Werror=discarded-array-qualifiers... no > checking whether compiler accepts -Qunused-arguments... yes > checking whether compiler accepts -Waddress... yes > checking whether compiler accepts -Warray-bounds... yes > checking whether compiler accepts -Wchar-subscripts... yes > checking whether compiler accepts -Wduplicate-decl-specifier... yes > checking whether compiler accepts -Winit-self... yes > checking whether compiler accepts -Wreturn-type... yes > checking whether compiler accepts -Wsequence-point... yes > checking whether compiler accepts -Wstrict-aliasing... yes > checking whether compiler accepts -Wunused-function... yes > checking whether compiler accepts -Wunused-label... yes > checking whether compiler accepts -Wunused-variable... yes > checking preprocessor condition __PIC__... false > checking whether linker accepts -Wl,--sort-section,alignment... yes > checking whether linker accepts -Wl,--sort-common... yes > checking whether linker accepts -Wl,--gc-sections... yes > checking whether linker accepts -Wl,--hash-style=both... yes > checking whether linker accepts -Wl,--no-undefined... yes > checking whether linker accepts -Wl,--exclude-libs=ALL... yes > checking whether linker accepts -Wl,--dynamic-list=./dynamic.list... yes > using compiler runtime libraries: -lcompiler_rt > checking preprocessor condition __thumb2__... false > checking preprocessor condition __ARMEB__... false > checking preprocessor condition __ARM_PCS_VFP... true > checking whether clang's vfp asm constraints work... yes > configured for arm variant: armhf > checking whether compiler's long double definition matches float.h... yes > checking preprocessor condition __FAST_MATH__... false > creating config.mak... done > > but now I get this error when compiling > > ld.lld: error: unable to find library -lcompiler_rt > > Have I made an error in the way I'm calling ./configure? > > Just to reiterate, I'm trying to use LLVM to cross compile from x86_64 > Linux to armv7a-linux-eabihf. > > On Tue, Oct 12, 2021 at 5:09 PM Nagakamira wrote: > >> You can pass --unwindlib=libunwind and rtlib, they are both link options >> >> On Tue, Oct 12, 2021, 8:55 AM Matt Andrews wrote: >> >>> > --rtlib=compiler-rt >>> >>> Is that a compiler option or a linker option? I used it in both places, >>> but still get the same error. >>> >>> On Tue, Oct 12, 2021 at 4:00 PM Nagakamira wrote: >>> >>>> --rtlib=compiler-rt >>>> >>>> On Tue, Oct 12, 2021, 7:58 AM Matt Andrews >>>> wrote: >>>> >>>>> > -fuse-ld=lld >>>>> >>>>> I actually used >>>>> >>>>> -fuse-ld=ld.lld >>>>> >>>>> That did the trick, but has unlocked another error >>>>> >>>>> ld.lld: error: unable to find library -lgcc >>>>> ld.lld: error: unable to find library -lgcc_eh >>>>> >>>>> I thought musl compiles with it's own headers? >>>>> >>>>> On Tue, Oct 12, 2021 at 3:54 PM Nagakamira >>>>> wrote: >>>>> >>>>>> -fuse-ld=lld >>>>>> >>>>>> On Tue, Oct 12, 2021, 3:26 AM Jeffrey Walton >>>>>> wrote: >>>>>> >>>>>>> On Mon, Oct 11, 2021 at 7:55 PM Matt Andrews >>>>>>> wrote: >>>>>>> > >>>>>>> > >> How do I specify which linker to use? >>>>>>> > > >>>>>>> > >LD. Also see >>>>>>> https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html >>>>>>> . >>>>>>> > >>>>>>> > Looking at the ./configure for musl (which is not based on >>>>>>> autoconf according to the docs), there is no mention of LD. Setting LD for >>>>>>> ./configure and/or the call to make still results in the error. >>>>>>> > >>>>>>> > Who calls the linker? The compiler or make? Shouldn't clang know >>>>>>> where it's linker is? How to tell clang which linker to use? >>>>>>> >>>>>>> You can have the compiler driver call the linker for you by >>>>>>> specifying >>>>>>> -o with an output file name. In that case, $CC or $CXX will drive the >>>>>>> link. And in this case, your LDFLAGS should prefix options with -Wl >>>>>>> to >>>>>>> tell the compiler driver the option is for the linker. >>>>>>> >>>>>>> Jeff >>>>>>> >>>>>> --000000000000af70bd05ce3555cb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
you need to compile compiler-rt builtins and put them in c= lang folder and then pass LIBCC=3D"$(clang --target=3Dblah-blah-blah -= print-libgcc-file-name)"

On Tue, Oct 12, 2021 at 7:34 PM Matt Andrews = <mattandrews@gmail.com> = wrote:
I'm currently using this to compile with LLVM
<= br>
AR=3D/usr/lib/llvm-13/bin/llvm-ar \
RANLIB=3D/usr/lib/llvm-13/bin/llvm-ranlib \
CC=3D/usr/lib/llvm-13/bin/clang \
CFLAGS=3D"-fuse-ld=3D/usr/lib/llvm-13/bin/ld.lld --rtli= b=3Dcompiler-rt --target=3Darmv7a-linux-eabihf -mcpu=3Dcortex-a8" \
LIBCC=3D-lcompiler_rt \
./configure \
--p= refix=3D$PREFIX/usr \
--syslibdir=3D$P= REFIX/lib \
--target=3Darmv7a-linux-ea= bihf \
&& make \=
&& make install
=
This is the output from ./con= figure

checking for C compiler... /usr/lib/llvm-13/bin/clang = =
= checking = whether C compiler works... yes = =
<= span style=3D"font-family:arial,sans-serif"> checking whether compiler a= ccepts -Werror=3Dunknown-warning-option... yes<= /div>
checking whether compiler accepts -Werror=3Dunused-command-line-ar= gument... yes
checking whether compile= r accepts -Werror=3Dignored-optimization-argument... yes
checking whether linker accepts -Werror=3Dunknown-warnin= g-option... yes
checking whether linke= r accepts -Werror=3Dunused-command-line-argument... yes
checking for C compiler family... clang
checking for toolchain wrapper to build... clang=
checking target system type... armv7a-linux-= eabihf
checking whether compiler accep= ts -std=3Dc99... yes
checking whether = compiler accepts -nostdinc... yes
chec= king whether compiler accepts -ffreestanding... yes
checking whether compiler accepts -fexcess-precision=3Dstanda= rd... no
checking whether compiler acc= epts -frounding-math... yes
<= font size=3D"2"> checking w= hether compiler needs attribute((may_alias)) suppression... no
checking whether compiler accepts -Wa,--noexecstac= k... yes
checking whether compiler acc= epts -fno-stack-protector... yes
check= ing whether compiler accepts -fno-tree-loop-distribute-patterns... no
checking whether we should preprocess assem= bly to add debugging information... no
= checking for optimization settings... using defaults<= /span>
checking whether compiler accepts -Os... yes<= /span>
<= span style=3D"color:rgb(0,0,0)"> components to be optimized for speed: internal mallo= c string
checking whether compiler acc= epts -pipe... yes
checking whether co= mpiler accepts -fomit-frame-pointer... yes
checking whether compiler accepts -fno-unwind-tables... yes
checking whether compiler accepts -fno-asynchron= ous-unwind-tables... yes
checking whe= ther compiler accepts -ffunction-sections... yes
checking whether compiler accepts -fdata-sections... yes
checking whether compiler accepts -w... yes=
checking whether compiler accepts -Wn= o-pointer-to-int-cast... yes
= checking = whether compiler accepts -Werror=3Dimplicit-function-declaration... yes
checking whether compiler accepts -Werror= =3Dimplicit-int... yes
checking whethe= r compiler accepts -Werror=3Dpointer-sign... yes
checking whether compiler accepts -Werror=3Dpointer-arith... y= es
checking whether compiler accepts -= Werror=3Dint-conversion... yes
checkin= g whether compiler accepts -Werror=3Dincompatible-pointer-types... yes
checking whether compiler accepts -Werror= =3Ddiscarded-qualifiers... no
checking= whether compiler accepts -Werror=3Ddiscarded-array-qualifiers... no=
checking whether compiler accepts -Qunused-a= rguments... yes
checking whether compi= ler accepts -Waddress... yes
= checking = whether compiler accepts -Warray-bounds... yes<= /div>
checking whether compiler accepts -Wchar-subscripts... yes<= /font>
checking whether compiler accepts -Wduplicate= -decl-specifier... yes
checking whethe= r compiler accepts -Winit-self... yes
= checking whether compiler accepts -Wreturn-type... yes=
checking whether compiler accepts -Wsequence-point... yes<= /span>
checking whether compiler accepts -Ws= trict-aliasing... yes
checking whether= compiler accepts -Wunused-function... yes
checking whether compiler accepts -Wunused-label... yes<= /span>
<= span style=3D"color:rgb(0,0,0)"> checking whether compiler accepts -Wunused-variable.= .. yes
checking preprocessor condition= __PIC__... false
checking whether li= nker accepts -Wl,--sort-section,alignment... yes
checking whether linker accepts -Wl,--sort-common... yes
checking whether linker accepts -Wl,--gc-se= ctions... yes
checking whether linker = accepts -Wl,--hash-style=3Dboth... yes
= checking whether linker accepts -Wl,--no-undefined... yes
checking whether linker accepts -Wl,--exclude-libs=3DA= LL... yes
checking whether linker acce= pts -Wl,--dynamic-list=3D./dynamic.list... yes<= /div>
using compiler runtime libraries: -lcompiler_rt
checking preprocessor condition __thumb2__... false
checking preprocessor condition __ARMEB__.= .. false
checking preprocessor conditi= on __ARM_PCS_VFP... true
checking whe= ther clang's vfp asm constraints work... yes
configured for arm variant: armhf<= /div>
checking whether compiler's long double definition matches flo= at.h... yes
= checking preprocessor cond= ition __FAST_MATH__... false
= creating = config.mak... done
<= /span>

but now I get this error = when compiling

ld.lld: error: unable to find library -lcompiler_rt
=
Have I made = an error in the way I'm calling ./configure?
<= span style=3D"background-color:rgb(255,255,255)">
Just to reiterate, I'm try= ing to use LLVM to cross compile from x86_64 Linux to armv7a-linux-eabihf.<= br>

On Tue, Oct 12, 2021 at 5:= 09 PM Nagakamira <nagakamira@gmail.com> wrote:
You can pass --unwindlib=3Dlibunw= ind and rtlib, they are both link options

On Tue, Oct 12, 2021, 8:55 AM Matt= Andrews <mat= tandrews@gmail.com> wrote:
> --rtlib=3Dcompiler-rt

Is that a compiler option or a linker option? I used it in= both places, but still get the same error.

On Tue, Oct 12, 2021= at 4:00 PM Nagakamira <nagakamira@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
--rtlib= =3Dcompiler-rt

On Tue, Oct 12, 2021, 7:58 AM Matt Andrews <mattandre= ws@gmail.com> wrote:
> -fuse-ld=3Dlld

<= div>I actually used

=C2=A0=C2=A0=C2=A0 -fuse-ld=3D= ld.lld

That did the trick, but has unlocked anothe= r error

=C2=A0=C2=A0=C2=A0 ld.lld: error: unable t= o find library -lgcc
=C2=A0=C2=A0=C2=A0 ld.lld: error: unable to = find library -lgcc_eh

I thought musl compiles with= it's own headers?

On Tue, Oct 12, 2021 at 3:54 PM Nagakamira = <nagakamira@gmail.com> wrote:
-fuse-ld=3Dlld
=
On Tue= , Oct 12, 2021, 3:26 AM Jeffrey Walton <noloader@gmail.com> wrote:
On = Mon, Oct 11, 2021 at 7:55 PM Matt Andrews <matt= andrews@gmail.com> wrote:
>
> >> How do I specify which linker to use?
> >
> >LD. Also see https://www.gnu.org/software/make/manual/html_= node/Implicit-Variables.html.
>
> Looking at the ./configure for musl (which is not based on autoconf ac= cording to the docs), there is no mention of LD. Setting LD for ./configure= and/or the call to make still results in the error.
>
> Who calls the linker? The compiler or make? Shouldn't clang know w= here it's linker is? How to tell clang which linker to use?

You can have the compiler driver call the linker for you by specifying
-o with an output file name. In that case, $CC or $CXX will drive the
link. And in this case, your LDFLAGS should prefix options with -Wl to
tell the compiler driver the option is for the linker.

Jeff
--000000000000af70bd05ce3555cb--