From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id 0022C3858412 for ; Mon, 11 Jul 2022 08:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0022C3858412 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=none smtp.mailfrom=cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id BFA0FC7984; Mon, 11 Jul 2022 10:58:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sEvA6S97hyFl; Mon, 11 Jul 2022 10:58:40 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p508547b6.dip0.t-ipconnect.de [80.133.71.182]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id E5C58C7887; Mon, 11 Jul 2022 10:58:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1657529920; bh=M/2y047u9zx3ZBvbcdvSQaX4LPbdgRvIzKZrnlpq/xY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=DuAHHQnFtePOf0Fg/psdusDI9DsRiioNyvOwHGpXNdAY3zA66YtHqCyCmkAzuIDaF sxLxi6yGIDpKqft0L1/SY6dxwixxrGRzqGFk9v/Rl57UqhOdskuLDoG4u16awUEqvd FKSlEll1f7CdA9HwcPXzMePL9tTNMEp2+4t04xeC3tZi4O2pufEr+Qd65KUZUWqq+z BzK0k+RDSCm+FW8CAPt/afTxNk65uo+FnBgYX2dKvmNKZF3iLQbZsjWMiHy4coE4yn GTNt6y+HNb0P4m1nhFNqdbeIql6FNJ7QDsKS97li1Scwt1abgH74kzK1nCZ6LiSOnu 0lAZAuo0ZJSeA== From: Rainer Orth To: Iain Buclaw Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] d: Move DSO registry support code from compiler to drtstuff in library (PR100062) References: <20220708130729.3690093-1-ibuclaw@gdcproject.org> Date: Mon, 11 Jul 2022 10:58:39 +0200 In-Reply-To: <20220708130729.3690093-1-ibuclaw@gdcproject.org> (Iain Buclaw's message of "Fri, 8 Jul 2022 15:07:29 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-3788.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Mon, 11 Jul 2022 08:58:44 -0000 --=-=-= Content-Type: text/plain Hi Iain, > Currently the DSO support for D runtime is generated by the compiler in > every object, when really it is only required once per shared object. > > This patch moves that support logic from the compiler itself to the > library as part of the drtstuff code. The object files drtbegin.o and > drtend.o are now always linked in. > > Bootstrapped and tested on x86_64-linux-gnu/-m32/-mx32, with no > observable regressions. > > @Rainer, as you provided the original, would be good to validate this is > fine for Solaris too. I did, with mixed success: initially, the patch broke bootstrap on both i386-pc-solaris2.11 and sparc-sun-solaris2.11 linking libgdruntime.so: Text relocation remains referenced against symbol offset in file __start_minfo 0x2 gcc/drtbegin.o _D8drtstuff7dsoSlotPv 0x7 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x1e gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x28 gcc/drtbegin.o __stop_minfo 0x2c gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x34 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x39 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x7 gcc/drtbegin.o _d_dso_registry 0x3e gcc/drtbegin.o _d_dso_registry 0xc gcc/drtbegin.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: error: ld returned 1 exit status make[5]: *** [Makefile:1943: libgdruntime.la] Error 1 Solaris ld defaults to -z text, and gcc is still non-pic/pie by default. The attached patch fixes the issue by building drtbegin.o/drtend.o as libtool objects. There are a couple of caveats, though: * It directs gdc to libdruntime/gcc/.libs instead of libdruntime/gcc. I've no idea what happens when configuring with --disable-shared, building for targets without PIC support, or on Windows where that directory is called _libs instead (I've found no variable to use here). OTOH, testsuite_flags.in already hardcodes .libs, so this is a preexisting problem. * I haven't checked if the PIC drt*.o files are actually installed, otherwise gdc wouldn't be able to create shared objects on Solaris. * This comment is misleading now that those files are used unconditionally: # Provide __start_minfo, __stop_minfo if linker doesn't. DRTSTUFF = gcc/drtbegin.o gcc/drtend.o At least with this incremental patch, I've been able to successfully bootstrap and test trunk on i386-pc-solaris2.11 (Solaris 11.3 which lacks ld support for __start_
/__stop_