From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B61AE3857C56 for ; Thu, 19 Nov 2020 23:43:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B61AE3857C56 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AJNVVgn136979; Thu, 19 Nov 2020 18:43:18 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 34x26t8mk4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Nov 2020 18:43:18 -0500 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0AJNYkdK150782; Thu, 19 Nov 2020 18:43:17 -0500 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 34x26t8mk0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Nov 2020 18:43:17 -0500 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AJNguqK001850; Thu, 19 Nov 2020 23:43:17 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01wdc.us.ibm.com with ESMTP id 34uyn1rwwf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Nov 2020 23:43:17 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AJNhFem10420918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Nov 2020 23:43:15 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A4B87805F; Thu, 19 Nov 2020 23:43:15 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC8547805E; Thu, 19 Nov 2020 23:43:04 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.65.203.26]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS; Thu, 19 Nov 2020 23:43:04 +0000 (GMT) Date: Thu, 19 Nov 2020 18:43:02 -0500 From: Michael Meissner To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner Subject: [PATCH] PowerPC: PR libgcc/97543, fix 64-bit long double issues Message-ID: <20201119234302.GA30873@ibm-toto.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-19_14:2020-11-19, 2020-11-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011190158 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 23:43:20 -0000 PowerPC: PR libgcc/97543, fix 64-bit long double issues I meant to post this to the gcc-patches mailing list last Thursday, but I see I posted this to an internal IBM mailing list. This patch replaces the previous iterations of this patch: October 22nd, 2020: Message-ID: <20201022220510.GA11556@ibm-toto.the-meissners.org> October 28th, 2020: Message-ID: <20201029004204.GA15149@ibm-toto.the-meissners.org If you use a compiler with long double defaulting to 64-bit instead of 128-bit with IBM extended double, you get linker warnings about mis-matches in the gnu attributes for long double (PR libgcc/97543). Even if the compiler is configured to have long double be 64 bit as the default with the configuration option '--without-long-double-128' you get the warnings. You also get the same issues if you use a compiler with long double defaulting to IEEE 128-bit instead of IBM extended double (PR libgcc/97643). The issue is the way libgcc.a/libgcc.so is built. Right now when building libgcc under Linux, the long double size is set to 128-bits when building libgcc. However, the gnu attributes are set, leading to the warnings. One feature of the current GNU attribute implementation is if you have a shared library (such as libgcc_s.so), the GNU attributes for the shared library is an inclusive OR of all of the modules within the library. This means if any module uses the -mlong-double-128 option and uses long double, the GNU attributes for the library will indicate that it uses 128-bit IBM long doubles. If you have a static library, you will get the warning only if you actually reference a module with the attribute set. This patch does two things: 1) All of the modules that support IBM 128-bit long doubles explicitly set the ABI to IBM extended double. 2) I turned off GNU attributes for building the shared library or for building the IBM 128-bit long double support. I have discussed this patch with Alan Modra, and made several changes based on his suggestions. I have tested this on a little endian power9 system running Linux by building three separate compilers, using the Advance Toolchain AT14.0 which uses GLIBC 2.32: 1) A compiler where the long double default is IBM 128-bit double; 2) A compiler where the long double default is IEEE 128-bit double; (and) 3) A compiler where the long double default is 64-bit. Note, for the IEEE build (#2), the other patches that I will be submitting are needed to enable the full build. For each of the 3 compilers, I then tested some code with long double's and verified that each of the long double options worked without generating warnings. In addition, I have tested this patch on a big endian power8 system running Linux, and there were no regressions. Can I install this patch into the master branch? Since this is a bug for 64-bit long doubles, I would like to back port it to GCC 10, and GCC 9 after a shake-in period. libgcc/ 2020-11-17 Michael Meissner PR libgcc/97543 PR libgcc/97643 * config/rs6000/t-linux (IBM128_STATIC_OBJS): New make variable. (IBM128_SHARED_OBJS): New make variable. (IBM128_OBJS): New make variable. Set all objects to use the explicit IBM format, and disable gnu attributes. (IBM128_CFLAGS): New make variable. (gcc_s_compile): Add -mno-gnu-attribute to all shared library modules. --- libgcc/config/rs6000/t-linux | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux index ed821947b66..72e9c2770a6 100644 --- a/libgcc/config/rs6000/t-linux +++ b/libgcc/config/rs6000/t-linux @@ -6,3 +6,25 @@ HOST_LIBGCC2_CFLAGS += -mlong-double-128 # smaller and faster libgcc code. Directly specifying -mcmodel=small # would need to take into account targets for which -mcmodel is invalid. HOST_LIBGCC2_CFLAGS += -mno-minimal-toc + +# On the modules that deal with IBM 128-bit values, make sure that TFmode uses +# the IBM extended double format. Also turn off gnu attributes on the static +# modules. +IBM128_STATIC_OBJS = ibm-ldouble$(objext) _powitf2$(objext) \ + ppc64-fp$(objext) _divtc3$(object) _multc3$(object) \ + _fixtfdi$(object) _fixunstfdi$(object) \ + _floatditf$(objext) _floatunsditf$(objext) +IBM128_SHARED_OBJS = $(IBM128_STATIC_OBJS:$(objext):_s$(objext)) +IBM128_OBJS = $(IBM128_STATIC_OBJS) $(IBM128_SHARED_OBJS) + +IBM128_CFLAGS = -Wno-psabi -mabi=ibmlongdouble -mno-gnu-attribute + +$(IBM128_OBJS) : INTERNAL_CFLAGS += $(IBM128_CFLAGS) + +# Turn off gnu attributes for long double size on all of the shared library +# modules, but leave it on for the static modules, except for the functions +# that explicitly process IBM 128-bit floating point. Shared libraries only +# have one gnu attribute for the whole library, and it can lead to warnings if +# somebody changes the long double format. We leave it on for the static +# modules to catch mis-compilation errors. +gcc_s_compile += -mno-gnu-attribute -- 2.22.0 -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meissner@linux.ibm.com, phone: +1 (978) 899-4797