From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH] host-utils: Avoid using __builtin_subcll on buggy versions of Apple Clang
Date: Thu, 22 Jun 2023 15:50:23 +0200 [thread overview]
Message-ID: <1e159a47-ec06-8369-ab2b-b88150200fd7@linaro.org> (raw)
In-Reply-To: <20230622130823.1631719-1-peter.maydell@linaro.org>
On 6/22/23 15:08, Peter Maydell wrote:
> We use __builtin_subcll() to do a 64-bit subtract with borrow-in and
> borrow-out when the host compiler supports it. Unfortunately some
> versions of Apple Clang have a bug in their implementation of this
> intrinsic which means it returns the wrong value. The effect is that
> a QEMU built with the affected compiler will hang when emulating x86
> float80 division.
>
> The upstream LLVM issue is:
> https://github.com/llvm/llvm-project/issues/55253
>
> The commit that introduced the bug apparently never made it into an
> upstream LLVM release without the subsequent fix
> https://github.com/llvm/llvm-project/commit/fffb6e6afdbaba563189c1f715058ed401fbc88d
> but unfortunately it did make it into Apple Clang 14.0, as shipped
> in Xcode 14.3 (14.2 is reported to be OK). The Apple bug number is
> FB12210478.
>
> Add ifdefs to avoid use of __builtin_subcll() on Apple Clang version
> 14 or greater. There is not currently a version of Apple Clang which
> has the bug fix -- when one appears we should be able to add an upper
> bound to the ifdef condition so we can start using the builtin again.
> We make the lower bound a conservative "any Apple clang with major
> version 14 or greater" because the consequences of incorrectly
> disabling the builtin when it would work are pretty small and the
> consequences of not disabling it when we should are pretty bad.
>
> Many thanks to those users who both reported this bug and also
> did a lot of work in identifying the root cause; in particular
> to Daniel Bertalan and osy.
>
> Cc:qemu-stable@nongnu.org
> Resolves:https://gitlab.com/qemu-project/qemu/-/issues/1631
> Resolves:https://gitlab.com/qemu-project/qemu/-/issues/1659
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> I don't have a setup to test this, so this needs testing by the
> people who've encountered this compiler bug to confirm it does
> the right thing...
> ---
> include/qemu/compiler.h | 13 +++++++++++++
> include/qemu/host-utils.h | 2 +-
> 2 files changed, 14 insertions(+), 1 deletion(-)
Ouch.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2023-06-22 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 13:08 [PATCH] host-utils: Avoid using __builtin_subcll on buggy versions of Apple Clang Peter Maydell
2023-06-22 13:50 ` Richard Henderson [this message]
2023-06-22 14:34 ` Daniel P. Berrangé
2023-06-22 14:38 ` Peter Maydell
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=1e159a47-ec06-8369-ab2b-b88150200fd7@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).