public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Failed to build glibc with clang for aarch64
@ 2022-04-29  4:23 T P
  2022-04-29 14:24 ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: T P @ 2022-04-29  4:23 UTC (permalink / raw)
  To: libc-help

Hello Adhemerval and all,

I checkout your branch azanella/clang and use the below commit (
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=c8b0172687a7b862fdd5229d95c513b9d0b64dcb),
I build glibc with clang for x86 successfully, that's great. Then I try to
build it for aarch64 using the below config:
../configure CC="clang --target=aarch64" CXX="clang++ --target=aarch64"
--target=aarch64 --host=aarch64-linux-gnu --disable-werror --prefix=/usr

The below error is reported:

*make[2]: Entering directory '/home/glibc/glibc/csu'*
*clang --target=aarch64 -nostdlib -nostartfiles -r -o
/home/glibc/glibc/build/csu/crt1.o /home/glibc/glibc/build/csu/start.o
/home/glibc/glibc/build/csu/abi-note.o /home/glibc/glibc/build/csu/init.o
/home/glibc/glibc/build/csu/static-reloc.o*
*ld: error: /home/glibc/glibc/build/csu/start.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/abi-note.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/init.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/static-reloc.o is incompatible with
elf_x86_64*
*collect2: error: ld returned 1 exit status*
*clang-13: error: linker (via gcc) command failed with exit code 1 (use -v
to see invocation)*
*make[2]: *** [Makefile:134: /home/glibc/glibc/build/csu/crt1.o] Error 1*
*make[2]: Leaving directory '/home/glibc/glibc/csu'*
*make[1]: *** [Makefile:483: csu/subdir_lib] Error 2*
*make[1]: Leaving directory '/home/glibc/glibc'*
*make: *** [Makefile:9: all] Error 2*

Then I run the above command manually by use -v, it reports as below:
*clang version 13.0.0*
*Target: aarch64*
*Thread model: posix*
*InstalledDir: /usr/local/bin*
* "/usr/bin/gcc" -nostdlib -nostartfiles -o
/home/glibc/glibc/build/csu/crt1.o -r /home/glibc/glibc/build/csu/start.o
/home/glibc/glibc/build/csu/abi-note.o /home/glibc/glibc/build/csu/init.o
/home/glibc/glibc/build/csu/static-reloc.o*
*ld: error: /home/glibc/glibc/build/csu/start.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/abi-note.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/init.o is incompatible with
elf_x86_64*
*ld: error: /home/glibc/glibc/build/csu/static-reloc.o is incompatible with
elf_x86_64*
*collect2: error: ld returned 1 exit status*
*clang-13: error: linker (via gcc) command failed with exit code 1 (use -v
to see invocation)*

I think it's an issue on my computer that clang will not invoke ld.lld
correctly, it always run "/usr/bin/gcc" which I still can't fix. Then I try
this command by manually invoking the ld.lld directly but it still reports
error:
*root@6ab3fca322b6:/home/glibc/glibc/build# ld.lld -nostdlib -nostartfiles
-o /home/glibc/glibc/build/csu/crt1.o -r
/home/glibc/glibc/build/csu/start.o /home/glibc/glibc/build/csu/abi-note.o
/home/glibc/glibc/build/csu/init.o
/home/glibc/glibc/build/csu/static-reloc.o*
*ld.lld: error: unknown argument '-nostartfiles'*

I think the issue is the flag'-nostartfiles', then I remove it and try the
below command it works:
*root@6ab3fca322b6:/home/glibc/glibc/build# ld.lld -nostdlib -o
/home/glibc/glibc/build/csu/crt1.o -r /home/glibc/glibc/build/csu/start.o
/home/glibc/glibc/b*
*uild/csu/abi-note.o /home/glibc/glibc/build/csu/init.o
/home/glibc/glibc/build/csu/static-reloc.o*
*root@6ab3fca322b6:/home/glibc/glibc/build#*

My questions are as below:
1. Is the below command correct to build the branch with clang for aarch64:
../configure CC="clang --target=aarch64" CXX="clang++ --target=aarch64"
--target=aarch64 --host=aarch64-linux-gnu --disable-werror --prefix=/usr

2. Why clang failed to invoke ld.lld? I am using clang and ld.lld 13.0.0
and I build the llvm from source code.

3. Why the flag '-nostartfiles' is not supported by ld.lld? I find the
webpage "
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-nostartfiles“
show that this flag is supported by clang?

Thanks!

Best Regards,
Simon

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

end of thread, other threads:[~2022-04-30 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29  4:23 Failed to build glibc with clang for aarch64 T P
2022-04-29 14:24 ` Adhemerval Zanella
2022-04-30 13:58   ` Zhu Simon

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