From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Davis Herring Newsgroups: gmane.emacs.devel Subject: Re: emacs25 dynamic module dlopen flags Date: Mon, 6 Mar 2017 14:24:15 -0700 Organization: XCP-1 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1488835501 5227 195.159.176.226 (6 Mar 2017 21:25:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Mar 2017 21:25:01 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 Cc: emacs-devel@gnu.org To: hx , Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 06 22:24:57 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl07e-0000PR-Jd for ged-emacs-devel@m.gmane.org; Mon, 06 Mar 2017 22:24:50 +0100 Original-Received: from localhost ([::1]:46224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cl07k-00017A-SF for ged-emacs-devel@m.gmane.org; Mon, 06 Mar 2017 16:24:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cl07D-000173-IF for emacs-devel@gnu.org; Mon, 06 Mar 2017 16:24:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cl07A-0004Sv-Cw for emacs-devel@gnu.org; Mon, 06 Mar 2017 16:24:23 -0500 Original-Received: from proofpoint5.lanl.gov ([2001:400:4210:400::a5]:42278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cl07A-0004SS-3l for emacs-devel@gnu.org; Mon, 06 Mar 2017 16:24:20 -0500 Original-Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103]) by mailgate5.lanl.gov (8.15.0.59/8.15.0.59) with ESMTP id v26LOFom029477; Mon, 6 Mar 2017 14:24:15 -0700 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay2.lanl.gov (Postfix) with ESMTP id B8358F740BA; Mon, 6 Mar 2017 14:24:15 -0700 (MST) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay2.lanl.gov Original-Received: from bismuth.lanl.gov (bismuth.lanl.gov [128.165.246.103]) by mailrelay2.lanl.gov (Postfix) with ESMTP id 9D922F740B8; Mon, 6 Mar 2017 14:24:15 -0700 (MST) In-Reply-To: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.16.24, 1.0.8, 0.0.0000 definitions=2017-03-06_21:2017-03-06, 2017-03-06, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 2001:400:4210:400::a5 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212803 Archived-At: > my emacs module linked with libperl.so, > when perl interpreter in the module execute some scripts, it may load other > .so files depending on which perl package is going to be loaded, > for example, DBD::mysql will load DBD/mysql/mysql.so, Socket will > load Socket.so, > without that flag, loading Socket.so will fail, the error message is like > Socket.so can't find some symbols from libperl.so . > it may look like the problem is in libperl.so, > but if I add RTLD_GLOBAL in emacs/src/dynlib.c, Socket.so will be loaded > successful, I've had the same issues with Python (playing the role of Emacs here): it uses RTLD_LOCAL, which is fine for the "top level" .so but bad for the (DT_NEEDED) dependencies because they should be made available to other things which might have them as dependencies. (Otherwise you can get duplicate symbols loaded, which breaks things that have vague linkage (from C++) or which have static duration variables.) Unfortunately, the fixed names that Philipp mentioned prevent this from working: you can't load two such things with RTLD_GLOBAL because the names will collide. Python doesn't have that problem because it looks for a symbol initfoo in a module named foo. If modules are careful to make all their other symbols have internal linkage (or have hidden ELF visibility), it should be an improvement (although Ulrich Drepper's piece on the subject calls RTLD_GLOBAL "usually a very bad idea"). Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.