Commit 26ab7b8a authored by Mihai Moldovan's avatar Mihai Moldovan

nxagent: implement RPATH/RUNPATH override for libX11.

As discussed in ArcticaProject/nx-libs#610, we need a way to load libNX_X11 as a fake version of libX11 into nxagent's address space. For doing so, we have to link against libX11 at build-time and specify a(n) RPATH/RUNPATH to our libX11 -> libNX_X11 compat symlinks. This commit is essentially doing a cross between options 3 and 4 discussed in the provided GH issue. We link libX11 early (before specifying -Lcompat_symlinks_dir), so that the linker finds the "real" libX11 version with the libX11 SONAME. This leads to our binary depending upon both libX11 and libNX_X11 SONAMEs. We already always added RPATH/RUNPATH, but these values are not passed down to dependent libraries. What happens at run-time is that the loader searches for a libX11 SONAME, takes RPATH/RUNPATH into account and loads our libNX_X11 library instead via the compat symlinks. This satisfies the libX11 SONAME and dependent libraries will *not* load the system libX11 version again. Debian's dpkg-shlibdeps isn't quite happy about this mismatching SONAME situation, so instruct to look the other way while we're minding our business. Fixes: ArcticaProject/nx-libs#610
parent e13e31f7
...@@ -124,5 +124,13 @@ override_dh_strip: ...@@ -124,5 +124,13 @@ override_dh_strip:
override_dh_makeshlibs: override_dh_makeshlibs:
dh_makeshlibs -n dh_makeshlibs -n
# Needed for the libX11 RUNPATH/RPATH link-time hack.
# dh_shlibdeps will follow dependencies within binaries and choke
# on the libX11 dependency, since the SONAME (libX11.*) used while linking
# does not match the later detected SONAME (libNX_X11.*) obtained through
# the libX11 -> libNX_X11 compat symlink.
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
get-orig-source: get-orig-source:
uscan --noconf --force-download --rename --download-current-version --destdir=.. uscan --noconf --force-download --rename --download-current-version --destdir=..
...@@ -1103,11 +1103,11 @@ CplusplusProgramTargetHelper(program,SRCS10,OBJS10,DEPLIBS10,locallib,syslib) ...@@ -1103,11 +1103,11 @@ CplusplusProgramTargetHelper(program,SRCS10,OBJS10,DEPLIBS10,locallib,syslib)
AllTarget(ProgramTargetName(server)) @@\ AllTarget(ProgramTargetName(server)) @@\
ProgramTargetName(server): subdirs objects libs @@\ ProgramTargetName(server): subdirs objects libs @@\
MoveToBakFile($@) @@\ MoveToBakFile($@) @@\
LinkRule($@,$(LDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\ LinkRule($@,$(SERVERLDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\
@@\ @@\
Concat(load,server): @@\ Concat(load,server): @@\
MoveToBakFile(ProgramTargetName(server)) @@\ MoveToBakFile(ProgramTargetName(server)) @@\
LinkRule(ProgramTargetName(server),$(LDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\ LinkRule(ProgramTargetName(server),$(SERVERLDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\
@@\ @@\
loadX:: Concat(load,server) @@\ loadX:: Concat(load,server) @@\
@@\ @@\
......
...@@ -1995,6 +1995,7 @@ XEXT_EXTRA_DEFINES = ...@@ -1995,6 +1995,7 @@ XEXT_EXTRA_DEFINES =
LDPRELIB = LdPreLib $(INSTALLED_LIBS) LDPRELIB = LdPreLib $(INSTALLED_LIBS)
LDPOSTLIB = LdPostLib LDPOSTLIB = LdPostLib
LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
SERVERLDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS)
CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
......
...@@ -319,6 +319,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \ ...@@ -319,6 +319,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \
-L../../../nxcompshad/src/.libs \ -L../../../nxcompshad/src/.libs \
-L../../lib/src/.libs \ -L../../lib/src/.libs \
-lrt \ -lrt \
-lX11 \
-lXcomp \ -lXcomp \
-lXcompshad \ -lXcompshad \
-lXrender \ -lXrender \
...@@ -334,6 +335,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \ ...@@ -334,6 +335,7 @@ NXAGENTNXLIBS = -L/usr/sfw/lib \
NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \ -L../../../nxcompshad/src/.libs \
-L../../lib/src/.libs \ -L../../lib/src/.libs \
-lX11 \
-lXcomp \ -lXcomp \
-lXcompshad \ -lXcompshad \
-lXrender \ -lXrender \
...@@ -349,6 +351,7 @@ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \ ...@@ -349,6 +351,7 @@ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \ -L../../../nxcompshad/src/.libs \
-L../../lib/src/.libs \ -L../../lib/src/.libs \
-lkvm \ -lkvm \
-lX11 \
-lXcomp \ -lXcomp \
-lXcompshad \ -lXcompshad \
-lXrender \ -lXrender \
...@@ -364,6 +367,7 @@ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \ ...@@ -364,6 +367,7 @@ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \ NXAGENTNXLIBS = -L../../../nxcomp/src/.libs \
-L../../../nxcompshad/src/.libs \ -L../../../nxcompshad/src/.libs \
-L../../lib/src/.libs \ -L../../lib/src/.libs \
-lX11 \
-lXcomp \ -lXcomp \
-lXcompshad \ -lXcompshad \
-lXrender \ -lXrender \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment