public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: T P <prog13579@gmail.com>
To: libc-help@sourceware.org
Subject: Failed to build glibc with clang for aarch64
Date: Fri, 29 Apr 2022 12:23:24 +0800	[thread overview]
Message-ID: <CAFEmNk18LN5aUWQo2hQ7OZQXLEigRzqKz-A_w-Q5ieLH8fHD3Q@mail.gmail.com> (raw)

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

             reply	other threads:[~2022-04-29  4:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29  4:23 T P [this message]
2022-04-29 14:24 ` Adhemerval Zanella
2022-04-30 13:58   ` Zhu Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEmNk18LN5aUWQo2hQ7OZQXLEigRzqKz-A_w-Q5ieLH8fHD3Q@mail.gmail.com \
    --to=prog13579@gmail.com \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).