<div dir="ltr">Hi Jeenu,<div><br></div><div>Your command line looks fairly correct. Clang falls back to the system linker when it fails to find a cross linker. A couple of things:</div><div><br></div><div>1. In the sysroot that Linaro package, "libc" is a subdirectory of "aarch64-linux-gnu". It looks like this is not the case for you - can I confirm that "<span style="line-height:1.5">/path/to/aarch64/gcc" contains the directory "aarch64-linux-gnu"?</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">2. clang-3.4 is very old to be working on AArch64. It was the first release that contained AArch64 as a target and while we did our best to make it conformant, it was still fairly beta. clang-3.5 was the best release for AArch64 - it contained the backend merge and a bunch of work on its conformance. I'd recommend upgrading to clang-3.7, but at least to clang-3.5.</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">James</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 6 Nov 2015 at 09:53 Jeenu Viswambharan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to use clang++ as drop-in replacement for G++ in a project.<br>
I'm compiling for AArch64. When linking, clang seems to invoke the<br>
native (x86) /usr/bin/ld instead of the one from AArch64 GCC suite. The<br>
clang link command line looks like:<br>
<br>
clang++ -target aarch64-linux-gnu -v \<br>
  -gcc-toolchain /path/to/aarch64/gcc \   # Root of my AArch64 tool chain<br>
  --sysroot=/path/to/aarch64/gcc/libc \   # From aarch64-linux-gnu-g++<br>
-print-sysroot<br>
  <some other options> <obj files><br>
<br>
And from the verbose output, I get:<br>
<br>
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)<br>
Target: aarch64--linux-gnu<br>
Thread model: posix<br>
Found candidate GCC installation:<br>
/path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3<br>
Selected GCC installation: /path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3<br>
 "/usr/bin/ld" --sysroot=/path/to/aarch64/gcc/aarch64-linux-gnu/libc ...<br>
<br>
I don't get why clang got around choosing the native linker. The link<br>
fails for obvious reasons that object files are AArch64 ELF.<br>
<br>
The inferred target looks suspicious; so I changed it to just aarch64.<br>
Even then, clang ends up invoking native linker.<br>
<br>
Please advise.<br>
<br>
PS: Please note that all these are from a legacy script that I'm<br>
working on. I'm a rather novice clang user, and probably don't yet<br>
know what I'm doing!<br>
<br>
--<br>
Jeenu<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>