mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: musl@lists.openwall.com
Cc: Samuel Holland <samuel@sholland.org>
Subject: [GCC PATCH] powerpc64 musl libc support for IEEE binary128 long double
Date: Sun, 30 Jun 2019 14:38:25 -0500	[thread overview]
Message-ID: <20190630193825.65174-2-samuel@sholland.org> (raw)
In-Reply-To: <20190630193825.65174-1-samuel@sholland.org>

---

This works properly with multiarch and -m64/-m32:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/powerpc64-gentoo-linux-musl/8.3.0/lto-wrapper
Target: powerpc64-gentoo-linux-musl
Configured with: /tmp/portage/sys-devel/gcc-8.3.0-r1/work/gcc-8.3.0/configure
--host=powerpc64-gentoo-linux-musl --build=powerpc64-gentoo-linux-musl
--prefix=/usr --enable-languages=c,c++,ada --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --disable-nls --enable-checking=release
--enable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-multilib --disable-altivec
--disable-fixed-point --enable-libgomp --disable-libmudflap --disable-libmpx
--disable-systemtap --disable-vtable-verify --disable-libvtv
--disable-libquadmath --enable-lto --without-isl --disable-libsanitizer
--enable-default-pie --enable-default-ssp --enable-multiarch
--with-linker-hash-style=both --disable-decimal-float --enable-secureplt
--with-abi=elfv2 --with-cpu=power9 --with-long-double-128
--with-long-double-format=ieee
Thread model: posix
gcc version 8.3.0 (Gentoo Hardened 8.3.0-r1 p1.1) 
$ gcc -m64 tests/hello.c -o hello
$ file hello
hello: ELF 64-bit MSB pie executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-powerpc64-ieee128.so.1, not stripped
$ readelf -aW hello | tail -n2
File Attributes
  Tag_GNU_Power_ABI_FP: hard float, 128-bit IEEE long double
$ ./hello 
Hello, world!
$ gcc -m32 tests/hello.c -o hello
$ file hello
hello: ELF 32-bit MSB pie executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-powerpc.so.1, not stripped
$ readelf -aW hello | tail -n2
File Attributes
  Tag_GNU_Power_ABI_FP: hard float, 64-bit long double
$ ./hello 
Hello, world!

---
 gcc/config/rs6000/linux.h   |  3 ++-
 gcc/config/rs6000/linux64.h | 11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index 96b97877989b..439b5179b172 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -139,8 +139,9 @@
 #define POWERPC_LINUX
 
 /* ppc linux has 128-bit long double support in glibc 2.4 and later.  */
+/* musl supports 128-bit long double in 1.1.23 and later on powerpc64 only.  */
 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
-#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
+#define RS6000_DEFAULT_LONG_DOUBLE_SIZE (OPTION_MUSL ? 64 : 128)
 #endif
 
 /* Static stack checking is supported by means of probes.  */
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 5380f6a6a6f1..2b76255f7673 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -447,12 +447,18 @@ extern int dot_symbols;
 ":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
 #endif
 
+#ifdef TARGET_DEFAULT_LONG_DOUBLE_128
+#define MUSL_DYNAMIC_LINKER_FP "%{mlong-double-64:;:-ieee128}"
+#else
+#define MUSL_DYNAMIC_LINKER_FP "%{mlong-double-128:-ieee128}"
+#endif
+
 #undef MUSL_DYNAMIC_LINKER32
 #define MUSL_DYNAMIC_LINKER32 \
   "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
 #undef MUSL_DYNAMIC_LINKER64
 #define MUSL_DYNAMIC_LINKER64 \
-  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP ".so.1"
 
 #undef  DEFAULT_ASM_ENDIAN
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
@@ -628,8 +634,9 @@ extern int dot_symbols;
 #define POWERPC_LINUX
 
 /* ppc{32,64} linux has 128-bit long double support in glibc 2.4 and later.  */
+/* musl supports 128-bit long double in 1.1.23 and later on powerpc64 only.  */
 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
-#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
+#define RS6000_DEFAULT_LONG_DOUBLE_SIZE (OPTION_MUSL && !TARGET_64BIT ? 64 : 128)
 #endif
 
 /* Static stack checking is supported by means of probes.  */
-- 
2.21.0



  reply	other threads:[~2019-06-30 19:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30 19:38 [PATCH] powerpc64: add IEEE binary128 long double support Samuel Holland
2019-06-30 19:38 ` Samuel Holland [this message]
2019-06-30 22:29   ` [GCC PATCH] powerpc64 musl libc support for IEEE binary128 long double Szabolcs Nagy
2019-07-01  0:59     ` Samuel Holland
2019-07-01  7:17       ` Szabolcs Nagy
2019-07-01 17:42   ` Rich Felker
2019-07-02  0:48     ` Samuel Holland
2019-06-30 22:02 ` [PATCH] powerpc64: add IEEE binary128 long double support Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190630193825.65174-2-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).