<div dir="ltr"><div><div><div><div><div><div>Hi,<br><br></div>I stopped into IRC to ask about a problem I've been having using Clang in conjunction with LLD to compile and link for an embedded project on Cortex-M ARM processor.<br><br></div>First, I am able to separately compile with a call to clang and link with a call to lld, but I cannot use clang to link using lld using the -fuse-ld=lld flag. I have the output from `clang -v -fuse-ld=lld -target arm-none-eabi main.c -o main` here [1], where calling `clang -target arm-none-eabi -c main.c -o main.o` and `ld.lld main.o -o main` work fine. Doing the compiling and linking for my host computer works just fine using -fuse-ld=lld, and I verified that it is using LLD by checking the .comments section in the generated elf.<br><br></div>Second, combining LTO with specifying any specific arm architecture seems to break linking with LLD. That is, I compile the object files with LTO (either -flto or -flto=thin) and, in addition to specifying `-target arm-none-eabi`, I specify an architecture specific flag (such as -march=armv7e-m, -mcpu=cortex-m4, or -mthumb, or instead I use -target armv7em-none-eabi), then while calling lld to link I get an error like:<br>ld.lld: error: main.o: could not infer e_machine from bitcode target triple thumbv7em-none--eabi<br>LLD 4.0.0<br></div><br></div>I am working on Linux and these two problems seem to exist on both 4.0rc2 and the current head.<br><br>I am really happy with the progress LLVM has made, with the upcoming 4.0 release, I have managed to compile and link programs for my embedded projects without any of the gcc arm toolchain! There are still some shortcomings with the linker scripts compared to ld that make those a bit trickier to work with, even with the added MEMORY section parsing in the current head. Other than the above, the only other bother I've hit is having to re-link with `--oformat binary` to get raw binary output, since there I haven't found an objcopy equivalent in llvm. I can add feature requests for these missing features, as well as the bug reports for the above two issues, on the bugzilla if that is appropriate.<br><br></div><div>Thanks for the help,<br></div><div><br></div>Sean<br><div><div><div><div><div><br>[1] <a href="https://gist.github.com/flacjacket/35d92ea619af96352d5ac06844f2f1b5">https://gist.github.com/flacjacket/35d92ea619af96352d5ac06844f2f1b5</a><br></div></div></div></div></div></div>