ABI versioning idea



I got an idea about ABI versioning in Gtk+ today. I'm not sure its a
good idea, but its sort of interesting so I thought I'd share it.

We have long thought that using ELF symbol versioning in Gtk+ is
undoable, since it would mean that a change in behaviour in e.g
GtkWidget would mean new entry points for all widget functions. However,
remembering things the Gtk+ 2.2 change that broke libgnomeui its clear
that it would be nice to have some sort of versioning such that we could
have fixed Gtk+ 2.2 without breaking apps that linked against Gtk+ 2.0.

The idea I had was about how this could be done. What we do is add
versioning to one single function, say gtk_init like this:

int gtk_runtime_version = 0;

void
gtk_init_version(int *argc,  char ***argv, int binary_age)
{
   gtk_runtime_version = MIN(gtk_runtime_version, binary_age)
   gtk_init_real(argc, argv);
}
void
gtk_init::2.6.4(int *argc,  char ***argv) 
{
   gtk_init_version(argc, argv, 604);
}
void
gtk_init::2.6.3(int *argc,  char ***argv) 
{
   gtk_init_version(argc, argv, 603);
}
... more autogenerated versions of this ...
void
gtk_init::unversioned(int *argc, char ***argv)
{
   gtk_init_version(argc, argv, LAST_UNVERSIONED_VERSION);
}

And if we do change ABI in a backwards incompatible way we can wrap it
in runtime checks against gtk_runtime_version. This way an application
that linked to a specific version of Gtk+ won't get the backward
incompatible changes, while if you relink you get them.

This mostly only works for apps, since they are the ones that call
gtk_init(). However one could introduce a gtk_version_init() call that
just sets the runtime version and call this from the library. You'd then
get the runtime behaviour that matches the library linked to the
earliest version of gtk+.

Not all apps call gtk_init. Perhaps there is some other symbol that
could be used instead.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an old-fashioned neurotic waffle chef who dotes on his loving old ma. 
She's a cold-hearted bisexual museum curator from a different time and place. 
They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]