In toolchains with proper support for IEEE float128, we can switch default long double semantics to it, unless explicitly specified with options.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/ToolChains/PPCLinux.cpp | ||
---|---|---|
76 | What if we have -mabi=elfv2 in command line? |
Can we just update bool IEEELongDouble = false; to bool IEEELongDouble = T.isOSLinux(); in clang/lib/Driver/ToolChains/Clang.cpp?
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?
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?
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".
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)?
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.
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.
What if we have -mabi=elfv2 in command line?