From: Jason Andryuk <jandryuk@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Wei Liu" <wl@xen.org>, "Jason Andryuk" <jandryuk@gmail.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Stefan Bader" <stefan.bader@canonical.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/2] xen/x86: Disable fcf-protection when necessary to build
Date: Mon, 11 May 2020 23:39:47 -0400 [thread overview]
Message-ID: <20200512033948.3507-2-jandryuk@gmail.com> (raw)
In-Reply-To: <20200512033948.3507-1-jandryuk@gmail.com>
Ubuntu gcc-9 enables -fcf-protection by default, which conflicts with
-mindirect-branch=extern and prevents building the hypervisor with
CONFIG_INDIRECT_THUNK:
xmalloc.h:81:1: error: ‘-mindirect-branch’ and ‘-fcf-protection’ are not
compatible
Detect this incompatible combination, and add -fcf-protection=none to
allow the build to succeed. To actually generated the error, the
compiled program must include a function.
CC: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
xen/arch/x86/arch.mk | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index 2a51553edb..3aa6ce521a 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -63,7 +63,16 @@ CFLAGS += -mno-red-zone -fpic -fno-asynchronous-unwind-tables
CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup)
# Compile with thunk-extern, indirect-branch-register if avaiable.
-CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch=thunk-extern
+# Some versions of gcc error: "‘-mindirect-branch’ and ‘-fcf-protection’ are
+# not compatible". For those, we need to disable cf-protection with
+# -fcf-protection=none
+cc-mindirect-branch = $(shell if test -n "`echo 'void foo(void) {};' | \
+ LANG=C $(CC) -mindirect-branch=thunk-extern -S -o /dev/null -x c - 2>&1 | \
+ grep -- '-mindirect-branch.*-fcf-protection.*are not compatible' -`"; \
+ then echo "-mindirect-branch=thunk-extern -fcf-protection=none"; \
+ else echo "-mindirect-branch=thunk-extern"; fi ;)
+
+CFLAGS-$(CONFIG_INDIRECT_THUNK) += $(call cc-mindirect-branch)
CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch-register
CFLAGS-$(CONFIG_INDIRECT_THUNK) += -fno-jump-tables
--
2.25.1
next prev parent reply other threads:[~2020-05-12 3:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 3:39 [PATCH 0/2] Fixups for fcf-protection Jason Andryuk
2020-05-12 3:39 ` Jason Andryuk [this message]
2020-05-12 3:39 ` [PATCH 2/2] x86/boot: Drop .note.gnu.properties in build32.lds Jason Andryuk
2020-05-12 15:32 ` Jan Beulich
2020-05-12 15:58 ` Andrew Cooper
2020-05-12 16:11 ` Jan Beulich
2020-05-12 16:13 ` Andrew Cooper
2020-05-12 16:17 ` Jason Andryuk
2020-05-12 19:10 ` Andrew Cooper
2020-05-12 7:17 ` [PATCH 0/2] Fixups for fcf-protection Stefan Bader
2020-05-12 18:47 ` Andrew Cooper
2020-05-13 5:41 ` Stefan Bader
2020-05-13 9:01 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200512033948.3507-2-jandryuk@gmail.com \
--to=jandryuk@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=stefan.bader@canonical.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.