This is an archive of the discontinued LLVM Phabricator instance.

Warn about unsupported ibmlongdouble
ClosedPublic

Authored by tuliom on Dec 6 2022, 11:43 AM.

Details

Reviewers
qiucf
Group Reviewers
Restricted Project
Commits
rG5f68c4111ab9: Warn about unsupported ibmlongdouble
Summary

When -mabi=ieeelongdouble is enabled by default, libc++ does not support
-mabi=ibmlongdouble.

Diff Detail

Event Timeline

tuliom created this revision.Dec 6 2022, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 11:43 AM
Herald added a subscriber: kbarton. · View Herald Transcript
tuliom requested review of this revision.Dec 6 2022, 11:43 AM
nikic added a reviewer: Restricted Project.Dec 6 2022, 10:29 PM
nikic added a subscriber: nikic.

Can you please upload the patch with full context (-U99999)?

The assumption here is that libc++ is being compiled with a compiler that has the same ieeelongdouble default as the clang that is being built, right? I guess that's the most reasonable assumption one can make.

MaskRay added inline comments.Dec 6 2022, 10:46 PM
clang/lib/Driver/ToolChains/PPCLinux.h
30

New functions should use camelCase

tuliom updated this revision to Diff 480858.Dec 7 2022, 4:54 AM

I'm attaching a new version of the patch.

Can you please upload the patch with full context (-U99999)?

@nikic Done!

The assumption here is that libc++ is being compiled with a compiler that has the same ieeelongdouble default as the clang that is being built, right?

@nikic Right.

New functions should use camelCase

@MaskRay Fixed.

nikic added inline comments.Dec 8 2022, 6:34 AM
clang/lib/Driver/ToolChains/PPCLinux.cpp
75

I don't think this formatting is right. You may find clang/tools/clang-format/clang-format-diff.py helpful.

I use this script locally:

#!/bin/sh
git diff -U ${1:-HEAD} | clang/tools/clang-format/clang-format-diff.py -p1

And then do something like ./clang_format_diff.sh | patch -p0 after checking that it did not reformat too much.

clang/test/Driver/lit.local.cfg
25

I believe this isn't robust, because ON is not the only possible value. Instead, you'll want to canonicalize the variable: https://github.com/llvm/llvm-project/blob/03e6d9d9d1d48e43f3efc35eb75369b90d4510d5/clang/test/CMakeLists.txt#L4

qiucf added a comment.Dec 8 2022, 7:32 AM

Thanks for the patch! But does libc++ support to be built with -mabi=ieeelongdouble now? (like libstdc++, if it works correctly, it should co-exist and be linked with different long double ABIs)

clang/lib/Driver/ToolChains/PPCLinux.cpp
96

SupportIEEEFloat128 checks the library version:

  • If using libstdc++, then libstdc++ (GCC) >= 12.1.0 is okay.
  • If using libc++, then sorry, no libc++ supports -mabi=ieeelongdouble now.
  • Glibc should >= 2.32

If the assumptions are still right, this changes its meaning (and supportIBMLongDouble has different meaning from it).

clang/test/Driver/lit.local.cfg
26

Can we assume if we are compiling with -mabi=ieeelongdouble, then libc++ 'must' be built with the same long double ABI? If I understand correctly, they're unrelated.

tuliom added a comment.Dec 8 2022, 8:25 AM

Thanks for the patch! But does libc++ support to be built with -mabi=ieeelongdouble now?

@qiucf libc++ can be built with -mabi=ieeelongdouble, but it supports only a single long double format, i.e. if it's built with -mabi=ieeelongdouble, it won't support IBM double-double and vice versa.
This is already being used in Fedora Rawhide at the moment.

tuliom updated this revision to Diff 481730.Dec 9 2022, 1:29 PM

Fix the issues pointed by @nikic.

tuliom marked 3 inline comments as done.Dec 9 2022, 1:53 PM
tuliom added inline comments.
clang/lib/Driver/ToolChains/PPCLinux.cpp
75

Thanks, this pointed out 2 errors.

96

@qiucf In operating systems that switched to IEEE long double by default, all libraries (and programs) are built with IEEE long double, including libc++.

clang/test/Driver/lit.local.cfg
25

Changed. This caused a few other modifications in the latest revision.

26

@qiucf I didn't understand this part. Are you suggesting to remove the long double warnings because the way the compiler was built is unrelated to the way libc++ was built?

tuliom marked 2 inline comments as done.Dec 9 2022, 2:00 PM
qiucf added inline comments.Dec 12 2022, 6:30 PM
clang/test/Driver/lit.local.cfg
26

Ah, I misunderstood meaning of 'defaults to IEEE long double' in last review. We can assume 'how the compiler was built' is the same as 'how the libc++ was built'.

But when 'how the libc++ was built' conflicts with 'how the compiler compiles current program', we expect a warning, right? If so, this looks reasonable.

tuliom marked 2 inline comments as done.Dec 13 2022, 5:46 AM
tuliom added inline comments.
clang/test/Driver/lit.local.cfg
26

Yes, exactly.
Thanks!

qiucf accepted this revision as: qiucf.Dec 13 2022, 7:53 AM
This revision is now accepted and ready to land.Dec 13 2022, 7:53 AM
tuliom marked an inline comment as done.Dec 13 2022, 8:30 AM

Thanks @qiucf ! I don't have commit access yet. Could you land this patch for me, please?
Please use “Tulio Magno Quites Machado Filho tuliom@redhat.com” to commit the change.

This revision was automatically updated to reflect the committed changes.
qiucf added a comment.Dec 13 2022, 7:18 PM

Committed as https://github.com/llvm/llvm-project/commit/5f68c4111ab9c79b902723df3986dd1033813c01

ppc-float-abi-warning.cpp would fail when testing on machine with glibc older than 2.32 but PPC_LINUX_DEFAULT_IEEELONGDOUBLE enabled, which is known failure even before this patch.