All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: drjones@redhat.com, pbonzini@redhat.com
Subject: [kvm-unit-tests PATCH] arm64: Compile with -mno-outline-atomics for GCC >= 10
Date: Fri, 17 Jul 2020 17:47:27 +0100	[thread overview]
Message-ID: <20200717164727.75580-1-alexandru.elisei@arm.com> (raw)

GCC 10.1.0 introduced the -m{,no-}outline-atomics flags which, according to
man 1 gcc:

"Enable or disable calls to out-of-line helpers to implement atomic
operations.  These helpers will, at runtime, determine if the LSE
instructions from ARMv8.1-A can be used; if not, they will use the
load/store-exclusive instructions that are present in the base ARMv8.0 ISA.
[..] This option is on by default."

Unfortunately the option causes the following error at compile time:

aarch64-linux-gnu-ld -nostdlib -pie -n -o arm/spinlock-test.elf -T /path/to/kvm-unit-tests/arm/flat.lds \
	arm/spinlock-test.o arm/cstart64.o lib/libcflat.a lib/libfdt/libfdt.a /usr/lib/gcc/aarch64-linux-gnu/10.1.0/libgcc.a lib/arm/libeabi.a arm/spinlock-test.aux.o
aarch64-linux-gnu-ld: /usr/lib/gcc/aarch64-linux-gnu/10.1.0/libgcc.a(lse-init.o): in function `init_have_lse_atomics':
lse-init.c:(.text.startup+0xc): undefined reference to `__getauxval'

This is happening because we are linking against our own libcflat which
doesn't implement the function __getauxval().

Disable the use of the out-of-line functions by compiling with
-mno-outline-atomics if we detect a GCC version greater than 10.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---

Tested with gcc versions 10.1.0 and 5.4.0 (cross-compilation), 9.3.0
(native).

I've been able to suss out the reason for the build failure from this
rejected gcc patch [1].

[1] https://patches.openembedded.org/patch/172460/

 arm/Makefile.arm64 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index dfd0c56fe8fb..3223cb966789 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -9,6 +9,12 @@ ldarch = elf64-littleaarch64
 arch_LDFLAGS = -pie -n
 CFLAGS += -mstrict-align
 
+# The -mno-outline-atomics flag is only valid for GCC versions 10 and greater.
+GCC_MAJOR_VERSION=$(shell $(CC) -dumpversion 2> /dev/null | cut -f1 -d.)
+ifeq ($(shell expr "$(GCC_MAJOR_VERSION)" ">=" "10"), 1)
+CFLAGS += -mno-outline-atomics
+endif
+
 define arch_elf_check =
 	$(if $(shell ! $(OBJDUMP) -R $(1) >&/dev/null && echo "nok"),
 		$(error $(shell $(OBJDUMP) -R $(1) 2>&1)))
-- 
2.27.0


WARNING: multiple messages have this Message-ID (diff)
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: pbonzini@redhat.com
Subject: [kvm-unit-tests PATCH] arm64: Compile with -mno-outline-atomics for GCC >= 10
Date: Fri, 17 Jul 2020 17:47:27 +0100	[thread overview]
Message-ID: <20200717164727.75580-1-alexandru.elisei@arm.com> (raw)

GCC 10.1.0 introduced the -m{,no-}outline-atomics flags which, according to
man 1 gcc:

"Enable or disable calls to out-of-line helpers to implement atomic
operations.  These helpers will, at runtime, determine if the LSE
instructions from ARMv8.1-A can be used; if not, they will use the
load/store-exclusive instructions that are present in the base ARMv8.0 ISA.
[..] This option is on by default."

Unfortunately the option causes the following error at compile time:

aarch64-linux-gnu-ld -nostdlib -pie -n -o arm/spinlock-test.elf -T /path/to/kvm-unit-tests/arm/flat.lds \
	arm/spinlock-test.o arm/cstart64.o lib/libcflat.a lib/libfdt/libfdt.a /usr/lib/gcc/aarch64-linux-gnu/10.1.0/libgcc.a lib/arm/libeabi.a arm/spinlock-test.aux.o
aarch64-linux-gnu-ld: /usr/lib/gcc/aarch64-linux-gnu/10.1.0/libgcc.a(lse-init.o): in function `init_have_lse_atomics':
lse-init.c:(.text.startup+0xc): undefined reference to `__getauxval'

This is happening because we are linking against our own libcflat which
doesn't implement the function __getauxval().

Disable the use of the out-of-line functions by compiling with
-mno-outline-atomics if we detect a GCC version greater than 10.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---

Tested with gcc versions 10.1.0 and 5.4.0 (cross-compilation), 9.3.0
(native).

I've been able to suss out the reason for the build failure from this
rejected gcc patch [1].

[1] https://patches.openembedded.org/patch/172460/

 arm/Makefile.arm64 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index dfd0c56fe8fb..3223cb966789 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -9,6 +9,12 @@ ldarch = elf64-littleaarch64
 arch_LDFLAGS = -pie -n
 CFLAGS += -mstrict-align
 
+# The -mno-outline-atomics flag is only valid for GCC versions 10 and greater.
+GCC_MAJOR_VERSION=$(shell $(CC) -dumpversion 2> /dev/null | cut -f1 -d.)
+ifeq ($(shell expr "$(GCC_MAJOR_VERSION)" ">=" "10"), 1)
+CFLAGS += -mno-outline-atomics
+endif
+
 define arch_elf_check =
 	$(if $(shell ! $(OBJDUMP) -R $(1) >&/dev/null && echo "nok"),
 		$(error $(shell $(OBJDUMP) -R $(1) 2>&1)))
-- 
2.27.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

             reply	other threads:[~2020-07-17 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 16:47 Alexandru Elisei [this message]
2020-07-17 16:47 ` [kvm-unit-tests PATCH] arm64: Compile with -mno-outline-atomics for GCC >= 10 Alexandru Elisei
2020-07-18  9:11 ` Andrew Jones
2020-07-18  9:11   ` Andrew Jones
2020-07-18 13:50   ` Alexandru Elisei
2020-07-18 13:50     ` Alexandru Elisei
2020-07-27 12:21     ` Alexandru Elisei
2020-07-27 12:21       ` Alexandru Elisei
2020-07-27 12:30       ` Andrew Jones
2020-07-27 12:30         ` Andrew Jones
2020-07-27 12:39         ` Alexandru Elisei
2020-07-27 12:39           ` Alexandru Elisei
2020-07-27 17:25         ` Paolo Bonzini
2020-07-27 17:25           ` Paolo Bonzini

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=20200717164727.75580-1-alexandru.elisei@arm.com \
    --to=alexandru.elisei@arm.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=pbonzini@redhat.com \
    /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.