mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Failed to build musl 1.2.2 by using clang cross compiler
@ 2021-10-24  3:34 Zhu Chunlin
  2021-10-24 14:22 ` Markus Wichmann
  0 siblings, 1 reply; 8+ messages in thread
From: Zhu Chunlin @ 2021-10-24  3:34 UTC (permalink / raw)
  To: musl

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

Hello,


I am trying to use Clang cross compiler to build musl libc 1.2.2, as following:

./configure CC=clang --target=aarch64
make


but it report the below error:

clang -std=c99 -nostdinc -ffreestanding -frounding-math -Wa,--noexecstack -D_XOPEN_SOURCE=700 -I./arch/aarch64 -I./arch/generic -Iobj/src/internal -I./src/include -I./src/internal -Iobj/include -I./include  -Os -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -w -Wno-pointer-to-int-cast -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -Werror=int-conversion -Werror=incompatible-pointer-types -Qunused-arguments -Waddress -Warray-bounds -Wchar-subscripts -Wduplicate-decl-specifier -Winit-self -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wunused-function -Wunused-label -Wunused-variable  -fPIC -fno-stack-protector -DCRT -c -o obj/crt/Scrt1.o crt/Scrt1.c
<inline asm>:5:11: error: unknown token in expression
        mov x29, #0
                 ^
<inline asm>:6:11: error: unknown token in expression
        mov x30, #0
                 ^
<inline asm>:7:2: error: unknown use of instruction mnemonic without a size suffix
        mov x0, sp
        ^
<inline asm>:10:2: error: invalid instruction mnemonic 'adrp'
        adrp x1, _DYNAMIC


Note: It's OK when I don't specify the --target to aarch64

./configure CC=clang
make


Thanks,

Simon


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

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

* Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-24  3:34 [musl] Failed to build musl 1.2.2 by using clang cross compiler Zhu Chunlin
@ 2021-10-24 14:22 ` Markus Wichmann
  2021-10-25  5:03   ` 回复: " Zhu Chunlin
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Wichmann @ 2021-10-24 14:22 UTC (permalink / raw)
  To: musl

On Sun, Oct 24, 2021 at 03:34:56AM +0000, Zhu Chunlin wrote:
> ./configure CC=clang --target=aarch64

I believe you want ./configure CC="clang --target=aarch64". You only
specified the target for the configure script but not to clang itself.
That's why the --target is absent from the command line that make
generated. And so it fails the first time it sees an actual assembly
file.

Ciao,
Markus

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

* 回复: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-24 14:22 ` Markus Wichmann
@ 2021-10-25  5:03   ` Zhu Chunlin
  2021-10-25  8:44     ` Jeffrey Walton
  0 siblings, 1 reply; 8+ messages in thread
From: Zhu Chunlin @ 2021-10-25  5:03 UTC (permalink / raw)
  To: musl, nullplan


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

Hello Markus,

Thanks!

AR=/usr/local/bin/llvm-ar \
RANLIB=/usr/local/bin/llvm-ranlib \
CC=/usr/local/bin/clang \
CFLAGS="-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt --target=aarch64" \
LIBCC=-lcompiler_rt \
./configure --target=aarch64 \
&& make

But when I use the above config, it reports the below error, but I don't understand why there are gcc error, I have explict specify to use clang and ld.lld
[cid:316ac50e-0bf9-49dc-a4d3-0c469e9d2248]

Best Regards,
Simon
________________________________
发件人: Markus Wichmann <nullplan@gmx.net>
发送时间: 2021年10月24日 22:22
收件人: musl@lists.openwall.com <musl@lists.openwall.com>
主题: Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler

On Sun, Oct 24, 2021 at 03:34:56AM +0000, Zhu Chunlin wrote:
> ./configure CC=clang --target=aarch64

I believe you want ./configure CC="clang --target=aarch64". You only
specified the target for the configure script but not to clang itself.
That's why the --target is absent from the command line that make
generated. And so it fails the first time it sees an actual assembly
file.

Ciao,
Markus

[-- Attachment #1.2: Type: text/html, Size: 3148 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 44398 bytes --]

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

* Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-25  5:03   ` 回复: " Zhu Chunlin
@ 2021-10-25  8:44     ` Jeffrey Walton
  2021-10-25 13:26       ` 回复: " Zhu Chunlin
  0 siblings, 1 reply; 8+ messages in thread
From: Jeffrey Walton @ 2021-10-25  8:44 UTC (permalink / raw)
  To: musl; +Cc: nullplan


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

On Mon, Oct 25, 2021 at 1:04 AM Zhu Chunlin <simon_0214@hotmail.com> wrote:

> Hello Markus,
>
> Thanks!
>
> AR=/usr/local/bin/llvm-ar \
> RANLIB=/usr/local/bin/llvm-ranlib \
> CC=/usr/local/bin/clang \
> CFLAGS="-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt
> --target=aarch64" \
> LIBCC=-lcompiler_rt \
> ./configure --target=aarch64 \
> && make
>
> But when I use the above config, it reports the below error, but I don't
> understand why there are gcc error, I have explict specify to use clang and
> ld.lld
>
>
-fuse-ld=/usr/local/bin/ld.lld is a LDFLAG. Since you are using GCC to
drive link, set:

    LDFLAGS = "-Wl,-fuse-ld=/usr/local/bin/ld.lld "
--rtlib=compiler-rt and --target=aarch64may need to go into LDFLAGS, too.

--noexecstack is a ASFLAG. Use:

    ASFLAGS = "-Wa,--noexecstack"

Jeff

[-- Attachment #1.2: Type: text/html, Size: 2254 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 44398 bytes --]

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

* 回复: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-25  8:44     ` Jeffrey Walton
@ 2021-10-25 13:26       ` Zhu Chunlin
  2021-10-30  3:46         ` Chunlin Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Zhu Chunlin @ 2021-10-25 13:26 UTC (permalink / raw)
  To: musl; +Cc: nullplan


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

Hello Jeff,

Thanks! But when I update the config as you suggest:

AR=/usr/local/bin/llvm-ar \
RANLIB=/usr/local/bin/llvm-ranlib \
CC=/usr/local/bin/clang \
CFLAGS="--rtlib=compiler-rt --target=aarch64" \
ASFLAGS="-Wa,--noexecstack" \
LDFLAGS="-Wl,-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt --target=aarch64" \
LIBCC=-lcompiler_rt \
./configure --target=aarch64 \
&& make

It still reports the error as below:
[cid:919d9698-56e2-49d2-85c5-8b12ac33e65f]

Another question, if I want to use LLVM tool chain instead of GCC, how should I config? Acutally I don't understand why there is gcc error, because I have specify to use clang and ld.lld.

Thanks,
Simon
________________________________
发件人: Jeffrey Walton <noloader@gmail.com>
发送时间: 2021年10月25日 16:44
收件人: musl@lists.openwall.com <musl@lists.openwall.com>
抄送: nullplan@gmx.net <nullplan@gmx.net>
主题: Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler



On Mon, Oct 25, 2021 at 1:04 AM Zhu Chunlin <simon_0214@hotmail.com<mailto:simon_0214@hotmail.com>> wrote:
Hello Markus,

Thanks!

AR=/usr/local/bin/llvm-ar \
RANLIB=/usr/local/bin/llvm-ranlib \
CC=/usr/local/bin/clang \
CFLAGS="-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt --target=aarch64" \
LIBCC=-lcompiler_rt \
./configure --target=aarch64 \
&& make

But when I use the above config, it reports the below error, but I don't understand why there are gcc error, I have explict specify to use clang and ld.lld
[cid:17cb69be492cb971f161]

-fuse-ld=/usr/local/bin/ld.lld is a LDFLAG. Since you are using GCC to drive link, set:

    LDFLAGS = "-Wl,-fuse-ld=/usr/local/bin/ld.lld "
--rtlib=compiler-rt and --target=aarch64may need to go into LDFLAGS, too.

--noexecstack is a ASFLAG. Use:

    ASFLAGS = "-Wa,--noexecstack"

Jeff

[-- Attachment #1.2: Type: text/html, Size: 5461 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 44398 bytes --]

[-- Attachment #3: image.png --]
[-- Type: image/png, Size: 15169 bytes --]

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

* Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-25 13:26       ` 回复: " Zhu Chunlin
@ 2021-10-30  3:46         ` Chunlin Zhu
  2021-10-30  4:25           ` Jeffrey Walton
  0 siblings, 1 reply; 8+ messages in thread
From: Chunlin Zhu @ 2021-10-30  3:46 UTC (permalink / raw)
  To: musl


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

Hello,

On my computer I have built and install the llvm toolchain from the source code by using the below configuration, the llvm lib is installed in the /usr/local/lib folder.
cmake -S llvm -B build -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"

And I am trying to build musl libc 1.2.2 for aarch64 by using llvm/clang, and I use the below configure:
./configure CC=clang --target=aarch64 CFLAGS="-v --target=aarch64 --rtlib=compiler-rt" AR=/usr/local/bin/llvm-ar RANLIB=/usr/local/bin/llvm-ranlib LIBCC=-lcompiler_rt --syslibdir=/usr/local/lib

It report the error as below:
[cid:ef74a00d-14e8-4a0a-b304-d1d3f4cb73f7]

And I find the compile phase is OK, the problem occurs during the link phase, I don't understand why finally gcc is invoked.
[cid:904980bd-5393-439f-b7a6-6735617f6c5b]

By the way, the below configure works on my computer:

./configure CC=clang

make -j4


Best Regards,
Simo
________________________________
发件人: Zhu Chunlin <simon_0214@hotmail.com>
发送时间: 2021年10月25日 21:26
收件人: musl@lists.openwall.com <musl@lists.openwall.com>
抄送: nullplan@gmx.net <nullplan@gmx.net>
主题: 回复: [musl] Failed to build musl 1.2.2 by using clang cross compiler

Hello Jeff,

Thanks! But when I update the config as you suggest:

AR=/usr/local/bin/llvm-ar \
RANLIB=/usr/local/bin/llvm-ranlib \
CC=/usr/local/bin/clang \
CFLAGS="--rtlib=compiler-rt --target=aarch64" \
ASFLAGS="-Wa,--noexecstack" \
LDFLAGS="-Wl,-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt --target=aarch64" \
LIBCC=-lcompiler_rt \
./configure --target=aarch64 \
&& make

It still reports the error as below:
[cid:919d9698-56e2-49d2-85c5-8b12ac33e65f]

Another question, if I want to use LLVM tool chain instead of GCC, how should I config? Acutally I don't understand why there is gcc error, because I have specify to use clang and ld.lld.

Thanks,
Simon
________________________________
发件人: Jeffrey Walton <noloader@gmail.com>
发送时间: 2021年10月25日 16:44
收件人: musl@lists.openwall.com <musl@lists.openwall.com>
抄送: nullplan@gmx.net <nullplan@gmx.net>
主题: Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler



On Mon, Oct 25, 2021 at 1:04 AM Zhu Chunlin <simon_0214@hotmail.com<mailto:simon_0214@hotmail.com>> wrote:
Hello Markus,

Thanks!

AR=/usr/local/bin/llvm-ar \
RANLIB=/usr/local/bin/llvm-ranlib \
CC=/usr/local/bin/clang \
CFLAGS="-fuse-ld=/usr/local/bin/ld.lld --rtlib=compiler-rt --target=aarch64" \
LIBCC=-lcompiler_rt \
./configure --target=aarch64 \
&& make

But when I use the above config, it reports the below error, but I don't understand why there are gcc error, I have explict specify to use clang and ld.lld
[cid:17cb69be492cb971f161]

-fuse-ld=/usr/local/bin/ld.lld is a LDFLAG. Since you are using GCC to drive link, set:

    LDFLAGS = "-Wl,-fuse-ld=/usr/local/bin/ld.lld "
--rtlib=compiler-rt and --target=aarch64may need to go into LDFLAGS, too.

--noexecstack is a ASFLAG. Use:

    ASFLAGS = "-Wa,--noexecstack"

Jeff

[-- Attachment #1.2: Type: text/html, Size: 11345 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 44398 bytes --]

[-- Attachment #3: image.png --]
[-- Type: image/png, Size: 15169 bytes --]

[-- Attachment #4: image.png --]
[-- Type: image/png, Size: 15169 bytes --]

[-- Attachment #5: image.png --]
[-- Type: image/png, Size: 236690 bytes --]

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

* Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-30  3:46         ` Chunlin Zhu
@ 2021-10-30  4:25           ` Jeffrey Walton
  2021-10-30 10:53             ` Chunlin Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Jeffrey Walton @ 2021-10-30  4:25 UTC (permalink / raw)
  To: musl


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

On Fri, Oct 29, 2021 at 11:46 PM Chunlin Zhu <simon_0214@hotmail.com> wrote:

> Hello,
>
> On my computer I have built and install the llvm toolchain from the source
> code by using the below configuration, the llvm lib is installed in the
> /usr/local/lib folder.
> *cmake -S llvm -B build -G "Unix Makefiles"
> -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld"
> -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64" *
>
> And I am trying to build musl libc 1.2.2 for aarch64 by using llvm/clang,
> and I use the below configure:
> *./configure CC=clang --target=aarch64 CFLAGS="-v --target=aarch64
> --rtlib=compiler-rt" AR=/usr/local/bin/llvm-ar
> RANLIB=/usr/local/bin/llvm-ranlib LIBCC=-lcompiler_rt
> --syslibdir=/usr/local/lib*
>
> It report the error as below:
>
>
> And I find the compile phase is OK, the problem occurs during the link
> phase, I don't understand why finally gcc is invoked.
>
>
> By the way, the below configure works on my computer:
>
> ./configure CC=clang
>
> make -j4
>

Set LD to clang, too. It sounds like GCC is creeping in because it is a
default.

For the link error with --noexecstack, the linker needs -z,noexecstack. So
add -Wl,-z,noexecstack to LDFLAGS. See the ld(1) man page at
https://www.man7.org/linux/man-pages/man1/ld.1.html.

ASFLAGS should continue to use --noexecstack.

Jeff

[-- Attachment #1.2: Type: text/html, Size: 5112 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 236690 bytes --]

[-- Attachment #3: image.png --]
[-- Type: image/png, Size: 15169 bytes --]

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

* Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler
  2021-10-30  4:25           ` Jeffrey Walton
@ 2021-10-30 10:53             ` Chunlin Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Chunlin Zhu @ 2021-10-30 10:53 UTC (permalink / raw)
  To: musl


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

Hello,

I made a change to the Makefile of musl 1.2.2 at line 162, just remove the CFLAGS_ALL.
[cid:2dca1e1f-1f39-4eed-bd01-3a2e4eabe70f]
Note: The reason why I remove the CFLAGS_ALL, because I find on my computer when "clang --target=aarch64 -fuse-ld=/usr/local/bin/ld.lld -Wl,....." is used, gcc linker will be invoked, but when  --target=aarch64 is removed, ld.lld will be invoked as expect. Since CFLAGS_ALL contains the option --target=aarch64, so I modify the Makefile.

And use the below configuration:
./configure CC=clang --target=aarch64 CFLAGS="--target=aarch64 --rtlib=compiler-rt" AR=/usr/local/bin/llvm-ar LDFLAGS="-fuse-ld=/usr/local/bin/ld.lld -Wl,-z,noexecstack -m elf64-littleaarch64" RANLIB=/usr/local/bin/llvm-ranlib LIBCC=  --syslibdir=/usr/local/lib

Then ld.lld is invoked but still report the below error, does anyone have encounter the same problem?
[cid:b4dacdde-8d7d-424d-a30a-197c7c38aeaf]

Thanks,
Simon
________________________________
From: Jeffrey Walton <noloader@gmail.com>
Sent: Saturday, October 30, 2021 12:25
To: musl@lists.openwall.com <musl@lists.openwall.com>
Subject: Re: [musl] Failed to build musl 1.2.2 by using clang cross compiler



On Fri, Oct 29, 2021 at 11:46 PM Chunlin Zhu <simon_0214@hotmail.com<mailto:simon_0214@hotmail.com>> wrote:
Hello,

On my computer I have built and install the llvm toolchain from the source code by using the below configuration, the llvm lib is installed in the /usr/local/lib folder.
cmake -S llvm -B build -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"

And I am trying to build musl libc 1.2.2 for aarch64 by using llvm/clang, and I use the below configure:
./configure CC=clang --target=aarch64 CFLAGS="-v --target=aarch64 --rtlib=compiler-rt" AR=/usr/local/bin/llvm-ar RANLIB=/usr/local/bin/llvm-ranlib LIBCC=-lcompiler_rt --syslibdir=/usr/local/lib

It report the error as below:
[cid:ef74a00d-14e8-4a0a-b304-d1d3f4cb73f7]

And I find the compile phase is OK, the problem occurs during the link phase, I don't understand why finally gcc is invoked.
[cid:17ccf705cf7cb971f163]

By the way, the below configure works on my computer:

./configure CC=clang

make -j4

Set LD to clang, too. It sounds like GCC is creeping in because it is a default.

For the link error with --noexecstack, the linker needs -z,noexecstack. So add -Wl,-z,noexecstack to LDFLAGS. See the ld(1) man page at https://www.man7.org/linux/man-pages/man1/ld.1.html.

ASFLAGS should continue to use --noexecstack.

Jeff

[-- Attachment #1.2: Type: text/html, Size: 9291 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 236690 bytes --]

[-- Attachment #3: image.png --]
[-- Type: image/png, Size: 14293 bytes --]

[-- Attachment #4: image.png --]
[-- Type: image/png, Size: 192618 bytes --]

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

end of thread, other threads:[~2021-10-30 10:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24  3:34 [musl] Failed to build musl 1.2.2 by using clang cross compiler Zhu Chunlin
2021-10-24 14:22 ` Markus Wichmann
2021-10-25  5:03   ` 回复: " Zhu Chunlin
2021-10-25  8:44     ` Jeffrey Walton
2021-10-25 13:26       ` 回复: " Zhu Chunlin
2021-10-30  3:46         ` Chunlin Zhu
2021-10-30  4:25           ` Jeffrey Walton
2021-10-30 10:53             ` Chunlin Zhu

Code repositories for project(s) associated with this public 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).