[PATCH 1/1][SRU][D] UBUNTU: SAUCE: kbuild: add -fcf-protection=none when using retpoline flags

Seth Forshee seth.forshee at canonical.com
Mon Sep 16 13:41:56 UTC 2019

BugLink: https://bugs.launchpad.net/bugs/1843291

The gcc -fcf-protection=branch option is not compatible with
-mindirect-branch=thunk-extern. The latter is used when
CONFIG_RETPOLINE is selected, and this will fail to build with
a gcc which has -fcf-protection=branch enabled by default. Adding
-fcf-protection=none when building with retpoline enabled
prevents such build failures.

Signed-off-by: Seth Forshee <seth.forshee at canonical.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
(cherry picked from commit 29be86d7f9cb18df4123f309ac7857570513e8bc)
Signed-off-by: Seth Forshee <seth.forshee at canonical.com>
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index 4c249a80dd17..d1e762787f5c 100644
--- a/Makefile
+++ b/Makefile
@@ -885,6 +885,12 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 # change __FILE__ to the relative path from the srctree
 KBUILD_CFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+# ensure -fcf-protection is disabled when using retpoline as it is
+# incompatible with -mindirect-branch=thunk-extern
+KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)

More information about the kernel-team mailing list