Switch makefiles to use libtool to build libmysqld.so, as well as all its dependencies.
The previous MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS() declaration is removed, as it does not work well with a libtool build. Instead, plugins that need it can specify an alternate object in MYSQL_PLUGIN_STATIC() that will be used for embedded library. The plugin must then take care itself of compiling the special object for embedded, rebuilding the source files previously listed in MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS() with @plugin_embedded_defs@ in CFLAGS/CXXFLAGS. The extra target @XXX_embedded_static_target@ is available for the special object, this will be empty when --without-embedded-server.
The plugin may optionally specify @plugin_static_if_no_embedded@ in CFLAGS/CXXFLAGS for the static target; this will avoid needlessly compiling with -fPIC if no libmysqld is being built.
All in-tree plugins are changed to build their static targets with libtool. Additional plugins that want to work with libmysqld.so will need to be similarly modified to build with libtool (or otherwise provide an -fPIC object). Dynamically loaded plugins are not affected.
The old MariaDB installs static libraries for certain built-in plugins like myisam, heap, etc. These libraries are still only build statically. The reason is that they contain unresolved symbols referencing code in mysqld (handler API eg.), and these unresolved symbols cause errors during loading for .so shared libraries (for .a static libraries there is no problem as long as only safe subsets of the static library is linked).
The old libmysqld.a was made to include all of libmysys, libmystrings, and libdbug, saving users from having to specify these in addition to -lmysqld. Despite much research and experiments, I did not find a way to get libtool to do something similar. This means that with this change, users may have to add these additional libraries to their link commands. For the same reason, client programs like mysqldump now by default link dynamically to libmysys.so (this could be considered an advantage of course). This behaviour can still be overridden with --with-client-ldflags=-static for example.
This patch only does what is necessary to build libmysqld.so. There are some more cleanups that are possible now that we are using libtool more fully, which will be done in subsequent patches:
- In libmysql_r/, we should be able to just link libmysys.la etc, instead of symlinking and re-compiling sources into the directory.
- In libmysql/, we can similarly avoid symlinking and recompiling sources if we instead build a libmysys_nothread.la library with appropriate CFLAGS and link that.
- In sql/, we can build a separate target libmysql_int.la with appropriate CFLAGS for embedded and use that in libmysqld/ instead of symlinking sources.