Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 30 Jun 2019 14:38:25 -0500
From: Samuel Holland <samuel@...lland.org>
To: musl@...ts.openwall.com
Cc: Samuel Holland <samuel@...lland.org>
Subject: [GCC PATCH] powerpc64 musl libc support for IEEE binary128 long double

---

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.