[Sync] Enable libquadmath on kunpeng

This commit is contained in:
huang-xiaoquan 2023-07-14 18:10:33 +08:00
parent 577a463f57
commit 199eae7853
3 changed files with 251 additions and 1 deletions

View File

@ -0,0 +1,45 @@
From 37ef787e743d98f9f6e53005d99709fb8e284964 Mon Sep 17 00:00:00 2001
From: eastb233 <xiezhiheng@huawei.com>
Date: Fri, 14 Jul 2023 11:07:05 +0800
Subject: [PATCH 1/2] [CONFIG] Regenerate configure file
Regenerate configure file under libquadmath directory
since it is out of date.
---
libquadmath/configure | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libquadmath/configure b/libquadmath/configure
index b3ee64f9c..603f2f131 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -10806,7 +10806,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10819 "configure"
+#line 10809 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10912,7 +10912,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10925 "configure"
+#line 10915 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13031,7 +13031,7 @@ case "$host" in
case "$enable_cet" in
auto)
# Check if target supports multi-byte NOPs
- # and if assembler supports CET insn.
+ # and if compiler and assembler support CET insn.
cet_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fcf-protection"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--
2.33.0

View File

@ -0,0 +1,197 @@
From 52a810b4d8a725a7edb2988f6c3813a9938362a5 Mon Sep 17 00:00:00 2001
From: eastb233 <xiezhiheng@huawei.com>
Date: Fri, 14 Jul 2023 11:10:24 +0800
Subject: [PATCH 2/2] [libquadmath] Enable libquadmath on kunpeng
This enable libquadmath on kunpeng platform to convenient
users that migrating from x86 platform. libquadmath uses "__float128"
as quad precision floating point type and with math functions with "q"
suffix like "cosq". For those who do not need to adapt to x86 platform,
you can use "long double" as quad precision floating point type and math
functions with "l" suffix like "cosl" in libm for quad precision math.
---
libquadmath/Makefile.am | 4 ++++
libquadmath/Makefile.in | 3 ++-
libquadmath/configure | 28 ++++++++++++++++++++++++++--
libquadmath/configure.ac | 7 +++++++
libquadmath/quadmath.h | 13 +++++++++++--
5 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/libquadmath/Makefile.am b/libquadmath/Makefile.am
index 35dffb46f..bf0398d9c 100644
--- a/libquadmath/Makefile.am
+++ b/libquadmath/Makefile.am
@@ -2,6 +2,10 @@
AUTOMAKE_OPTIONS = foreign info-in-builddir
+if ARCH_AARCH64
+DEFS += -D__float128="long double"
+endif
+
## Skip over everything if the quadlib is not available:
if BUILD_LIBQUADMATH
ACLOCAL_AMFLAGS = -I .. -I ../config
diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in
index 8c0112122..449cc8a06 100644
--- a/libquadmath/Makefile.in
+++ b/libquadmath/Makefile.in
@@ -90,6 +90,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
+@ARCH_AARCH64_TRUE@am__append_1 = -D__float128="long double"
@BUILD_LIBQUADMATH_FALSE@libquadmath_la_DEPENDENCIES =
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -337,7 +338,7 @@ CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
+DEFS = @DEFS@ $(am__append_1)
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
diff --git a/libquadmath/configure b/libquadmath/configure
index 603f2f131..13a9088fb 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -633,6 +633,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
get_gcc_base_ver
+ARCH_AARCH64_FALSE
+ARCH_AARCH64_TRUE
GENINSRC_FALSE
GENINSRC_TRUE
XCFLAGS
@@ -10806,7 +10808,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10809 "configure"
+#line 10811 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10912,7 +10914,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10915 "configure"
+#line 10917 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12705,6 +12707,11 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+ #if defined(__aarch64__)
+ typedef long double __float128;
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
+ #endif
+
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
typedef _Complex float __attribute__((mode(TC))) __complex128;
#else
@@ -12756,6 +12763,11 @@ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+ #if defined(__aarch64__)
+ typedef long double __float128;
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
+ #endif
+
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
typedef _Complex float __attribute__((mode(TC))) __complex128;
#else
@@ -13242,6 +13254,14 @@ else
GENINSRC_FALSE=
fi
+ if expr "$target_cpu" : "aarch64.*" > /dev/null; then
+ ARCH_AARCH64_TRUE=
+ ARCH_AARCH64_FALSE='#'
+else
+ ARCH_AARCH64_TRUE='#'
+ ARCH_AARCH64_FALSE=
+fi
+
# Determine what GCC version number to use in filesystem paths.
@@ -13425,6 +13445,10 @@ if test -z "${GENINSRC_TRUE}" && test -z "${GENINSRC_FALSE}"; then
as_fn_error $? "conditional \"GENINSRC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${ARCH_AARCH64_TRUE}" && test -z "${ARCH_AARCH64_FALSE}"; then
+ as_fn_error $? "conditional \"ARCH_AARCH64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac
index eec4084a4..507c247d6 100644
--- a/libquadmath/configure.ac
+++ b/libquadmath/configure.ac
@@ -218,6 +218,11 @@ AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128],
[GCC_TRY_COMPILE_OR_LINK([
+ #if defined(__aarch64__)
+ typedef long double __float128;
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
+ #endif
+
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
typedef _Complex float __attribute__((mode(TC))) __complex128;
#else
@@ -393,6 +398,8 @@ AS_HELP_STRING([--enable-generated-files-in-srcdir],
[enable_generated_files_in_srcdir=no])
AC_MSG_RESULT($enable_generated_files_in_srcdir)
AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
+AM_CONDITIONAL(ARCH_AARCH64,
+ [expr "$target_cpu" : "aarch64.*" > /dev/null])
# Determine what GCC version number to use in filesystem paths.
GCC_BASE_VER
diff --git a/libquadmath/quadmath.h b/libquadmath/quadmath.h
index 81eb957d2..bb1b49df6 100644
--- a/libquadmath/quadmath.h
+++ b/libquadmath/quadmath.h
@@ -27,6 +27,12 @@ Boston, MA 02110-1301, USA. */
extern "C" {
#endif
+#if defined(__aarch64__)
+#ifndef __float128
+typedef long double __float128;
+#endif
+#endif
+
/* Define the complex type corresponding to __float128
("_Complex __float128" is not allowed) */
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
@@ -160,10 +166,13 @@ extern int quadmath_snprintf (char *str, size_t size,
#define FLT128_MAX_10_EXP 4932
-#define HUGE_VALQ __builtin_huge_valq()
+#if defined(__aarch64__)
/* The following alternative is valid, but brings the warning:
(floating constant exceeds range of __float128) */
-/* #define HUGE_VALQ (__extension__ 0x1.0p32767Q) */
+# define HUGE_VALQ (__extension__ 0x1.0p32767Q)
+#else
+# define HUGE_VALQ __builtin_huge_valq()
+#endif
#define M_Eq 2.718281828459045235360287471352662498Q /* e */
#define M_LOG2Eq 1.442695040888963407359924681001892137Q /* log_2 e */
--
2.33.0

View File

@ -2,7 +2,7 @@
%global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 2
%global gcc_release 3
%global _unpackaged_files_terminate_build 0
%global _performance_build 1
@ -137,6 +137,8 @@ Provides: bundled(libffi)
Provides: gcc(major) = %{gcc_major}
Patch0: 0000-Version-Set-version-to-12.3.1.patch
Patch1: 0001-CONFIG-Regenerate-configure-file.patch
Patch2: 0002-libquadmath-Enable-libquadmath-on-kunpeng.patch
# On ARM EABI systems, we do want -gnueabi to be part of the
# target triple.
@ -605,6 +607,8 @@ not stable, so plugins must be rebuilt any time GCC is updated.
%setup -q -n gcc-12.3.0
%patch0 -p1
%patch1 -p1
%patch2 -p1
echo '%{_vendor} %{version}-%{release}' > gcc/DEV-PHASE
@ -2708,6 +2712,10 @@ end
%doc rpm.doc/changelogs/libcc1/ChangeLog*
%changelog
* Fri Jul 14 2023 huangxiaoquan <huangxiaoquan1@huawei.com> 12.3.1-3
- Type:Sync
- DESC:Enable libquadmath on kunpeng
* Tue Jul 11 2023 huangxiaoquan <huangxiaoquan1@huawei.com> 12.3.1-2
- Type:SPEC
- DESC:Set version to 12.3.1