This is an archive of the discontinued LLVM Phabricator instance.

Support __float128 on NetBSD libstdc++ x86/x86_64
Changes PlannedPublic

Authored by krytarowski on Jun 7 2017, 4:54 PM.

Details

Reviewers
joerg
rnk
mgorny
Summary

This adds support for __float128 from GNU libstdc++ with Clang on NetBSD x86/x86_64 targets.

This corrects compilation at least of CMake and probably others like Firefox.

In file included from /tmp/pkgsrc-tmp/devel/cmake/work/cmake-3.8.2/Source/kwsys/Directory.cxx:4:
In file included from /tmp/pkgsrc-tmp/devel/cmake/work/cmake-3.8.2/Source/cmsys/Directory.hxx:8:
In file included from /usr/include/g++/string:40:
In file included from /usr/include/g++/bits/char_traits.h:39:
In file included from /usr/include/g++/bits/stl_algobase.h:64:
In file included from /usr/include/g++/bits/stl_pair.h:59:
In file included from /usr/include/g++/bits/move.h:57:
/usr/include/g++/type_traits:311:39: error: __float128 is not supported on this target

struct __is_floating_point_helper<__float128>
                                  ^

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Jun 7 2017, 4:54 PM
joerg edited edge metadata.Jun 8 2017, 4:55 AM

At the very least, missing test case.

I'm mostly ambivalent about this -- I don't really see the point and without matching soft float support it won't fully work either.

Softfloat on the NetBSD of Clang/LLVM part?

joerg added a comment.Jun 8 2017, 5:54 AM

Soft-float on the runtime environment part. I.e. non-trivial operations are lowered to library calls.

Is this sufficient as a test:

$NetBSD$

--- test/Sema/128bitfloat.cpp.orig	2017-05-29 10:06:54.000000000 +0000
+++ test/Sema/128bitfloat.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i386--netbsd -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64--netbsd -verify -std=c++11 %s
 
 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
 __float128 f;
``

As I said, I don't see the point in pretending we support float128 when the runtime doesn't contain the necessary pieces.

As I said, I don't see the point in pretending we support float128 when the runtime doesn't contain the necessary pieces.

On the other hand cmake and other packages break now. What's the alternative?

We can patch libstdc++ to conditionally enable float128 on NetBSD, this works too. All other systems I'm aware of including cygwin moved to this->HasFloat128 = true;.

We can change NetBSD base libstdc++ in /usr/include/g++/bits/*/c++config.h from

/* Define if __float128 is supported on this host. */
#define _GLIBCXX_USE_FLOAT128 1

to:

#if !defined(__clang__)
/* Define if __float128 is supported on this host. */
#define _GLIBCXX_USE_FLOAT128 1
#endif
rnk edited edge metadata.Jun 26 2017, 6:11 PM

I think there's something wrong with clang's implementation of float128. It seems fundamentally incompatible with libstdc++'s is_floating_point_helper mechanism. We can definitely take this patch to unblock things, but we should file a bug about investigating this all the way. This popped up in mingw, I forget elsewhere, and it's wasting peoples' time.

Joerg declines to take this patch as it is, as there is no compiler-rt support for float128 on i386 in compiler-rt. GCC knows float128 on i386, amd64, i64, hppa, powerpc [some variations]; currently I focus on i386/amd64.

My proposal was to check if there is used libstdc++, and conditionally enable __float128 for i386/amd64?

krytarowski planned changes to this revision.Oct 25 2017, 3:31 PM

Rescheduled for future. Maybe I will need to check and improve how good is this i386 __float128 support.

krytarowski requested review of this revision.Nov 4 2018, 6:53 PM

This change happened to be required in downstream usage.. knowing its limits can we merge it as it is?

joerg added a comment.Nov 5 2018, 4:44 AM

Nothing changed. I don't see how catering to the broken libstdc++ self-configuration helps. So no, I still object to this change.

krytarowski planned changes to this revision.Nov 5 2018, 5:57 AM

OK.