Return-Path: Received: from youngberry.canonical.com ([91.189.89.112]:33635 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbfGQQH1 (ORCPT ); Wed, 17 Jul 2019 12:07:27 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hnmRp-0001kQ-Ax for linux-kbuild@vger.kernel.org; Wed, 17 Jul 2019 16:06:29 +0000 Received: by mail-io1-f69.google.com with SMTP id f22so27555385ioh.22 for ; Wed, 17 Jul 2019 09:06:29 -0700 (PDT) From: Seth Forshee Subject: [PATCH v2] kbuild: add -fcf-protection=none when using retpoline flags Date: Wed, 17 Jul 2019 11:06:26 -0500 Message-Id: <20190717160626.26293-1-seth.forshee@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Masahiro Yamada , Michal Marek Cc: Josh Poimboeuf , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org 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 --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 3e4868a6498b..73a94d1db2b6 100644 --- a/Makefile +++ b/Makefile @@ -878,6 +878,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 +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) -- 2.20.1