diff mbox series

[2/2,SRU,B] UBUNTU: SAUCE: kbuild: add -fcf-protection=none when using retpoline flags

Message ID 20190916134157.32219-3-seth.forshee@canonical.com
State New
Headers show
Series kbuild: add -fcf-protection=none when using retpoline flags | expand

Commit Message

Seth Forshee Sept. 16, 2019, 1:41 p.m. UTC
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@canonical.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
(cherry picked from commit 29be86d7f9cb18df4123f309ac7857570513e8bc)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index c78f3d71a905..1fe5d2a2cfd9 100644
--- a/Makefile
+++ b/Makefile
@@ -869,6 +869,12 @@  KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 # Require designated initializers for all marked structures
 KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
+# ensure -fcf-protection is disabled when using retpoline as it is
+# incompatible with -mindirect-branch=thunk-extern
+ifdef CONFIG_RETPOLINE
+KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
+endif
+
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)