Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jul 2011 05:58:53 +0000
From:      "b. f." <bf1783@googlemail.com>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        "freebsd-x11@FreeBSD.org" <freebsd-x11@freebsd.org>, danfe@FreeBSD.org
Subject:   Re: x11/nvidia-driver incompatible with portmaster?
Message-ID:  <CAGFTUwPHREj=oucqCihCpYB%2BzdZR3Vtkztaod9EbV2SaP679HA@mail.gmail.com>
In-Reply-To: <20110703140400.GO48734@deviant.kiev.zoral.com.ua>
References:  <CAGFTUwMPV9Tge6%2BGZO879KD7dh6Sr6%2BfPGK97SGvRndBitMTjg@mail.gmail.com> <4E0FCDD1.7050809@missouri.edu> <4E0FD8DC.20700@missouri.edu> <CAGFTUwM-c4WvkX01iuDh4kWcjX8kLKv9Gm1297orPMgNyV_1Cg@mail.gmail.com> <20110703114104.GK48734@deviant.kiev.zoral.com.ua> <CAGFTUwM2VMBsWmxQ70PkNcDfPb_JOBUw7N1wZOVsXfPPSQic1g@mail.gmail.com> <20110703140400.GO48734@deviant.kiev.zoral.com.ua>

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

[-- Attachment #1 --]
On 7/3/11, Kostik Belousov <kostikbel@gmail.com> wrote:
> On Sun, Jul 03, 2011 at 12:45:50PM +0000, b. f. wrote:
>> On 7/3/11, Kostik Belousov <kostikbel@gmail.com> wrote:
>> > On Sun, Jul 03, 2011 at 03:54:15AM +0000, b. f. wrote:
>> >> On 7/3/11, Stephen Montgomery-Smith <stephen@missouri.edu> wrote:
>> >> > On 07/02/2011 09:02 PM, Stephen Montgomery-Smith wrote:
>> >> >> On 07/02/2011 08:39 PM, b. f. wrote:
>> ...
>> >
>> > That said, there is absolutely no need in any static linker tricks,
>> > esp. a heavy one like filters or linker scripts. A symlink named
...
>>
>> > libGL.so would be enough for the static linker, pointing to any
>> > of two libraries. And symlink libGL.so.1 would be also enough
>> > for dynamic linker.
>> >
>> > The real issue with xorg-server, mesa and nvidia driver is only
>> > the overwrite of extensions/libglx.so and lib/libGL.so.1. If
>> > this can be somewhat solved by the packaging system, that would
>> > be great. On my hybrid laptop I have to manually manage the
>> > said symlinks (actually, with the rc script that verifies
>> > the list of pci devices and arranges the symlinks).
>>
>> So basically, you would prefer that we:
>>
>> patch xorg-server so that it installs, e.g.,
>> ${PREFIX}/lib/xorg/modules/extensions/libglx-xorg.so.1 instead of
>> ${PREFIX}/lib/xorg/modules/extensions/libglx.so.1, and points the
>> symlink ${PREFIX}/lib/xorg/modules/extensions/libglx-xorg.so at the
>> former;
>>
>> patch libGL so that it installs, e.g., ${PREFIX}/lib/libGL-mesa.so.1
>> instead of ${PREFIX}/lib/libGL.so.1, and points the symlink
>> ${PREFIX}/lib/libGL.so at the former;
>>
>> and patch nvidia-driver so that it installs, e.g.,
>> ${PREFIX}/lib/xorg/modules/extensions/libglx-nvidia.so.1 instead of
>> ${PREFIX}/lib/xorg/modules/extensions/libglx.so.1, and
>> ${PREFIX}/lib/libGL-nvidia.so.1 instead of ${PREFIX}/lib/libGL.so.1;
>> and during installation it overwrites the
>> ${PREFIX}/lib/xorg/modules/extensions/libglx-xorg.so and
>> ${PREFIX}/lib/libGL.so symlinks, redirecting them to the corresponding
>> nvidia libraries; while during deinstallation it changes them to point
>> to the mesa/xorg libraries?
> Yes.
>
>>
>> And corresponding redirection to handle the libtool archive file?
> I do not think this is needed. First, I believe .la files are only
> installed by the Xorg ports. Second, as I described, libGL.so from
> Xorg and from NVidia should be replacable for the static linking
> purposes. Third, libglx.la is not used at all.
...
> On Sun, Jul 03, 2011 at 01:33:09PM +0000, b. f. wrote:
>> On second thought the renaming of these libraries is not very
>> convenient, since they are built by nvidia, and not necessary if their
>> mesa/xorg counterparts already have different names.
>
> As I said, it is useful for me on the hybrid laptop, where a switch
> selects the GPU attached to the panel. The startup script then would
> only need to create proper symlink, instead of delicate renaming
> of the libraries.

Please consider the attached patch.  Small unrelated clean-ups to
x11-servers/xorg-server and bsd.mesalib.mk are included with the
changes that remove the collisions, and add the necessary symlinks.
The renaming in the xorg-server post-install target is a bit ugly, but
much easier than dissecting the libtool build and installation of the
glx convenience library.  I used sed rather than patches for some of
the changes in libGL and nvidia-driver because of the multiple
distfiles involved.

b.

[-- Attachment #2 --]
Index: graphics/libGL/Makefile
===================================================================
RCS file: /home/pcvs/ports/graphics/libGL/Makefile,v
retrieving revision 1.17
diff -u -r1.17 Makefile
--- graphics/libGL/Makefile	25 Feb 2011 16:52:06 -0000	1.17
+++ graphics/libGL/Makefile	5 Jul 2011 03:15:55 -0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	libGL
 PORTVERSION=	${MESAVERSION}
+PORTREVISION=	1
 CATEGORIES=	graphics
 
 COMMENT=	OpenGL library that renders using GLX or DRI
@@ -20,6 +21,11 @@
 do-install:
 	${RM} -f ${WRKSRC}/include/GL/glu*.h
 	cd ${WRKSRC}/src/mesa; ${GMAKE} install-libgl
+	${INSTALL_LIB} ${WRKSRC}/lib/libGL.so.1 ${PREFIX}/lib/libGL-mesa.so.1
+#For the libGL.so.1 link, defer to nvidia-driver, if the latter is present:
+	cd ${PREFIX}/lib ; ${LN} -sf libGL.so.1 libGL.so ; \
+		if [ ! -f libGL-nvidia.so.1 ] ; then \
+		${LN} -sf libGL-mesa.so.1 libGL.so.1 ; fi
 
 .include "${.CURDIR}/bsd.mesalib.mk"
 .include <bsd.port.mk>
Index: graphics/libGL/bsd.mesalib.mk
===================================================================
RCS file: /home/pcvs/ports/graphics/libGL/bsd.mesalib.mk,v
retrieving revision 1.17
diff -u -r1.17 bsd.mesalib.mk
--- graphics/libGL/bsd.mesalib.mk	25 Feb 2011 16:52:06 -0000	1.17
+++ graphics/libGL/bsd.mesalib.mk	5 Jul 2011 02:56:06 -0000
@@ -43,8 +43,9 @@
 GNU_CONFIGURE=	yes
 MAKE_JOBS_SAFE=	yes
 
-CONFIGURE_ENV=	CPPFLAGS=-I${LOCALBASE}/include \
-				LDFLAGS=-L${LOCALBASE}/lib
+CPPFLAGS+=	-I${LOCALBASE}/include
+LDFLAGS+=	-L${LOCALBASE}/lib
+CONFIGURE_ENV=	LDFLAGS="${LDFLAGS}"
 CONFIGURE_ARGS=	--disable-gallium
 
 ALL_TARGET=		default
@@ -108,6 +109,10 @@
 		${WRKSRC}/src/glw/Makefile \
 		${WRKSRC}/src/mesa/Makefile \
 		${WRKSRC}/src/mesa/drivers/dri/Makefile
+.if ${COMPONENT:MGL} != ""
+	@${REINPLACE_CMD} -e '/install-libgl:/,/:/{/INSTALL.*GL_LIB_GLOB/,/INSTALL_LIB_DIR/d;}' \
+		${WRKSRC}/src/mesa/Makefile
+.endif
 .if ${COMPONENT:Mglut} != ""
 	@${REINPLACE_CMD} -e 's|[$$](INSTALL_LIB_DIR)/pkgconfig|${PREFIX}/libdata/pkgconfig|' \
 		${WRKSRC}/src/glut/glx/Makefile
Index: graphics/libGL/pkg-plist
===================================================================
RCS file: /home/pcvs/ports/graphics/libGL/pkg-plist,v
retrieving revision 1.4
diff -u -r1.4 pkg-plist
--- graphics/libGL/pkg-plist	7 Feb 2010 11:51:05 -0000	1.4
+++ graphics/libGL/pkg-plist	5 Jul 2011 00:32:28 -0000
@@ -14,7 +14,11 @@
 include/GL/vms_x_fix.h
 %%MESALIB76%%include/GL/wglext.h
 include/GL/wmesa.h
-lib/libGL.so
-lib/libGL.so.1
+lib/libGL-mesa.so.1
+@exec ln -sf libGL.so.1 %B/libGL.so
+@comment For the libGL.so.1 link, defer to nvidia-driver, if the latter is present:
+@exec if [ ! -f %B/libGL-nvidia.so.1 ] ; then ln -sf %f %B/libGL.so.1 ; fi
+@comment On removal, delete these links if they are not owned by nvidia-driver:
+@unexec if [ ! -f %B/libGL-nvidia.so.1 ] ; then rm -f %B/libGL.so.1 %B/libGL.so ; fi
 libdata/pkgconfig/gl.pc
 @dirrmtry include/GL
Index: x11-servers/xorg-server/Makefile
===================================================================
RCS file: /home/pcvs/ports/x11-servers/xorg-server/Makefile,v
retrieving revision 1.80
diff -u -r1.80 Makefile
--- x11-servers/xorg-server/Makefile	27 Feb 2011 23:16:09 -0000	1.80
+++ x11-servers/xorg-server/Makefile	4 Jul 2011 23:46:38 -0000
@@ -7,17 +7,14 @@
 
 PORTNAME=	xorg-server
 PORTVERSION=	1.7.7
-PORTREVISION=	1
+PORTREVISION=	2
 PORTEPOCH=	1
 CATEGORIES=	x11-servers
-MASTER_SITES=	http://xorg.freedesktop.org/releases/individual/xserver/
-DISTFILES=	xorg-server-${PORTVERSION}.tar.bz2
 
 MAINTAINER=	x11@FreeBSD.org
 COMMENT=	X.Org X server and related programs
 
 LIB_DEPENDS=	drm:${PORTSDIR}/graphics/libdrm
-
 RUN_DEPENDS=	${LOCALBASE}/share/X11/xkb/rules/base.xml:${PORTSDIR}/x11/xkeyboard-config
 
 XORG_CAT=	xserver
@@ -91,21 +88,21 @@
 
 .if ${ARCH} == alpha
 PLIST_SUB+=	ALPHA_NA="@comment "
-EXTRA_PATCHES=	${.CURDIR}/files/extra-arch-alpha
+EXTRA_PATCHES=	${FILESDIR}/extra-arch-alpha
 .else
 PLIST_SUB+=	ALPHA_NA=""
 .endif
 
 .if ${ARCH} == ia64
-PLIST_SUB+=     IA64_NA="@comment "
-EXTRA_PATCHES=  ${.CURDIR}/files/extra-arch-ia64
+PLIST_SUB+=	IA64_NA="@comment "
+EXTRA_PATCHES=	${FILESDIR}/extra-arch-ia64
 .else
-PLIST_SUB+=     IA64_NA=""
+PLIST_SUB+=	IA64_NA=""
 .endif
 
 .if ${ARCH} == powerpc || ${ARCH} == powerpc64
 PLIST_SUB+=	PPC_NA="@comment "
-EXTRA_PATCHES=	${.CURDIR}/files/extra-arch-powerpc
+EXTRA_PATCHES=	${FILESDIR}/extra-arch-powerpc
 .else
 PLIST_SUB+=	PPC_NA=""
 .endif
@@ -134,4 +131,14 @@
 	@${ECHO_MSG} "NO_SUID_XSERVER=YES in /etc/make.conf."
 .endif
 
+#Avoid conflict with nvidia-driver by moving libglx.so to libglx-xorg.so.  If
+#the nvidia-driver is present, restore any nvidia-driver symlinks that may have been
+#clobbered during installation:
+post-install:
+	@(cd ${PREFIX}/lib/xorg/modules/extensions ; \
+		${MV} -f libglx.so libglx-xorg.so ; \
+		if [ -L libglx.so.1 ] ; then \
+		${LN} -sf libglx.so.1 libglx.so ; else \
+		${LN} -sf libglx-xorg.so libglx.so ; fi)
+
 .include <bsd.port.post.mk>
Index: x11-servers/xorg-server/pkg-plist
===================================================================
RCS file: /home/pcvs/ports/x11-servers/xorg-server/pkg-plist,v
retrieving revision 1.21
diff -u -r1.21 pkg-plist
--- x11-servers/xorg-server/pkg-plist	1 May 2010 11:41:05 -0000	1.21
+++ x11-servers/xorg-server/pkg-plist	5 Jul 2011 05:42:44 -0000
@@ -175,7 +175,10 @@
 lib/xorg/modules/extensions/libextmod.la
 lib/xorg/modules/extensions/libextmod.so
 lib/xorg/modules/extensions/libglx.la
-lib/xorg/modules/extensions/libglx.so
+lib/xorg/modules/extensions/libglx-xorg.so
+@comment Add and remove links to libglx.so, if the nvidia-driver is not present:
+@exec if [ ! -L %B/libglx.so.1 ] ; then ln -sf %f %B/libglx.so ; fi
+@unexec if [ ! -L %B/libglx.so.1 ] ; then rm -f %B/libglx.so ; fi
 lib/xorg/modules/extensions/librecord.la
 lib/xorg/modules/extensions/librecord.so
 lib/xorg/modules/libexa.la
@@ -218,11 +221,10 @@
 libdata/pkgconfig/xorg-server.pc
 share/aclocal/xorg-server.m4
 @dirrm include/xorg
-@dirrm lib/xorg/modules/extensions
-@dirrm lib/xorg/modules/linux
-@dirrm lib/xorg/modules/multimedia
-@dirrm lib/xorg/modules
-@dirrm lib/xorg
+@dirrmtry lib/xorg/modules/extensions
+@dirrmtry lib/xorg/modules/linux
+@dirrmtry lib/xorg/modules/multimedia
+@dirrmtry lib/xorg/modules
 @dirrmtry include/X11/bitmaps
 @dirrmtry include/X11/pixmaps
 @dirrmtry lib/X11/doc
Index: x11/nvidia-driver/Makefile
===================================================================
RCS file: /home/pcvs/ports/x11/nvidia-driver/Makefile,v
retrieving revision 1.107
diff -u -r1.107 Makefile
--- x11/nvidia-driver/Makefile	23 May 2011 07:14:50 -0000	1.107
+++ x11/nvidia-driver/Makefile	5 Jul 2011 05:30:12 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	nvidia-driver
 DISTVERSION?=	270.41.19
-PORTREVISION?=	0			# As a reminder it can be overridden
+PORTREVISION?=	1			# As a reminder it can be overridden
 CATEGORIES=	x11 kld
 MASTER_SITES=	${MASTER_SITE_NVIDIA}
 # MASTER_SITE_SUBDIR has to be set later because it depends on NVVERSION
@@ -67,11 +67,7 @@
 
 .include <bsd.port.pre.mk>
 
-XSERVVERSION!=	${PKG_INFO} -qO x11-servers/xorg-server 2>/dev/null || true
-LIBGLVERSION!=	${PKG_INFO} -qO graphics/libGL 2>/dev/null || true
-
-PLIST_SUB+=	XSERVVERSION=${XSERVVERSION} LIBGLVERSION=${LIBGLVERSION} \
-		LINUXBASE=${LINUXBASE} SHLIB_VERSION=${PORTVERSION} \
+PLIST_SUB+=	LINUXBASE=${LINUXBASE} SHLIB_VERSION=${PORTVERSION} \
 		MODULESDIR=${MODULESDIR}
 
 .if !defined(WITHOUT_LINUX)
@@ -93,6 +89,10 @@
 LIB_DEPENDS+=	m.3:${PORTSDIR}/misc/compat5x
 .endif
 
+post-extract:
+	@(cd ${WRKSRC}/obj; ${MV} -f libGL.so.1 libGL-nvidia.so.1; \
+		${MV} -f libglx.so.1 libglx-nvidia.so.1)
+
 post-patch: .SILENT
 # We should support -CURRENT: kill the check
 	${REINPLACE_CMD} -e '24,26d' ${WRKSRC}/src/nv-freebsd.h
@@ -138,6 +138,12 @@
 .endif
 # Do not execute afterinstall target (prevent automatic module registration)
 	${REINPLACE_CMD} -e 's/afterinstall/dontexecute/' ${WRKSRC}/Makefile
+# Don't remove libGL or xorg-server libraries or links during beforeinstall:
+# either they no longer collide after the nvidia library name changes, or they
+# are altered in post-install
+	${REINPLACE_CMD} -e \
+		'/FIND_FILES!=/,/ECHO/{s/libGL/&-nvidia/;s/libglx/&-nvidia/;}' \
+		${WRKSRC}/lib/Makefile
 
 pre-su-install:
 # While this port silently assumes PREFIX == LOCALBASE, at least try to
@@ -162,6 +168,7 @@
 	${REINPLACE_CMD} -E 's/libGLcore/libnvidia-glcore/ ; \
 		/usr.*(glcore|tls).*so\.1$$/d' ${TMPPLIST}
 .endif
+	${LN} -sf libglx.so.1 ${PREFIX}/${MODULESDIR}/extensions/libglx.so
 # Some applications need this symlink (see PR ports/72877)
 	${LN} -sf libXvMCNVIDIA.so.1 ${PREFIX}/lib/libXvMCNVIDIA_dynamic.so.1
 	${ECHO_MSG}
Index: x11/nvidia-driver/pkg-plist
===================================================================
RCS file: /home/pcvs/ports/x11/nvidia-driver/pkg-plist,v
retrieving revision 1.29
diff -u -r1.29 pkg-plist
--- x11/nvidia-driver/pkg-plist	21 May 2011 14:04:48 -0000	1.29
+++ x11/nvidia-driver/pkg-plist	5 Jul 2011 00:54:57 -0000
@@ -1,11 +1,7 @@
-@exec mv -f %D/%%MODULESDIR%%/extensions/libglx.la %D/%%MODULESDIR%%/extensions/XXX-libglx.la.%%%%.%%XSERVVERSION%%
-@unexec mv -f %D/%%MODULESDIR%%/extensions/XXX-libglx.la.%%%%.%%XSERVVERSION%% %D/%%MODULESDIR%%/extensions/libglx.la
-@exec mv -f %D/%%MODULESDIR%%/extensions/libglx.so %D/%%MODULESDIR%%/extensions/XXX-libglx.so.%%%%.%%XSERVVERSION%%
-%%MODULESDIR%%/extensions/libglx.so
-@unexec mv -f %D/%%MODULESDIR%%/extensions/XXX-libglx.so.%%%%.%%XSERVVERSION%% %D/%%MODULESDIR%%/extensions/libglx.so
-@exec mv -f %D/lib/libGL.so.1 %D/lib/XXX-libGL.so.1.%%%%.%%LIBGLVERSION%%
-lib/libGL.so.1
-@unexec mv -f %D/lib/XXX-libGL.so.1.%%%%.%%LIBGLVERSION%% %D/lib/libGL.so.1
+lib/libGL-nvidia.so.1
+@exec ln -sf %f %B/libGL.so.1
+@comment On removal, restore the link between libGL.so.1 and libGL, if the latter is present:
+@unexec if [ -f %B/libGL-mesa.so.1 ] ; then ln -sf libGL-mesa.so.1 %B/libGL.so.1 ; else rm -f  %B/libGL.so.1 ; fi
 lib/libnvidia-tls.so.1
 lib/libnvidia-tls.so
 lib/libnvidia-cfg.so.1
@@ -22,7 +18,10 @@
 %%MODULESDIR%%/libnvidia-wfb.so.1
 %%MODULESDIR%%/drivers/nvidia_drv.so
 %%MODULESDIR%%/extensions/libglx.so.1
-@exec ln -sf libglx.so.1 %D/%%MODULESDIR%%/extensions/libglx.so
+@exec ln -sf %f %B/libglx.so
+@comment On removal, restore the link between glx.so and the xorg-server, if the latter is present:
+@unexec if [ -f %B/libglx-xorg.so ] ; then ln -sf libglx-xorg.so %B/libglx.so ; else rm -f %B/libglx.so ; fi
+%%MODULESDIR%%/extensions/libglx-nvidia.so.1
 @dirrmtry %%MODULESDIR%%/drivers
 @cwd /boot/modules
 nvidia.ko
Index: x11/nvidia-driver/files/patch-lib__libGL__Makefile
===================================================================
RCS file: x11/nvidia-driver/files/patch-lib__libGL__Makefile
diff -N x11/nvidia-driver/files/patch-lib__libGL__Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ x11/nvidia-driver/files/patch-lib__libGL__Makefile	3 Jul 2011 20:24:33 -0000
@@ -0,0 +1,10 @@
+--- lib/libGL/Makefile.orig	2011-04-14 04:15:43.000000000 -0400
++++ lib/libGL/Makefile	2011-07-03 16:22:50.000000000 -0400
+@@ -6,5 +6,7 @@
+ LIB=		GL
+ SHLIB_MAJOR=	1
+ LIBDIR=		${X11BASE}/lib
++SHLIB_LINK=	lib${LIB}.so.${SHLIB_MAJOR}
++SHLIB_NAME=	lib${LIB}-nvidia.so.${SHLIB_MAJOR}
+ 
+ .include <${NVIDIA_ROOT}/mk/nvidia.lib.mk>
Index: x11/nvidia-driver/files/patch-x11__extension__Makefile
===================================================================
RCS file: x11/nvidia-driver/files/patch-x11__extension__Makefile
diff -N x11/nvidia-driver/files/patch-x11__extension__Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ x11/nvidia-driver/files/patch-x11__extension__Makefile	4 Jul 2011 02:18:35 -0000
@@ -0,0 +1,10 @@
+--- x11/extension/Makefile.orig	2011-07-03 16:28:26.000000000 -0400
++++ x11/extension/Makefile	2011-07-03 16:29:29.000000000 -0400
+@@ -11,5 +11,7 @@
+ .else
+ LIBDIR=		${X11BASE}/lib/modules/extensions
+ .endif
++SHLIB_LINK=	lib${LIB}.so.${SHLIB_MAJOR}
++SHLIB_NAME=	lib${LIB}-nvidia.so.${SHLIB_MAJOR}
+ 
+ .include <${NVIDIA_ROOT}/mk/nvidia.lib.mk>
Index: x11/nvidia-driver-71/Makefile
===================================================================
RCS file: /home/pcvs/ports/x11/nvidia-driver-71/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- x11/nvidia-driver-71/Makefile	21 May 2011 14:04:48 -0000	1.19
+++ x11/nvidia-driver-71/Makefile	4 Jul 2011 23:43:15 -0000
@@ -6,7 +6,7 @@
 #
 
 DISTVERSION=	71.86.14
-PORTREVISION=	2
+PORTREVISION=	3
 
 MASTERDIR=	${.CURDIR}/../nvidia-driver
 NO_LATEST_LINK=	yes
Index: x11/nvidia-driver-96/Makefile
===================================================================
RCS file: /home/pcvs/ports/x11/nvidia-driver-96/Makefile,v
retrieving revision 1.20
diff -u -r1.20 Makefile
--- x11/nvidia-driver-96/Makefile	21 May 2011 14:04:48 -0000	1.20
+++ x11/nvidia-driver-96/Makefile	4 Jul 2011 23:43:37 -0000
@@ -6,7 +6,7 @@
 #
 
 DISTVERSION=	96.43.19
-PORTREVISION=	2
+PORTREVISION=	3
 
 MASTERDIR=	${.CURDIR}/../nvidia-driver
 NO_LATEST_LINK=	yes

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGFTUwPHREj=oucqCihCpYB%2BzdZR3Vtkztaod9EbV2SaP679HA>