llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.71k stars 11.88k forks source link

Extra archive suffix is generated for ARM baremetal builtins. #33926

Open 7f1138a3-b229-4707-9203-bbc9684dbd73 opened 7 years ago

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 7 years ago
Bugzilla Link 34578
Version 6.0
OS other
CC @eblot

Extended Description

main.c: int main(void) {return 0;}

$ clang-5.0 -target arm-non-eabi main.c /usr/local/clang50/bin/ld.lld: error: unable to find library -lc /usr/local/clang50/bin/ld.lld: error: unable to find library -lm /usr/local/clang50/bin/ld.lld: error: unable to find library -lclang_rt.builtins-arm.a clang-5.0: error: ld.lld command failed with exit code 1 (use -v to see invocation)

Clang generates "-lclang_rt.builtins-arm.a" rather than "-lclang_rt.builtins-arm", which makes ld.lld to search for "libclang_rt.builtins-arm.a.a" rather than "libclang_rt.builtins-arm.a"

BTW, is there an option switch to disable standard libraries but keep linking with builtins?

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 5 years ago

It seems it has been fixed with LLVM 9.0

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 6 years ago

I think you're right, this issue does not belong to LLD.

llvmbot commented 6 years ago

Does not seem LLD behavior is incorrect. I think it matches -l option description. I think clang should either generate "-l:libclang_rt.builtins-arm.a" or "-lclang_rt.builtins-arm", but not "-lclang_rt.builtins-arm.a".

(https://linux.die.net/man/1/ld): "Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a.

On systems which support shared libraries, ld may also search for files other than libnamespec.a. Specifically, on ELF and SunOS systems, ld will search a directory for a library called libnamespec.so before searching for one called libnamespec.a. (By convention, a ".so" extension indicates a shared library.) Note that this behavior does not apply to :filename, which always specifies a file called filename."

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 6 years ago

Oops, this one is likely to belong to lld, not cfe

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 7 years ago

(sorry, typo: s/arm-non-eabi/arm-none-eabi/)

7f1138a3-b229-4707-9203-bbc9684dbd73 commented 7 years ago

(sorry, typo: s/arm-non-eabi/arm-none-abi/)