]> git.cworth.org Git - glaze/log
glaze
9 years agoAdd egl definitions and related buildsupport. master
Mark Janes [Fri, 12 Sep 2014 23:16:39 +0000 (16:16 -0700)]
Add egl definitions and related buildsupport.

For each supported API, glaze-gl.c requires a definition file which
formats interposable function names in a series of macro invocations.

 * Add egl.xml, downloaded from http://www.opengl.org/registry/ as
   specified in the specs README.

 * Append support for egl.def code generation to the specs makefile.

 * Add egl.def as a prerequisite for libGL.so.1

9 years agoAdd glaze-find-libegl programs.
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.

9 years agoFix loose ends in build support.
Mark Janes [Fri, 12 Sep 2014 23:16:37 +0000 (16:16 -0700)]
Fix loose ends in build support.

Add the following items to the glaze Makefile:

 * Clean up libglaze.so in clean target

 * Add dependency to rebuild libGL.so.1 if any of the .def files have
   been changed.

 * Add a distclean target.

 * Add a check-syntax target to allow emacs flymake.

9 years agoAdd a version script for libglaze
Carl Worth [Tue, 24 Sep 2013 22:38:45 +0000 (15:38 -0700)]
Add a version script for libglaze

Explicitly listing the very few functions we want to export globally
in libfips.so, ensuring that everything else is kepy local.

10 years agoAdd support for multiple Glaze wrappers to be used at the same time.
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.

10 years agoTeach libglaze to look for wrapper library in current working directory
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.

10 years agoAdd a simple helper program, glaze
Carl Worth [Mon, 23 Sep 2013 15:13:22 +0000 (08:13 -0700)]
Add a simple helper program, glaze

This program allows for a user of glaze to simply execute:

glaze --wrapper=mywrapper.so <program> <args>

which is a fair bit easier than setting all of LD_LIBRARY_PATH,
GLAZE_LIBGL, and GLAZE_WRAPPER to achieve the same result.

10 years agoRename glaze.c to libglaze.c
Carl Worth [Mon, 23 Sep 2013 14:48:27 +0000 (07:48 -0700)]
Rename glaze.c to libglaze.c

This is in preparation for a new main program named, simply, glaze
which will be implemented in glaze.c.

10 years agoFix segmentation fault if GLAZE_LIBGL is set to empty string
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.

10 years agoAdd specs/README
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.

10 years agoRemove obsolete glapi.def file
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.

10 years agoImplement glXGetProcAdddress (and glXGetProcAddressARB)
Carl Worth [Sat, 21 Sep 2013 18:34:47 +0000 (11:34 -0700)]
Implement glXGetProcAdddress (and glXGetProcAddressARB)

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.

10 years agoInstall symlinks from libGL.so to libGL.so.1
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.

10 years agoFix misleasing error message for unset GLAZE_WRAPPER variable.
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.

10 years agoInstall a libglaze-32.so library along with a glaze-32.pc file.
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.

10 years agoDon't try to install 32- or 64-bit libraries if not compiled.
Carl Worth [Wed, 4 Sep 2013 23:48:53 +0000 (16:48 -0700)]
Don't try to install 32- or 64-bit libraries if not compiled.

We only conditionally compile these libraries, so we should also only
conditionally install them.

10 years agoAdd function glaze_set_first_gl_call_callback
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).

10 years agoAdd hard-coded library directory paths for systems without --print-multiarch
Carl Worth [Thu, 29 Aug 2013 22:35:18 +0000 (15:35 -0700)]
Add hard-coded library directory paths for systems without --print-multiarch

Apparently, the very convenient "gcc --print-multiarch" option is something
that Debian and Ubuntu have patched into gcc.

For other systems, we hard-code either "i386-linux-gnu" or
"x86_64-linux-gnu" and warn the user to fix things up if those are
wrong.

10 years agoRemove dependency of libglaze on libelf
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.

10 years agoAdd a glaze_execute function to libglaze
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.

10 years agoAdd a simple helper program to find libGL.so.1
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).

10 years agoAdd a more useful error message if dlopen fails
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).

10 years agoUse "gcc --print-multiarch" to determine directory names for library installs
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

10 years agoDon't compile 32- or 64-bit components when not supported
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.

10 years agoMakefile: Fix to enable compiler warnings
Carl Worth [Tue, 20 Aug 2013 23:11:31 +0000 (16:11 -0700)]
Makefile: Fix to enable compiler warnings

The configure script was carefully detecting available warning options, but
the Makefile was neglecting to actually use them when compiling.

Fix so that we get useful warning messages.

10 years agoAdd a new libglaze library
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.

10 years agoAdd a configure script
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.

10 years agoRename glaze.c to glaze-gl.c
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.

10 years agoAdd a README file
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.

10 years agoAdd GLAZE_WRAPPER variable to specify library with OpenGL wrapper functions
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.

10 years agoAdd GLX functions as well.
Carl Worth [Thu, 25 Jul 2013 03:16:36 +0000 (20:16 -0700)]
Add GLX functions as well.

The glx.xml file was downloaded from:

https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/glx.xml

And should be current as of OpenGL 4.4.

10 years agoExtend OpenGL API list to all functions in Khronos gl.xml
Carl Worth [Thu, 25 Jul 2013 00:33:18 +0000 (17:33 -0700)]
Extend OpenGL API list to all functions in Khronos gl.xml

Here we add the gl.xml file downloaded from:

https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml

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.

10 years agoInitial commit of glaze, a thin, shiny wrapper for OpenGL
Carl Worth [Wed, 24 Jul 2013 23:48:02 +0000 (16:48 -0700)]
Initial commit of glaze, a thin, shiny wrapper for OpenGL

The basic mechanic is in place here to create a pass-through ifunc for
every function in a list of functions.

The current list is the tiniest stub so far, (nothing but glClear).

And there is not yet any mechanism to do selective substitution of any
OpenGL functions, (so glaze cannot actually be used for anything yet).