From owner-freebsd-ports@freebsd.org Fri Feb 22 11:29:59 2019 Return-Path: Delivered-To: freebsd-ports@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 5A6F214E7642 for ; Fri, 22 Feb 2019 11:29:59 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay117.isp.belgacom.be (mailrelay117.isp.belgacom.be [195.238.20.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F5E18FC45 for ; Fri, 22 Feb 2019 11:29:58 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DmAACP3G9c/99MQFdlDg4BAgQBCAQ?= =?us-ascii?q?BgVUEAQwBggNngQMnhAeIeYpzAoIMNQGJcI9zKIRRAoN8IzcGDQEDAQECAQE?= =?us-ascii?q?CbRwMhUoBAQEBAgEjMyMFCwsOCgkhAgIPKh4GE4MhgWoMq0mBL4khfw+MX4F?= =?us-ascii?q?/hCOICoJXApEakj8JhEyCcoNvhyclgkmQRi2eMyKBVk0wCIMnCVaBSReKPIM?= =?us-ascii?q?nPD4DMAGNPSqCIwEB?= X-IPAS-Result: =?us-ascii?q?A2DmAACP3G9c/99MQFdlDg4BAgQBCAQBgVUEAQwBggNng?= =?us-ascii?q?QMnhAeIeYpzAoIMNQGJcI9zKIRRAoN8IzcGDQEDAQECAQECbRwMhUoBAQEBA?= =?us-ascii?q?gEjMyMFCwsOCgkhAgIPKh4GE4MhgWoMq0mBL4khfw+MX4F/hCOICoJXApEak?= =?us-ascii?q?j8JhEyCcoNvhyclgkmQRi2eMyKBVk0wCIMnCVaBSReKPIMnPD4DMAGNPSqCI?= =?us-ascii?q?wEB?= Received: from 223.76-64-87.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([87.64.76.223]) by relay.skynet.be with ESMTP; 22 Feb 2019 12:28:48 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id x1MBSgqY001882; Fri, 22 Feb 2019 12:28:43 +0100 (CET) (envelope-from tijl@FreeBSD.org) Date: Fri, 22 Feb 2019 12:28:41 +0100 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Steve Kargl Cc: Diane Bruce , "Russell L. Carter" , Eugene Grosbein , FreeBSD Ports ML Subject: Re: FreeCAD 0.17 && /lib//libgcc_s.so.1 Message-ID: <20190222122841.6d48b473@kalimero.tijl.coosemans.org> In-Reply-To: <20190222001315.GA24225@troutmask.apl.washington.edu> References: <416689e6-37f9-17ec-54d8-0d224c26f30f@pinyon.org> <20190217151604.GB68620@night.db.net> <20190221180515.39c79ce6@kalimero.tijl.coosemans.org> <20190221183040.GA42303@night.db.net> <20190221231850.46dd5374@kalimero.tijl.coosemans.org> <20190222001315.GA24225@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/cQ+YeS_/Zzb2b/nLG4lA2zv" X-Rspamd-Queue-Id: 9F5E18FC45 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; ASN(0.00)[asn:5432, ipnet:195.238.0.0/19, country:BE] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2019 11:29:59 -0000 --MP_/cQ+YeS_/Zzb2b/nLG4lA2zv Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thu, 21 Feb 2019 16:13:15 -0800 Steve Kargl wrote: > On Thu, Feb 21, 2019 at 11:18:50PM +0100, T=C4=B3l Coosemans wrote: >> On Thu, 21 Feb 2019 13:30:41 -0500 Diane Bruce wrote: >>> On Thu, Feb 21, 2019 at 06:05:15PM +0100, T=C4=B3l Coosemans wrote: >>>> On Sun, 17 Feb 2019 10:16:04 -0500 Diane Bruce wrote: >>>>> Except python doesn't have an rpath which is why this keeps coming >>>>> up over and over again. >>>>=20 >>>> Maybe we should just add the gcc rpaths to the python ports LDFLAGS >>>> without depending on gcc. Then python should use gcc libgcc_s when >>>> it exists and fall back to base system libgcc_s when it doesn't. >>>=20 >>> Right. Or just provide a shell shim to LD_PRELOAD IFF it is noticed >>> a specific port will require a fortran built binary module later. >>>=20 >>>> Maybe we should compile *all* ports with gcc rpaths without depending >>>> on gcc, just like we already compile everything with -fstack-protector >>>> in LDFLAGS. >>>>=20 >>>> There's also the fact that gfortran behaves differently from the C >>>> compilers (both clang and gcc) when it comes to libgcc_s. Gfortran >>>> always links with libgcc_s. The C compilers link with libgcc.a first >>>> and then with libgcc_s only as needed. This eliminates almost all >>>=20 >>> What is really happening is gfortran links with libgfortran (surprise >>> surprise) and libgfortran has the requirement for @GCC_4.6.0 or later >>>=20 >>>> links with libgcc_s. The only ones left are for exception handling >>>> and stack unwinding and gcc libgcc_s and base system libgcc_s are >>>> version compatible for that so it doesn't matter which one gets picked >>>> up. The attached patch for lang/gcc8 makes gfortran behave just like >>>> the C compilers. >>>=20 >>> Something like this was tried already. I'll have to dig into >>> my old notes. >>=20 >> With my patch libgfortran only needs GCC_4.2.0 and works with base >> libgcc_s. >=20 > Why not bump the major version number of the port? Because that renames the library and like I said, renaming allows a process to load both versions, as your example shows. > % ~/work/x/bin/gfortran -o z hello.f90 > % ldd z > z: > libgfortran.so.5 =3D> /usr/local/lib/gcc8/libgfortran.so.5 (0x200= 800000) > libm.so.5 =3D> /lib/libm.so.5 (0x200645000) > libgcc_s.so.2 =3D> /safe/sgk/work/x/lib/libgcc_s.so.2 (0x200c5800= 0) > libquadmath.so.0 =3D> /usr/local/lib/gcc8/libquadmath.so.0 (0x200= e70000) > libc.so.7 =3D> /lib/libc.so.7 (0x2010b0000) > libz.so.6 =3D> /lib/libz.so.6 (0x200678000) > libgcc_s.so.1 =3D> /usr/local/lib/gcc8/libgcc_s.so.1 (0x2014a1000) > % nm z | grep 4.6 > U __multf3@@GCC_4.6.0 > % ./z > 2.00000000000000000000000000000000000 >=20 > Note, I'm playing with a test install into a ~/work/x directory. > The ldconfig still has issues with first come first served >=20 > % ldconfig -r | grep libgcc_s > 6:-lgcc_s.1 =3D> /lib/libgcc_s.so.1 > 806:-lgcc_s.1 =3D> /usr/local/lib/gcc8/libgcc_s.so.1 > 880:-lgcc_s.2 =3D> /safe/sgk/work/x/lib/libgcc_s.so.2 > % ldconfig -r | grep libgfortran > 808:-lgfortran.5 =3D> /usr/local/lib/gcc8/libgfortran.so.5 > 876:-lgfortran.5 =3D> /safe/sgk/work/x/lib/libgfortran.so.5 >=20 > 6 is picked up due to libc.so. 806 is picked up due to > 808, but won't be there is major version number is > bumped. 876 is the loser of the first come first served, here; > but 808 would be the correct libgfortran point to 880 if I > had installed into /usr/local/lib/gcc8. The ldconfig order can be improved. I've attached another patch that I've been using for a long time. It changes /etc/rc.d/ldconfig so it puts /usr/lib and /lib last, just like compilers and linkers do at compile time, and as documented in rtld(1). It also sorts paths like /usr/local/lib/gcc(7|8|9|10) in reverse version order so if multiple versions are installed the most recent libgcc_s is listed first. > PS: For the record, the GCC_4.6.0 are needed for gfortran REAL(16) > type. With my patch gfortran resolves the GCC_4.6.0 symbols statically just like the C compilers do. If the C compilers didn't do this we'd have this libgcc_s problem all over the place. It makes perfect sense to make gfortran do the same thing. --MP_/cQ+YeS_/Zzb2b/nLG4lA2zv Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=ldconfig.patch Index: libexec/rc/rc.conf =================================================================== --- libexec/rc/rc.conf (revision 343935) +++ libexec/rc/rc.conf (working copy) @@ -636,14 +636,14 @@ linux_enable="NO" # Linux binary compatibility loaded clear_tmp_enable="NO" # Clear /tmp at startup. clear_tmp_X="YES" # Clear and recreate X11-related directories in /tmp ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks -ldconfig_paths="/usr/lib/compat /usr/local/lib /usr/local/lib/compat/pkg" +ldconfig_paths="/usr/local/lib /usr/local/lib/compat/pkg /usr/lib /usr/lib/compat /lib" # shared library search paths ldconfig32_paths="/usr/lib32 /usr/lib32/compat" # 32-bit compatibility shared library search paths -ldconfigsoft_paths="/usr/libsoft /usr/libsoft/compat /usr/local/libsoft" +ldconfigsoft_paths="/usr/local/libsoft /usr/libsoft /usr/libsoft/compat" # soft float compatibility shared library search paths # Note: temporarily with extra stuff for transition -ldconfig_paths_aout="/usr/lib/compat/aout /usr/local/lib/aout" +ldconfig_paths_aout="/usr/local/lib/aout /usr/lib/aout /usr/lib/compat/aout" # a.out shared library search paths ldconfig_local_dirs="/usr/local/libdata/ldconfig" # Local directories with ldconfig configuration files. Index: libexec/rc/rc.d/ldconfig =================================================================== --- libexec/rc/rc.d/ldconfig (revision 343935) +++ libexec/rc/rc.d/ldconfig (working copy) @@ -17,22 +17,23 @@ stop_cmd=":" ldconfig_start() { - local _files _ins + local _files _ins _paths _LDC _ins= ldconfig=${ldconfig_command} checkyesno ldconfig_insecure && _ins="-i" if [ -x "${ldconfig_command}" ]; then - _LDC="/lib /usr/lib" + _paths="" for i in ${ldconfig_local_dirs}; do if [ -d "${i}" ]; then _files=`find ${i} -type f` if [ -n "${_files}" ]; then - ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`" + _paths="${_paths} `cat ${_files} | sort -Vru`" fi fi done - for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do + _LDC="" + for i in ${_paths} ${ldconfig_paths} /etc/ld-elf.so.conf; do if [ -r "${i}" ]; then _LDC="${_LDC} ${i}" fi @@ -42,16 +43,17 @@ ldconfig_start() case `sysctl -n hw.machine_arch` in amd64|mips64|powerpc64) + _paths="" for i in ${ldconfig_local32_dirs}; do if [ -d "${i}" ]; then _files=`find ${i} -type f` if [ -n "${_files}" ]; then - ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`" + _paths="${_paths} `cat ${_files} | sort -Vru`" fi fi done _LDC="" - for i in ${ldconfig32_paths}; do + for i in ${_paths} ${ldconfig32_paths}; do if [ -r "${i}" ]; then _LDC="${_LDC} ${i}" fi @@ -64,16 +66,17 @@ ldconfig_start() case `sysctl -n hw.machine_arch` in armv[67]) + _paths="" for i in ${ldconfig_localsoft_dirs}; do if [ -d "${i}" ]; then _files=`find ${i} -type f` if [ -n "${_files}" ]; then - ldconfigsoft_paths="${ldconfigsoft_paths} `cat ${_files} | sort -u`" + _paths="${_paths} `cat ${_files} | sort -Vru`" fi fi done _LDC="" - for i in ${ldconfigsoft_paths}; do + for i in ${_paths} ${ldconfigsoft_paths}; do if [ -r "${i}" ]; then _LDC="${_LDC} ${i}" fi @@ -87,10 +90,8 @@ ldconfig_start() # Legacy aout support for i386 only case `sysctl -n hw.machine_arch` in i386) - # Default the a.out ldconfig path. - : ${ldconfig_paths_aout=${ldconfig_paths}} _LDC="" - for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do + for i in ${ldconfig_paths_aout} /etc/ld.so.conf; do if [ -r "${i}" ]; then _LDC="${_LDC} ${i}" fi --MP_/cQ+YeS_/Zzb2b/nLG4lA2zv--