This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCHv2] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler


Changes since v1:
 - Completely rewrite of the patch to set ENABLE_FLOAT128 at libstdc++
   build time and undef _GLIBCXX_USE_FLOAT128 when building user code.

--- 8< ---

In order to use __float128 in C++ it's necessary to check if the
compiler enabled its support too when building user code.
This patch changes the behavior at libstdc++ build by setting
ENABLE_FLOAT128, which is used to set the value of the exported macro
_GLIBCXX_USE_FLOAT128.

2018-03-12  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	PR libstdc++/84654
	* acinclude.m4: Set ENABLE_FLOAT128 instead of _GLIBCXX_USE_FLOAT128.
	* config.h.in: Remove references to _GLIBCXX_USE_FLOAT128.
	* configure: Regenerate.
	* include/Makefile.am: Replace the value of _GLIBCXX_USE_FLOAT128
	based on ENABLE_FLOAT128.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config: Define _GLIBCXX_USE_FLOAT128.
	[!defined(__FLOAT128__) && !defined(__SIZEOF_FLOAT128__)]: Undefine
	_GLIBCXX_USE_FLOAT128.
---
 libstdc++-v3/acinclude.m4           |  5 ++---
 libstdc++-v3/config.h.in            |  3 ---
 libstdc++-v3/include/Makefile.am    | 13 ++++++++++++-
 libstdc++-v3/include/bits/c++config |  6 ++++++
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 3bd669a..4f37b6a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3062,7 +3062,7 @@ dnl Note: also checks that the types aren't standard types.
 dnl
 dnl Defines:
 dnl  _GLIBCXX_USE_INT128
-dnl  _GLIBCXX_USE_FLOAT128
+dnl  ENABLE_FLOAT128
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_INT128_FLOAT128], [
 
@@ -3117,13 +3117,12 @@ EOF
 
     AC_MSG_CHECKING([for __float128])
     if AC_TRY_EVAL(ac_compile); then
-      AC_DEFINE(_GLIBCXX_USE_FLOAT128, 1,
-      [Define if __float128 is supported on this host.])
       enable_float128=yes
     else
       enable_float128=no
     fi
     AC_MSG_RESULT($enable_float128)
+    GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, test $enable_float128 = yes)
     rm -f conftest*
 
   AC_LANG_RESTORE
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 5a0f067..765cedc 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -918,9 +918,6 @@
 /* Define if fchmodat is available in <sys/stat.h>. */
 #undef _GLIBCXX_USE_FCHMODAT
 
-/* Define if __float128 is supported on this host. */
-#undef _GLIBCXX_USE_FLOAT128
-
 /* Defined if gettimeofday is available. */
 #undef _GLIBCXX_USE_GETTIMEOFDAY
 
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 70a662f..ba5adda 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1230,6 +1230,14 @@ stamp-allocator-new:
 	echo 0 > stamp-allocator-new
 endif
 
+if ENABLE_FLOAT128
+stamp-float128:
+	echo 1 > stamp-float128
+else
+stamp-float128:
+	echo 0 > stamp-float128
+endif
+
 # NB: The non-empty default ldbl_compat works around an AIX sed
 # oddity, see libstdc++/31957 for details.
 ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
@@ -1241,7 +1249,8 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
 			      stamp-extern-template \
 			      stamp-dual-abi \
 			      stamp-cxx11-abi \
-			      stamp-allocator-new
+			      stamp-allocator-new \
+			      stamp-float128
 	@date=`cat ${toplevel_srcdir}/gcc/DATESTAMP` ;\
 	release=`sed 's/^\([0-9]*\).*$$/\1/' ${toplevel_srcdir}/gcc/BASE-VER` ;\
 	ns_version=`cat stamp-namespace-version` ;\
@@ -1250,6 +1259,7 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
 	dualabi=`cat stamp-dual-abi` ;\
 	cxx11abi=`cat stamp-cxx11-abi` ;\
 	allocatornew=`cat stamp-allocator-new` ;\
+	float128=`cat stamp-float128` ;\
 	ldbl_compat='s,g,g,' ;\
 	grep "^[	 ]*#[	 ]*define[	 ][	 ]*_GLIBCXX_LONG_DOUBLE_COMPAT[	 ][	 ]*1[	 ]*$$" \
 	${CONFIG_HEADER} > /dev/null 2>&1 \
@@ -1262,6 +1272,7 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
 	-e "s,define _GLIBCXX_USE_DUAL_ABI, define _GLIBCXX_USE_DUAL_ABI $$dualabi," \
 	-e "s,define _GLIBCXX_USE_CXX11_ABI, define _GLIBCXX_USE_CXX11_ABI $$cxx11abi," \
 	-e "s,define _GLIBCXX_USE_ALLOCATOR_NEW, define _GLIBCXX_USE_ALLOCATOR_NEW $$allocatornew," \
+	-e "s,define _GLIBCXX_USE_FLOAT128, define _GLIBCXX_USE_FLOAT128 $$float128," \
 	-e "$$ldbl_compat" \
 	    < ${glibcxx_srcdir}/include/bits/c++config > $@ ;\
 	sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 1eb4679..e345241 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -609,4 +609,10 @@ namespace std
 # endif
 #endif
 
+/* Define if __float128 is supported on this host. */
+#define _GLIBCXX_USE_FLOAT128
+#if !defined(__FLOAT128__) && !defined(__SIZEOF_FLOAT128__)
+#undef _GLIBCXX_USE_FLOAT128
+#endif
+
 // End of prewritten config; the settings discovered at configure time follow.
-- 
2.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]