[xcb] XCL as drop-in Xlib replacement

xcb@nickle.org xcb@nickle.org
Sat, 7 Sep 2002 23:56:54 -0700


--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

So Bart says Keith really wants a complete Xlib-compatible XCL, as
soon as he can get it. Fair enough. As a first step, I've taken a
look at inter-library dependencies.

Background: A major goal of XCB and XCL is to reduce code size, both
the amount resident on disk and that in RAM. To that end, I'd like
XCL's implementation of Xlib to be split across several libraries.
In the future, I'd hope most of the libraries wouldn't be used, and
so users could choose not to install them at all. However, I'd also
like to allow XCL to be installed on a system running Xlib-compiled
apps, and have all those apps immediately gain some of XCL's benefits.

The approach proposed for this has been to create a "libX11.so" that
contains no functions, but is linked against all the other XCL
libraries. So I wrote some simple libraries and an application to
call into them, then checked that this idea would at least work in
Linux.

Please find attached the tarball with this test code and the output
from building and running it. Note that the 'old' directory contains
the functions in a single library, while the 'new' directory splits
them across two libraries.

Judging by my tests, the idea is sound. The only problem arises when
running the version of the test program that was linked against
'new', while using the libraries found in 'old'. This corresponds to
building an application on a system using XCL, then trying to run
that application on an Xlib-based system. The reason is pretty clear:

~/test/libdep$ objdump -p main-old | grep NEEDED
  NEEDED      libdep1.so
  NEEDED      libc.so.6
~/test/libdep$ objdump -p main-new | grep NEEDED
  NEEDED      libdep1.so
  NEEDED      libc.so.6
  NEEDED      libdep2.so
~/test/libdep$

If the linker hadn't recorded the dependency on libdep2.so at compile
time, at run-time the system would have no trouble figuring out what
to do, no matter which version was used. Sigh.

In any case, I guess I've established that this will do for now, and
that we can probably find a way to make it work perfectly later. So
I'll start looking for the chunks of Xlib that can already be used to
create some of these new libraries. I believe that significant parts
of Xlib are independent of the 'lower layer' as we described it in
the XCL paper, and can be used unchanged. I plan to take advantage of
that to get most of XCL written very quickly.
-- 
Jamey Sharp <jamey@sharp.ath.cx> - http://jamey.is.dreaming.org/

--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="libdep.script"

~/test/libdep$ make run
make -C old
make[1]: Entering directory `/home/jamey/test/libdep/old'
gcc -Wall -I.. -shared -o libdep1.so libdep1.c
make[1]: Leaving directory `/home/jamey/test/libdep/old'
gcc -Wall -o main-old main.c -Lold -ldep1
make -C new
make[1]: Entering directory `/home/jamey/test/libdep/new'
gcc -Wall -I.. -shared -o libdep2.so libdep2.c -L. -Wl,-rpath=`pwd`
gcc -Wall -I.. -shared -o libdep1.so libdep1.c -L. -Wl,-rpath=`pwd` -ldep2
make[1]: Leaving directory `/home/jamey/test/libdep/new'
gcc -Wall -o main-new main.c -Lnew -ldep1
LD_LIBRARY_PATH=old ./main-old
entering main
libdep version: old
called libdep2
called libdep2
leaving main
LD_LIBRARY_PATH=new ./main-old
entering main
libdep version: new
called libdep2
called libdep2
leaving main
LD_LIBRARY_PATH=new ./main-new
entering main
libdep version: new
called libdep2
called libdep2
leaving main
LD_LIBRARY_PATH=old ./main-new
./main-new: error while loading shared libraries: libdep2.so: cannot open shared object file: No such file or directory
make: [run-new] Error 127 (ignored)
~/test/libdep$ 

--VbJkn9YxBvnuCH5J
Content-Type: application/x-gtar
Content-Disposition: attachment; filename="libdep.tgz"
Content-Transfer-Encoding: base64

H4sIAF3rej0AA+2ZXU/bMBSGe1v/Cqvjoq2WYjtxInWAxoANpA4QQ0JcQZYGmi0kVdrCpon/
PsdxWrcFumkkYeI8N0mOPxPnPbaPw+Br3x+u14qEEIs4nIsroQ4n+jWnJjKYNrc5ZyIfpabp
1DAvtFeKyWjsJhjXvrk3/s8n8q1K/08Js/H/7H73r4LQL6QNQgmxLeux8aeUmGr8ObcYFfmZ
Y9MaJoX0ZoFXPv47H3vbn75sGmduGKLernoKxT9BEUomUReLBCxujDjsy2vk3yEkjF184waZ
Wd5Ie27KEjse7gdJ+ozq156H15pZcy1sxHjtPV7bwEYvrWCtqZpuqSpEZXNVpJU/XoVInatC
NdpF9RvxX2NjB6ddQKoizSz7rF5Oe59pi0Zv96J38OFk++T84nj7dH8zTe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