From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, thuth@redhat.com
Subject: [PATCH kvm-unit-tests] arm64: Fix compiling with ancient compiler
Date: Tue, 1 Feb 2022 20:01:16 +0100 [thread overview]
Message-ID: <20220201190116.182415-1-drjones@redhat.com> (raw)
When compiling with an ancient compiler (gcc-4.8.5-36.el7_6.2.aarch64)
the build fails with
lib/libcflat.a(alloc.o): In function `mult_overflow':
/home/drjones/kvm-unit-tests/lib/alloc.c:19: undefined reference to `__multi3'
According to kernel commit fb8722735f50 ("arm64: support __int128 on
gcc 5+") GCC5+ will not emit __multi3 for __int128 multiplication,
so let's just fallback to the non-__int128 overflow check when we
use gcc versions older than 5.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/alloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/alloc.c b/lib/alloc.c
index f4266f5d064e..70228aa32c6c 100644
--- a/lib/alloc.c
+++ b/lib/alloc.c
@@ -1,6 +1,7 @@
#include "alloc.h"
#include "asm/page.h"
#include "bitops.h"
+#include <linux/compiler.h>
void *malloc(size_t size)
{
@@ -13,7 +14,7 @@ static bool mult_overflow(size_t a, size_t b)
/* 32 bit system, easy case: just use u64 */
return (u64)a * (u64)b >= (1ULL << 32);
#else
-#ifdef __SIZEOF_INT128__
+#if defined(__SIZEOF_INT128__) && (!defined(__aarch64__) || GCC_VERSION >= 50000)
/* if __int128 is available use it (like the u64 case above) */
unsigned __int128 res = a;
res *= b;
--
2.34.1
next reply other threads:[~2022-02-01 19:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 19:01 Andrew Jones [this message]
2022-02-02 5:19 ` [PATCH kvm-unit-tests] arm64: Fix compiling with ancient compiler Thomas Huth
2022-02-02 8:06 ` Andrew Jones
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=20220201190116.182415-1-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=thuth@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.