From patchwork Tue Jan 29 10:52:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 1032669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494896-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="atyRXbOL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjyN6wvqz9sNJ for ; Tue, 29 Jan 2019 21:52:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=Sd0/Q0VcB0tvH434WnOdYvUxa4DvAikkT2hHURMEAtogCl4i30 MN22NAsKgAjf6wS1Gp4OFAxXns7vmuVbYnzGt9LKiuh1yQdMi0966tieOohgrWCo PS08tpS74PxLVOdDow8dAutlmvrSd4lrQ/YvOdf0xy/Hcq+Z7vXwWynA8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=p1YfV0lHEZHdqgptYohQrgrgVTM=; b=atyRXbOLpMhNEXXmBoJ2 yUJSzeZTEBXG312/WOrLYutb3SKDW3+rUiaeNqLBpsZwm4nJZOcTvWcifDZDRVz4 tPd/kK5tEytZSYqTIQl2OQ3HZauFs43KiSMzhNiw+dcExbEtOqb9pvnXOiSJgKHX mO3a+e8DmHLq+/NQdWd4URU= Received: (qmail 87482 invoked by alias); 29 Jan 2019 10:52:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87465 invoked by uid 89); 29 Jan 2019 10:52:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT autolearn=ham version=3.3.2 spammy= X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Jan 2019 10:52:49 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id EB2984C1; Tue, 29 Jan 2019 11:52:45 +0100 (CET) Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5d4GIRnGAQEn; Tue, 29 Jan 2019 11:52:42 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p4FDDB9E7.dip0.t-ipconnect.de [79.221.185.231]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id A7A2C4BF; Tue, 29 Jan 2019 11:52:41 +0100 (CET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [libphobos] Work around lack of dlpi_tls_modid before Solaris 11.5 Date: Tue, 29 Jan 2019 11:52:40 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Before Solaris 11.5, struct dl_phdr_info lacked the dlpi_tls_modid member. While the support might be backported to Solaris 11.4, it certainly won't to previous Solaris releases. To work around this, I've used the following patch. Again, it's pretty straightforward. Point of note: * On Solaris, FreeBSD and NetBSD, dl_phdr_info is always visible in , while on Linux one needs to define _GNU_SOURCE. AC_USE_SYSTEM_EXTENSION takes care of this, but needs to be called early (i.e. not in DRUNTIME_OS_DLPI_TLS_MODID) to avoid an autoconf warning: configure.ac:129: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS m4/druntime/os.m4:190: DRUNTIME_OS_DLPI_TLS_MODID is expanded from... configure.ac:129: the top level Tested on i386-pc-solaris2.11 (Solaris 11.4) and x86_64-pc-linux-gnu. Not unexpectedly, there are a couple of regressions compared to the Solaris 11.5/x86 results: +FAIL: gdc.test/runnable/testaa.d execution test +FAIL: gdc.test/runnable/testaa.d -fPIC execution test +FAIL: gdc.test/runnable/testaa.d -fPIC -shared-libphobos execution test +FAIL: gdc.test/runnable/testaa.d -shared-libphobos execution test 32 and 64-bit +FAIL: gdc.test/runnable/xtest55.d execution test +FAIL: gdc.test/runnable/xtest55.d -shared-libphobos execution test 64-bit only +FAIL: libphobos.shared/link_linkdep.d -I/vol/gcc/src/hg/trunk/local/libphobos/t estsuite/libphobos.shared liblinkdep.so lib.so -shared-libphobos execution test +FAIL: libphobos.shared/load_linkdep.d -shared-libphobos -ldl execution test +FAIL: libphobos.shared/load_loaddep.d -shared-libphobos -ldl execution test +FAIL: libphobos.shared/linkDR.c -shared-libphobos -ldl -pthread execution test +FAIL: libphobos.shared/host.c -ldl -pthread execution test +FAIL: libphobos.shared/loadDR.c -ldl -pthread -g execution test 32 and 64-bit +FAIL: libphobos.shared/link.d -I/vol/gcc/src/hg/trunk/local/libphobos/testsuite/libphobos.shared lib.so -shared-libphobos execution test 64-bit only I haven't looked much closer yet, just posting this to see if anything along those lines could be acceptable at all. Rainer # HG changeset patch # Parent 517609f2fc6f40a6cbf15addd7f1006864256064 Work around lack of dlpi_tls_modid before Solaris 11.5 diff --git a/libphobos/configure.ac b/libphobos/configure.ac --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -32,6 +32,7 @@ AC_CONFIG_HEADERS(config.h) AM_ENABLE_MULTILIB(, ..) AC_CANONICAL_SYSTEM +AC_USE_SYSTEM_EXTENSIONS target_alias=${target_alias-$target} AC_SUBST(target_alias) @@ -126,6 +127,7 @@ DRUNTIME_OS_SOURCES DRUNTIME_OS_THREAD_MODEL DRUNTIME_OS_ARM_EABI_UNWINDER DRUNTIME_OS_MINFO_BRACKETING +DRUNTIME_OS_DLPI_TLS_MODID DRUNTIME_OS_LINK_SPEC WITH_LOCAL_DRUNTIME([ diff --git a/libphobos/libdruntime/gcc/config.d.in b/libphobos/libdruntime/gcc/config.d.in --- a/libphobos/libdruntime/gcc/config.d.in +++ b/libphobos/libdruntime/gcc/config.d.in @@ -38,6 +38,9 @@ enum ThreadModel GNU_Thread_Model = Thre // Whether the linker provides __start_minfo and __stop_minfo symbols enum Minfo_Bracketing = @DCFG_MINFO_BRACKETING@; +// Whether struct dl_phdr_info has dlpi_tls_modid member. +enum OS_Have_Dlpi_Tls_Modid = @DCFG_DLPI_TLS_MODID@; + // Whether target has support for builtin atomics. enum GNU_Have_Atomics = @DCFG_HAVE_ATOMIC_BUILTINS@; diff --git a/libphobos/libdruntime/rt/sections_elf_shared.d b/libphobos/libdruntime/rt/sections_elf_shared.d --- a/libphobos/libdruntime/rt/sections_elf_shared.d +++ b/libphobos/libdruntime/rt/sections_elf_shared.d @@ -751,8 +751,16 @@ void scanSegments(in ref dl_phdr_info in case PT_TLS: // TLS segment assert(!pdso._tlsSize); // is unique per DSO - pdso._tlsMod = info.dlpi_tls_modid; - pdso._tlsSize = phdr.p_memsz; + static if (OS_Have_Dlpi_Tls_Modid) + { + pdso._tlsMod = info.dlpi_tls_modid; + pdso._tlsSize = phdr.p_memsz; + } + else + { + pdso._tlsMod = 0; + pdso._tlsSize = 0; + } break; default: diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4 --- a/libphobos/m4/druntime/os.m4 +++ b/libphobos/m4/druntime/os.m4 @@ -183,6 +183,20 @@ AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING], AC_LANG_POP([C]) ]) +# DRUNTIME_OS_DLPI_TLS_MODID +# ---------------------------- +# Check if struct dl_phdr_info includes the dlpi_tls_modid member and +# substitute DCFG_DLPI_TLS_MODID. +AC_DEFUN([DRUNTIME_OS_DLPI_TLS_MODID], +[ + AC_LANG_PUSH([C]) + AC_CHECK_MEMBER([struct dl_phdr_info.dlpi_tls_modid], + [DCFG_DLPI_TLS_MODID=true], [DCFG_DLPI_TLS_MODID=false], + [[#include ]]) + AC_SUBST(DCFG_DLPI_TLS_MODID) + AC_LANG_POP([C]) +]) + # DRUNTIME_OS_LINK_SPEC # --------------------- # Add target-specific link options to link_spec.