FROMLIST: kbuild: disable Android-specific compiler features

The Android compilers enable some non-standard features by default. While
most Android build systems inject the needed "-mno-android" option via
KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS
gains KCFLAGS after running (and failing) many cc-option tests. (For
example, the stack-protector tests happen after arch-specific
KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As
such, we should notice this option and immediately turn it on as the
first cc-option test we run.

Signed-off-by: Kees Cook <keescook@chromium.org>

Bug: 27039414
Patchset: android compiler

(git am from https://patchwork.kernel.org/patch/8240831/)
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: Idc0c80ddef90bb02ce6255055f30b05864ff4cfd
diff --git a/Makefile b/Makefile
index cf35f6b..591fd02 100644
--- a/Makefile
+++ b/Makefile
@@ -403,6 +403,10 @@
 		   -Wno-format-security \
 		   -std=gnu89
 
+# We must turn off the Android-specific compiler options as early as possible
+# otherwise cc-option calls below may erroneously fail.
+KBUILD_CFLAGS	+= $(call cc-option,-mno-android,)
+
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS   := -D__ASSEMBLY__