This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Use IEEE long double in proper toolchain
AbandonedPublic

Authored by qiucf on Jan 12 2022, 8:01 PM.

Details

Reviewers
nemanjai
shchenz
jsji
Group Reviewers
Restricted Project
Summary

In toolchains with proper support for IEEE float128, we can switch default long double semantics to it, unless explicitly specified with options.

Diff Detail

Event Timeline

qiucf created this revision.Jan 12 2022, 8:01 PM
qiucf requested review of this revision.Jan 12 2022, 8:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2022, 8:01 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jsji accepted this revision as: jsji.Jan 20 2022, 1:20 PM

LGTM. Thanks for working on this!

This revision is now accepted and ready to land.Jan 20 2022, 1:20 PM
jsji added inline comments.Jan 20 2022, 5:23 PM
clang/lib/Driver/ToolChains/PPCLinux.cpp
76

What if we have -mabi=elfv2 in command line?

jsji added a comment.EditedJan 20 2022, 5:28 PM

Can we just update bool IEEELongDouble = false; to bool IEEELongDouble = T.isOSLinux(); in clang/lib/Driver/ToolChains/Clang.cpp?

jsji requested changes to this revision.Jan 20 2022, 5:28 PM
This revision now requires changes to proceed.Jan 20 2022, 5:28 PM

I don't think this is the right approach. Personally, I would find it surprising if simply having GCC 12.1 on the system changes my long double default. Imagine if I simply install and use such a toolchain on a machine for whatever reason. If the default for such a toolchain is not IEEE, then the clang default diverges from the GCC toolchain default.

Would there be a way to query the GCC toolchain for what the default is for long double?

jsji added a comment.EditedJan 21 2022, 7:46 AM

Would there be a way to query the GCC toolchain for what the default is for long double?

There would certainly be ways to query. But I don't think we should change the default *BASED* on the gcc toolchain installed.

As you mentioned, I would find it surprising if simply having GCC 12.1 on the system changes my long double default. Imagine if I simply install and use such a toolchain on a machine for whatever reason

So, the proposal is we change the default on Linux, so we will not change the default based on the gcc version, it is based on OS and clang version only.
but will emit warning if we detect that the GCC toolchain is too old.

Can we just update bool IEEELongDouble = false;  to bool IEEELongDouble = T.isOSLinux(); in clang/lib/Driver/ToolChains/Clang.cpp?

So, the proposal is we change the default on Linux, so we will not change the default based on the gcc version, it is based on OS and clang version only.
but will emit warning if we detect that the GCC toolchain is too old.

Can we just update bool IEEELongDouble = false;  to bool IEEELongDouble = T.isOSLinux(); in clang/lib/Driver/ToolChains/Clang.cpp?

Won't that end up producing a warning on ALL code built on any Linux distro with a GCC toolchain older than 12.1? That would be terrible.
Ultimately, what we care about is checking for the default for the distro toolchain. I am not sure what a good proxy for that is, but I don't think it is "all Linux distros".

jsji added a comment.Jan 21 2022, 12:40 PM

Won't that end up producing a warning on ALL code built on any Linux distro with a GCC toolchain older than 12.1? That would be terrible.

Good point. Yes, so should be something like:

IsDistroWithNewToolchain = ( Distro.IsRedhat() && Distro >= Distro::RHEL9  ||  (Distro.IsUbuntu() && Distro >= Distro::xxx)
bool IEEELongDouble = T.isOSLinux() && IsDistroWithNewToolchain;
qiucf added a comment.Jan 24 2022, 2:31 AM

Won't that end up producing a warning on ALL code built on any Linux distro with a GCC toolchain older than 12.1? That would be terrible.

Good point. Yes, so should be something like:

IsDistroWithNewToolchain = ( Distro.IsRedhat() && Distro >= Distro::RHEL9  ||  (Distro.IsUbuntu() && Distro >= Distro::xxx)
bool IEEELongDouble = T.isOSLinux() && IsDistroWithNewToolchain;

Thanks for reminding about checking Linux distro version! Besides, would it be acceptable that we add a variable to cmake to determine default long double semantics (like current GCC)?

jsji added a comment.Jan 24 2022, 7:04 AM

Besides, would it be acceptable that we add a variable to cmake to determine default long double semantics (like current GCC)?

Yes, we can. But I think that can be in another patch, and we shouldn't rely on it -- as we shouldn't assume user will config/build clang/llvm on the target machine.

jsji resigned from this revision.Jun 2 2022, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 7:59 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
qiucf abandoned this revision.Sep 19 2023, 12:28 AM

Determining float ABI by system library without explicit options may cause confusion. Since Fedora has successfully switched using ieeelongdouble on ppc64le (https://developers.redhat.com/articles/2023/05/16/benefits-fedora-38-long-double-transition-ppc64le ), this patch is not so relevant.