From owner-freebsd-hackers@freebsd.org Thu May 10 19:48:25 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A59ABFD4C12 for ; Thu, 10 May 2018 19:48:25 +0000 (UTC) (envelope-from sgk@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 3AE8F6D423 for ; Thu, 10 May 2018 19:48:25 +0000 (UTC) (envelope-from sgk@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 w4AJmNil095994 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 10 May 2018 12:48:23 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w4AJmNcB095993 for freebsd-hackers@freebsd.org; Thu, 10 May 2018 12:48:23 -0700 (PDT) (envelope-from sgk) Date: Thu, 10 May 2018 12:48:23 -0700 From: Steve Kargl To: freebsd-hackers@freebsd.org Subject: Re: Runtime loader issue Message-ID: <20180510194823.GA60567@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20180509234551.GA39526@troutmask.apl.washington.edu> <20180510190549.GB14916@britannica.bec.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180510190549.GB14916@britannica.bec.de> User-Agent: Mutt/1.9.2 (2017-12-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 19:48:25 -0000 On Thu, May 10, 2018 at 09:05:49PM +0200, Joerg Sonnenberger wrote: > On Wed, May 09, 2018 at 04:45:51PM -0700, Steve Kargl wrote: > > In review PR 228007, it came to my attention some individuals are > > mis-characterizing a FreeBSD loader issue as "gfortran's FreeBSD > > issue". > > I don't get why you are blaming the FreeBSD loader. In fact, this is a > pretty common issue and the fault is and has always been that the GCC > ecosystem is extremely bad about mixing different GCC versions in the > runtime environment. It tends to somewhat work as long as you make sure > that the main binary is using the newest GCC version, but it can still > fail even then. > It is a runtime loader issue in that the loader cannot not deal with a name clash. Suppose project Ajax has libfoo.so.1 and project Nub has libfoo.so.1. You install Ajax first, ldconfig will find 42:-lfoo.1 => /usr/local/lib/ajax/libfoo.so.1 while project Nub's libfoo.so.1 is 666:-lfoo.1 => /usr/local/lib/nub/libfoo.so.1 You build your Nub project bar and go to execute bar where upon the runtime loader finds 42 instead of 666. Tijl's suggested fix of re-ordering the list of hints so gcc7's libgcc_s.so.1 is found before /lib/libgcc_s.so.1 works around the issue of executables compiled by gfortran7 getting the correct libgcc_s.so.1. It does not solve the above problem, because once re-ordered, anything compiled by the ajax project finds the wrong libfoo.so.1 library. As to your comment "the fault is and has always been that the GCC ecosystem is extremely bad about mixing different GCC version". libgcc_s.so.1 is a symbol versioned shared library. As long as the ABI of symbols are not changed, one can add new symbols without bumping the library version number. GCC has added symbols to libgcc_s.so.1 since gcc 4.2.1, and FreeBSD has not stayed in-sync. If you want to get snarky about different projects, don't you think that "the fault is and has always been that the FreeBSD ecosystem" (mis)appropriated the name libgcc when clang came into the tree [1] because clang didn't have a runtime library [2] and it was expedient to simply use libgcc_s.so.1. [1] llvm+clang Added Tue Jun 2 17:58:47 2009 UTC (8 years, 11 months ago) by ed https://svnweb.freebsd.org/base?view=revision&revision=193326 [2] compiler-rt. Added Thu Oct 21 19:02:02 2010 UTC (7 years, 6 months ago) by ed https://svnweb.freebsd.org/base?view=revision&revision=214152 -- Steve