Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Apr 2007 07:59:05 GMT
From:      Scot Hetzel<swhetzel@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/112203: Mk/bsd.port.mk - Fix detection of 32bit libraries on FreeBSD/amd64, ia64
Message-ID:  <200704280759.l3S7x4dL014303@www.freebsd.org>
Resent-Message-ID: <200704280810.l3S8A6gD008958@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         112203
>Category:       ports
>Synopsis:       Mk/bsd.port.mk - Fix detection of 32bit libraries on FreeBSD/amd64, ia64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 28 08:10:05 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Scot Hetzel
>Release:        FreeBSD/amd64 7.0-CURRENT
>Organization:
Ye Old Computer
>Environment:
FreeBSD hp010.hetzel.org 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Fri Apr 27 00:26:19 CDT 2007     swhetzel@hp010.hetzel.org:/usr/src/7x/sys-p4/amd64/compile/GENERIC.debug  amd64

>Description:
When a port installs a 32bit binary program on FreeBSD/amd64 or FreeBSD/ia64 and it depends on a port that supplies 32bit libraries, the detection fails to detect that the dependency is already installed and attempts to reinstall the dependency.  Also, if the 32bit library is not installed, but a 64bit library matches what is found in LIB_DEPENDS, it will not install the dependency on the 32bit library port.

The cause of this behavior is that the library detection is only looking for the 64bit libraries, as ldconfig is not given the -32 flag when checking library dependencies.
>How-To-Repeat:
On a FreeBSD/amd64 system do the following:

Install misc/compat4x

cd /usr/ports/misc/compat4x
make install
chflags noschg work/var/empty
make clean

Then install security/vscan

cd /usr/ports/security/vscan

Edit the Makefile, and remove 'LDCONFIG= ldconfig -32' as it is a hack to get proper detection of it's library dependencies.

make install
:
===>  Patching for uvscan-5.10e_2
===>   uvscan-5.10e_3 depends on shared library: m.2 - not found
===>    Verifying install for m.2 in /usr/ports/misc/compat4x
===>  Extracting for compat4x-i386-5.3_9
:
<misc/compat4x gets reinstalled>
:
===>   Returning to build of uvscan-5.10e_2
Error: shared library "m.2" does not exist
*** Error code 1

Stop in /usr/ports/security/vscan.

 
>Fix:
Apply the attached patch.

- moves the IA32_BINARY_PORT check from the pre-makefile section into the post-makefile section of bsd.port.mk.
- defines LIB32DIR as lib32 on amd64/ia64 and as lib on i386
- adds LIB32DIR to PLIST_SUB
- fixes detection of 32bit libraries on amd64/ia64 systems

After this patch and the security/vscan PR ports/112202 are applied, the security/vscan port can be modified as follows:

Remove LIB32DIR=, LDCONFIG=, PLIST_SUB+= from security/vscan/Makefile

Patch attached with submission follows:

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.565
diff -u -r1.565 bsd.port.mk
--- bsd.port.mk	7 Apr 2007 12:51:47 -0000	1.565
+++ bsd.port.mk	7 Apr 2007 18:22:55 -0000
@@ -1208,29 +1208,6 @@
 MASTER_PORT?=
 .endif
 
-# Check the compatibility layer for amd64/ia64
-
-.if ${ARCH} == "amd64" || ${ARCH} =="ia64"
-.if exists(/usr/lib32)
-HAVE_COMPAT_IA32_LIBS?=  YES
-.endif
-.if !defined(HAVE_COMPAT_IA32_KERN)
-HAVE_COMPAT_IA32_KERN!= if ${SYSCTL} -a compat.ia32.maxvmem >/dev/null 2>&1; then echo YES; fi
-.endif
-.endif
-
-.if defined(IA32_BINARY_PORT) && ${ARCH} != "i386"
-.if ${ARCH} == "amd64" || ${ARCH} == "ia64"
-.if !defined(HAVE_COMPAT_IA32_KERN)
-IGNORE= you need a kernel with compiled-in IA32 compatibility to use this port.
-.elif !defined(HAVE_COMPAT_IA32_LIBS)
-IGNORE= you need the 32-bit libraries installed under /usr/lib32 to use this port.
-.endif
-.else
-IGNORE= you have to use i386 (or compatible) platform to use this port.
-.endif
-.endif
-
 # If they exist, include Makefile.inc, then architecture/operating
 # system specific Makefiles, then local Makefile.local.
 
@@ -1672,6 +1649,34 @@
 .endif
 .endif
 
+# Check the compatibility layer for amd64/ia64
+
+.if ${ARCH} == "amd64" || ${ARCH} =="ia64"
+.if exists(/usr/lib32)
+HAVE_COMPAT_IA32_LIBS?=  YES
+.endif
+.if !defined(HAVE_COMPAT_IA32_KERN)
+HAVE_COMPAT_IA32_KERN!= if ${SYSCTL} -a compat.ia32.maxvmem >/dev/null 2>&1; then echo YES; fi
+.endif
+.endif
+
+.if defined(IA32_BINARY_PORT) && ${ARCH} != "i386"
+.if ${ARCH} == "amd64" || ${ARCH} == "ia64"
+.if !defined(HAVE_COMPAT_IA32_KERN)
+IGNORE= you need a kernel with compiled-in IA32 compatibility to use this port.
+.elif !defined(HAVE_COMPAT_IA32_LIBS)
+IGNORE= you need the 32-bit libraries installed under /usr/lib32 to use this port.
+.endif
+_LDCONFIG_FLAGS=-32
+LIB32DIR=	lib32
+.else
+IGNORE= you have to use i386 (or compatible) platform to use this port.
+.endif
+.else
+LIB32DIR=	lib
+.endif
+PLIST_SUB+=	LIB32DIR=${LIB32DIR}
+
 .if defined(USE_ZIP)
 EXTRACT_DEPENDS+=	unzip:${PORTSDIR}/archivers/unzip
 .endif
@@ -3908,6 +3913,12 @@
 .endif
 # This can be removed once all ports have been converted to USE_LDCONFIG.
 .if defined(INSTALLS_SHLIB)
+.if defined(USE_LDCONFIG)
+	@${ECHO_MSG} "===>   INSTALLS_SHLIB and USE_LDCONFIG both defined."
+.endif
+.if defined(USE_LDCONFIG32)
+	@${ECHO_MSG} "===>   INSTALLS_SHLIB and USE_LDCONFIG32 both defined."
+.endif
 .if !defined(INSTALL_AS_USER)
 .if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig"
@@ -4901,7 +4912,7 @@
 		fi; \
 		if [ -z "${DESTDIR}" ] ; then \
 			${ECHO_MSG} -n "===>   ${PKGNAME} depends on shared library: $$lib"; \
-			if ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
+			if ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
 				${ECHO_MSG} " - found"; \
 				if [ ${_DEPEND_ALWAYS} = 1 ]; then \
 					${ECHO_MSG} "       (but building it anyway)"; \

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704280759.l3S7x4dL014303>