[cfe-dev] clang++ as drop-in g++ replacement

James Molloy via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 6 02:03:52 PST 2015


Hi Jeenu,

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:

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 "/path/to/aarch64/gcc" contains the directory
"aarch64-linux-gnu"?

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.

James

On Fri, 6 Nov 2015 at 09:53 Jeenu Viswambharan via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I'm trying to use clang++ as drop-in replacement for G++ in a project.
> I'm compiling for AArch64. When linking, clang seems to invoke the
> native (x86) /usr/bin/ld instead of the one from AArch64 GCC suite. The
> clang link command line looks like:
>
> clang++ -target aarch64-linux-gnu -v \
>   -gcc-toolchain /path/to/aarch64/gcc \   # Root of my AArch64 tool chain
>   --sysroot=/path/to/aarch64/gcc/libc \   # From aarch64-linux-gnu-g++
> -print-sysroot
>   <some other options> <obj files>
>
> And from the verbose output, I get:
>
> Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM
> 3.4)
> Target: aarch64--linux-gnu
> Thread model: posix
> Found candidate GCC installation:
> /path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3
> Selected GCC installation:
> /path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3
>  "/usr/bin/ld" --sysroot=/path/to/aarch64/gcc/aarch64-linux-gnu/libc ...
>
> I don't get why clang got around choosing the native linker. The link
> fails for obvious reasons that object files are AArch64 ELF.
>
> The inferred target looks suspicious; so I changed it to just aarch64.
> Even then, clang ends up invoking native linker.
>
> Please advise.
>
> PS: Please note that all these are from a legacy script that I'm
> working on. I'm a rather novice clang user, and probably don't yet
> know what I'm doing!
>
> --
> Jeenu
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151106/1935d166/attachment.html>


More information about the cfe-dev mailing list