[Driver] allow Android triples to alias for non Android targets
authorNick Desaulniers <ndesaulniers@google.com>
Mon, 22 Oct 2018 19:48:08 +0000 (19:48 +0000)
committerNick Desaulniers <ndesaulniers@google.com>
Mon, 22 Oct 2018 19:48:08 +0000 (19:48 +0000)
commit11dadac247e677de124328077d080fe086f14d47
tree8a317314070618c6b8ee40ce7aa8e491a1cd6fdf
parent552b62ed1f24dfbed4b5ee733415572ead5b228e
[Driver] allow Android triples to alias for non Android targets

Summary:
Partial revert of r330873 ('[Driver] Reland "Android triples are not
aliases for other triples."')

While we don't want `-target *-linux-android` to alias to non
*-linux-android libs and binaries, it turns out we do want the
opposite. Ie. We would like for `-target *-linux-gnu` to still be
able to use *-android libs and binaries.

In fact, this is used to cross assemble and link the Linux kernel for
Android devices.

`-target *-linux-gnu` needs to be used for the Linux kernel when
using the android binutils prebuilts (*-linux-android).

The use of `-target *-linux-android` on C source files will cause
Clang to perform optimizations based on the presence of bionic (due to
r265481 ('Faster stack-protector for Android/AArch64.')) which is
invalid within the Linux kernel and will produce a non-bootable kernel
image.

Of course, you could just use the standard binutils (*-linux-gnu),
but Android does not distribute these.  So this patch fixes a problem
that only occurs when cross assembling and linking a Linux kernel with
the Android provided binutils, which is what is done within Android's
build system.

Reviewers: srhines, pirama, danalbert

Reviewed By: srhines, danalbert

Subscribers: javed.absar, kristof.beyls, cfe-commits

Differential Revision: https://reviews.llvm.org/D53463

llvm-svn: 344941
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/android-gcc-toolchain.c [new file with mode: 0644]