--- /dev/null
+From 41f1c48420709470c51ee0e54b6fb28b956bb4e0 Mon Sep 17 00:00:00 2001
+From: Alistair Strachan <astrachan@google.com>
+Date: Thu, 9 Aug 2018 09:40:42 -0700
+Subject: efi/libstub: arm: support building with clang
+
+From: Alistair Strachan <astrachan@google.com>
+
+commit 41f1c48420709470c51ee0e54b6fb28b956bb4e0 upstream.
+
+When building with CONFIG_EFI and CONFIG_EFI_STUB on ARM, the libstub
+Makefile would use -mno-single-pic-base without checking it was
+supported by the compiler. As the ARM (32-bit) clang backend does not
+support this flag, the build would fail.
+
+This changes the Makefile to check the compiler's support for
+-mno-single-pic-base before using it, similar to c1c386681bd7 ("ARM:
+8767/1: add support for building ARM kernel with clang").
+
+Signed-off-by: Alistair Strachan <astrachan@google.com>
+Reviewed-by: Stefan Agner <stefan@agner.ch>
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/firmware/efi/libstub/Makefile | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/firmware/efi/libstub/Makefile
++++ b/drivers/firmware/efi/libstub/Makefile
+@@ -16,7 +16,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__K
+ cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie \
+ $(DISABLE_STACKLEAK_PLUGIN)
+ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
+- -fno-builtin -fpic -mno-single-pic-base
++ -fno-builtin -fpic \
++ $(call cc-option,-mno-single-pic-base)
+
+ cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
+