From owner-freebsd-toolchain@freebsd.org Fri Aug 19 00:43:07 2016 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80E09BBF2F3; Fri, 19 Aug 2016 00:43:07 +0000 (UTC) (envelope-from kargl@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C2451368; Fri, 19 Aug 2016 00:43:07 +0000 (UTC) (envelope-from kargl@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id u7J0h4a6094053 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 18 Aug 2016 17:43:04 -0700 (PDT) (envelope-from kargl@troutmask.apl.washington.edu) Received: (from kargl@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id u7J0h4h6094052; Thu, 18 Aug 2016 17:43:04 -0700 (PDT) (envelope-from kargl) Date: Thu, 18 Aug 2016 17:43:04 -0700 From: "Steven G. Kargl" To: Tijl Coosemans Cc: Dimitry Andric , Steve Kargl , freebsd-toolchain@freebsd.org, freebsd-ports@freebsd.org, kargl@uw.edu Subject: Re: Problems with out libgcc_s.so in base Message-ID: <20160819004304.GA94021@troutmask.apl.washington.edu> Reply-To: kargl@uw.edu References: <20160814230351.GA10587@troutmask.apl.washington.edu> <20160814233430.GA35872@night.db.net> <20160817211710.GA59205@troutmask.apl.washington.edu> <20160818111521.7f79b9f8@kalimero.tijl.coosemans.org> <20160819011432.6f2eadbd@kalimero.tijl.coosemans.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160819011432.6f2eadbd@kalimero.tijl.coosemans.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2016 00:43:07 -0000 On Fri, Aug 19, 2016 at 01:14:32AM +0200, Tijl Coosemans wrote: > On Thu, 18 Aug 2016 14:48:28 +0200 Dimitry Andric wrote: > > > how would you solve the problem of having > > multiple, possibly incompatible versions of the same library in > > different directories? > > > > For example, on one of my systems, I now have these: > > > > /usr/local/lib/gcc47/libgcc_s.so.1 > > /usr/local/lib/gcc48/libgcc_s.so.1 > > /usr/local/lib/gcc49/libgcc_s.so.1 > > /usr/local/lib/gcc5/libgcc_s.so.1 > > /usr/local/lib/gcc6/libgcc_s.so.1 > > /usr/local/lib/gcc7/libgcc_s.so.1 > > > > So which one are you going to put at the front of the path? The gcc7 > > version? If you are lucky that one is backwards compatible with all the > > previous ones, but still I would like it much better if a program > > compiled by, say, gcc5 was linked *explicitly* against the gcc5 version > > of libgcc_s.so. > > > > Steve's proposed scheme solves that quite nicely, in my opinion. The > > problem is only in the details, as usual. There will be many configure > > scripts and libtool-like utilities out there, that assume libgcc must be > > linked using -lgcc_s, not -lgcc_s$VERSION. > > This is a separate problem that has been discussed many times before. > The ports tree adds -Wl,-rpath to *FLAGS in several places to choose > a library. I now noticed there is a FAQ about this at > https://gcc.gnu.org/faq.html#rpath. It gives some suggestions including > creating wrapper scripts, but they wouldn't work when code is compiled > with gfortran but linked with Clang cc/c++. The only thing that works > in this case is -Wl,-rpath. Another option would be to create a port > that installs a recent version of libgcc in /usr/local/lib and let the > gcc ports use that instead of their own copy. It gross but it appears to work: % cd ~/work/6/lib % sed s/gcc_s/gcc_t/ < libgfortran.so.3 > zxc % mv zxc libgfortran.so.3 % elfdump -a libgfortran.so.3 | grep gcc_ d_val: libgcc_t.so.1 % ln -sf libgcc_s.so.1 libgcc_t.so.1 % ldconfig -R % ldconfig -r | grep libgcc 6:-lgcc_s.1 => /lib/libgcc_s.so.1 735:-lgcc_s.1 => /usr/local/lib/gcc6/libgcc_s.so.1 745:-lgcc_t.1 => /usr/local/lib/gcc6/libgcc_t.so.1 % cd tmp % gfortran6 -o z foo.f90 && ./z Hello That is, the name clash in ldconfig can be avoided by editing libgfortran.so.3 to look for a symlinked libgcc_s.so.1. -- Steve http://troutmask.apl.washington.edu/~kargl/