mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Failed to invoke ld.lld by using clang -fuse-ld=/usr/local/bin/ld.lld
@ 2021-11-28  3:38 Simon Z
  0 siblings, 0 replies; only message in thread
From: Simon Z @ 2021-11-28  3:38 UTC (permalink / raw)
  To: musl

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

Hello,

I am trying to cross compile musl 1.2.2 by using the following configure:
./configure CC="clang --target=aarch64" --target=aarch64 CFLAGS="--rtlib=compiler-rt" AR=/usr/local/bin/llvm-ar LDFLAGS="-fuse-ld=/usr/local/bin/ld.lld" RANLIB=/usr/local/bin/llvm-ranlib --syslibdir=/usr/local/lib LIBCC=-L/usr/local/lib/clang/13.0.0/lib/linux

The linking phase failed, it reported the below error:
gcc: error: unrecognized command-line option ‘--noexecstack’
clang-13: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:162: lib/libc.so] Error 1
make: *** Waiting for unfinished jobs....

Finally, I find the reason is on my computer clang -fuse-ld=/usr/local/bin/ld.lld can't force clang to use ld.lld, while it still will invoke gcc ld, below is my testing:
simon@LAPTOP-JH2M71LG:~/workspace/musl-1.2.2$ clang -fuse-ld=/usr/local/bin/ld.lld -v -nostdlib -shared -Wl,-e,_dlstart
-o lib/libc.so obj/src/aio/aio.lo
clang version 13.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
 "/usr/local/bin/ld.lld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -shared -o lib/libc.so -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/usr/local/bin/../lib -L/lib -L/usr/lib -e _dlstart obj/src/aio/aio.lo
ld.lld: error: obj/src/aio/aio.lo is incompatible with elf_x86_64
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

Then I modified the Makefile (line 162 and 163) from:
lib/libc.so: $(LOBJS) $(LDSO_OBJS)
    $(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -nostdlib -shared \
        -Wl,-e,_dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC)
to
lib/libc.so: $(LOBJS) $(LDSO_OBJS)
    /usr/local/bin/ld.lld -nostdlib -shared \
    -e _dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC)

It works now! I am using clang 13.0.0. Is it the problem caused by my computer setting? And I also have a question why $(CFLAGS_ALL) is needed to build libc.so? Thanks!

Best Regards,
Simon

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-28  3:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28  3:38 [musl] Failed to invoke ld.lld by using clang -fuse-ld=/usr/local/bin/ld.lld Simon Z

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