Mark Janes [Fri, 12 Sep 2014 23:16:38 +0000 (16:16 -0700)]
Add glaze-find-libegl programs.
To preparation for supporting EGL interposition, add 32 and 64 bit
variants of glaze-find-libegl. glaze-find-libegl is analogous to the
existing glaze-find-libgl, and has identical usage/function.
Carl Worth [Mon, 23 Sep 2013 19:57:49 +0000 (12:57 -0700)]
Add support for multiple Glaze wrappers to be used at the same time.
We simply use a colon-separated specification of the wrappers in
GLAZE_WRAPPER and hold on to an array of dlopened handles.
It's a simple matter to use the array of handles in several places.
The one place that involves some delicacy is glaze_lookup. Here we
must ensure that one wrapper's wrapped implementation of a function
chains to the subsequent wrapper and not to itself (which would lead
to infinite recursion). To get this right, we inspect the backtrace
and refuse to let glaze_lookup return a function that already appears
in the backtrace.
Carl Worth [Mon, 23 Sep 2013 15:16:27 +0000 (08:16 -0700)]
Teach libglaze to look for wrapper library in current working directory
Previously, with libfoo.so in the current directory, the following
command would fail:
glaze --wrapper=libfoo.so <program> <args>
And to fix things, the user would have to explicitly name the current
working directory such as:
glaze --wrapper=./libfoo.so <program> <args>
That seems like a silly requirement, (and is an artefact if the logic
of the dynamic loader).
To allow the convenient usage (without "./") we teach libglaze to
explicitly look for the wrapper in the current working directory, and
if found, to resolve its absolute path.
Carl Worth [Mon, 23 Sep 2013 14:00:51 +0000 (07:00 -0700)]
Fix segmentation fault if GLAZE_LIBGL is set to empty string
Previosuly, we would catch and report an unset GLAZE_LIBGL variable
with a clean error message so that the user would know to set this
variable. Similarly, if the variable was set to an incorrect filename,
that would also result in a good error message.
But, if the user happened to set GLAZE_LIBGL to an empty string, then
Glaze would march on and end up triggering the dlsym behavior where a
NULL handle results in a lookup in the local program. This would then
trigger infinite recursion in the resolving of the ifunc symbol and a
not-very-useful segfault.
We avoid all that by noticing the empty string up front and giving the
user the useful error message.
Carl Worth [Sat, 21 Sep 2013 22:12:24 +0000 (15:12 -0700)]
Add specs/README
Previously, the only documentation for where the XML files came from
was in commit messages. Fix this by adding specs/README which explains
where the XML files came from, their license, the script that
processes them, etc.
Carl Worth [Sat, 21 Sep 2013 21:56:54 +0000 (14:56 -0700)]
Remove obsolete glapi.def file
The glapi.def file was originally created as a simple stub during the
development of the GLAZE_API ifunc-creating macros. This file has been
obsolete since commit c06f006c64765 which generates a complete gl.def
file from the XML description of the OpenGL interface. It's just that
we neglected to delete the glapi.def file at that time. We fix that by
actually removing it now.
Since applications can use these functions to find their symbols, it's
important that Glaze intercept these and ensure that the appropriate
wrapped symbols are returned.
This implementation allows the wrapping library to optionally
implement glXGetProcAddress itself. If it does, it's responsible for
implementing it correctly.
If the wrapping library does not implement glXGetProcAddress, then
Glaze's version will return a symbol from the wrapper if any
exists. Otherwise, it will defer to the underlying glXGetProcAddress
to do whatever it needs to do.
Carl Worth [Sat, 21 Sep 2013 16:18:26 +0000 (09:18 -0700)]
Install symlinks from libGL.so to libGL.so.1
An application that is directly linked will already be pointing to libGL.so.1,
but an application that is using dlopen will likely look for a file named
"libGL.so" so we need to install this symlink for those to work as well.
Carl Worth [Sat, 21 Sep 2013 16:05:23 +0000 (09:05 -0700)]
Fix misleasing error message for unset GLAZE_WRAPPER variable.
The previous error message was apparently copy-pasted from the GLAZE_LIBGL
error message. Fix it to indicate that GLAZE_WRAPPER should point to the
user's wrapper library, not the underlying libGL.so.
Carl Worth [Sat, 21 Sep 2013 16:02:26 +0000 (09:02 -0700)]
Install a libglaze-32.so library along with a glaze-32.pc file.
This is the helper library that Glaze-using libraries can link against.
Previously, it was only compiled in a native version (named libglaze.so).
Now, we compile a 64-bit version named libglaze.so and a 32-bit version
named libglaze-32.so.
Carl Worth [Wed, 4 Sep 2013 23:44:44 +0000 (16:44 -0700)]
Add function glaze_set_first_gl_call_callback
This allows the wrapper to specify a callback to be called once OpenGL
is first initialized, (without the wrapper library needing to predict
what the name of the first GL function called might be, nor needing to
wrap all OpenGL calls just in order to intercept the first one).
Carl Worth [Thu, 29 Aug 2013 22:25:09 +0000 (15:25 -0700)]
Remove dependency of libglaze on libelf
The dependency is onerous since it requires the user of Glaze to have
both a 32-bit and 64-bit development version of libelf available, (and
also have a toolchain ready to find either one as appropriate).
Meanwhile, the only thing we were doing with libelf was determining
whether the current library targets a 32-bit or a 64-bit
architecture. But we are compiling this code twice, once for each
architecture. So it is actually quite simple to just conditionally
compile in the value we want.
Carl Worth [Fri, 23 Aug 2013 23:32:29 +0000 (16:32 -0700)]
Add a glaze_execute function to libglaze
This function takes care of all of the magic needed in order to use Glaze.
With this function, the caller need not set the environment variables
such as LD_LIBRARY_PATH, GLAZE_WRAPPER, and GLAZE_LIBGL that would
otherwise need to be set in order to use Glaze.
In some cases, (such as when the "program" passed to glaze_execute is
a script that forces an alternate libGL.so.1 to be loaded), the user
may still need to set GLAZE_LIBGL to the absolute path of the correct,
underlying libGL.so.1 providing the implementation of OpenGL.
Carl Worth [Fri, 23 Aug 2013 23:24:37 +0000 (16:24 -0700)]
Add a simple helper program to find libGL.so.1
This allows us to directly inspect the final result of all of the
loader's search-path logic without us needing to implement a
compatible version of that logic ourselves, (which is more than
trivial).
Carl Worth [Thu, 22 Aug 2013 00:32:35 +0000 (17:32 -0700)]
Add a more useful error message if dlopen fails
Previously, we were printing only the name of the library that we failed to
open. Now, we also print the underlying cause for the failure, (as reported
by dlerror).
Carl Worth [Thu, 22 Aug 2013 00:28:49 +0000 (17:28 -0700)]
Use "gcc --print-multiarch" to determine directory names for library installs
Previously, we had hardcoded names of lib32 and lib64. Instead, we now
ask gcc for the actual triple being targeted, (such as, for example,
lib/i386-linux-gnu or lib/x86_64-linux-gnu).
Using these correct names means that the user of Glaze can put a
literal $LIB into LD_PRELOAD or LD_LIBRARY_PATH and the run-time
linker will expand that to the correct name based on the architecture
of the program being linked
Carl Worth [Thu, 22 Aug 2013 00:15:41 +0000 (17:15 -0700)]
Don't compile 32- or 64-bit components when not supported
The configure script is already kind enough to detect whether we can
compile 32-bit- or 64-bit-specific components. Now, fix the Makefile
to actually pay attention and not try to compile something which we
know will not work.
Carl Worth [Mon, 12 Aug 2013 21:09:58 +0000 (14:09 -0700)]
Add a new libglaze library
So far this is simply a glaze_lookup function which uses GLAZE_LIBGL
to find libGL.so, then does a dlopen on that, and then a dlsym for the
function name of interest.
Carl Worth [Mon, 12 Aug 2013 20:18:37 +0000 (13:18 -0700)]
Add a configure script
The primary motivation is a new install target. And it's just plain
rude to provide an install target without also supporting --prefix and
DESTDIR, so we need this simple configure script at least.
Carl Worth [Mon, 12 Aug 2013 19:22:00 +0000 (12:22 -0700)]
Rename glaze.c to glaze-gl.c
I'm planning to add a new glaze library with a "glaze.h" header file,
so it will be natural to have its implementation in glaze.c. To
prepare for that, I'm renaming the OpenGL API implementation from
glaze.c to glaze-gl.c.
Carl Worth [Mon, 29 Jul 2013 22:04:21 +0000 (15:04 -0700)]
Add a README file
Documenting how to set LD_LIBRARY_PATH, GLAZE_WRAPPER, and GLAZE_LIBGL
for invoking Glaze. Also giving credit to Alexander Monakov for
teaching me how to ue ifuncs.
Carl Worth [Mon, 29 Jul 2013 21:25:55 +0000 (14:25 -0700)]
Add GLAZE_WRAPPER variable to specify library with OpenGL wrapper functions
The GLAZE_WRAPPER environment variable should point to a library which
has symbols for some subset of the OpenGL API. For all such symbols,
Glaze will resolve its ifunc symbols to the wrapper functions. For all
functions not having symbols in the GLAZE_WRAPPER library, Glaze will
resolve its ifunc symbols to the functions in the GLAZE_LIBGL library.
Along with a script and Makefile to convert it to the list form
expected by glaze.c.
Note: The Makefile to perform the conversion is not called by
default. Instead, the result of the conversion (gl.def) is committed
directly to the source repository. This makes it convenient, (the
general user does not need to install xmlstarlet, for example), while
a developer that does need to update gl.xml can simply invoke "make
clean; make" in the specs directory to rebuild gl.def.