Closed chris-se closed 8 years ago
I will test your branch, but as long as it works fine I have no problem merging this request. Thank you for all your work!
Thanks a lot! While packaging open-isns (which I only started after sending this pull request) I found a couple of minor other things (typos in manpages, some minor build system things, default pid file of the discovery daemon, isnsd not handling isns not being in /etc/services
), should I send another pull request (then I'd have to wait until you've merged this one, as the build system stuff would otherwise conflict with this patch) or add them to this pull request?
I suggest a separate pull request. I'll merge this one soon. It builds for me with and without shared library.
I'm in the process of packaging open-isns for Debian (because I co-maintain open-iscsi there), and have noticed that open-isns only builds a static library. This is frowned upon in Debian (and many other distributions) for non-internal libraries, because every update (even security updates) would require a rebuild of all the software that uses them.
I've hence added support for optionally building a shared library to the open-isns build system. This is off by default, so without any additional options to
./configure
, the build will produce the same result as previously. Now, however,--enable-shared
can be specified, which will build a shared library. The diff is a quite large because I had to regenerateconfigure
, and I don't have the really old autotools version installed with which it was initially generated, inflating the changes.In following best practices for shared libraries, I've added a version script for symbol versioning. This has three advantages for the shared library (as compared to no symbol versioning):
isnsd
etc.) as internal (I've used the version tagLIBISNS_INTERNAL
), so that you advertise that these symbols shouldn't be used by anyone else and are not part of the official ABI (even though they are exported to be available from the open-isns binaries). This way it's easily possible to modify the ABI of those symbols without breaking external binary compatibility.The linker script I've added explicitly exports functions that are available in the public headers (with the
LIBISNS_0.96
version tag), plus the functions that are used by other isns binaries (with theLIBISNS_INTERNAL
version tag). All other functions are not exported (equivalent to-fvisibility=hidden
or__attribute__((visibility("hidden")))
) by using a catch-all rule in the linker script.Non-exported symbols
For completeness sake the following is a list of all functions and global variables that are not in the linker script of the shared library, and hence not exported. I've listed them here because it's maybe good to have an overview at the point in time when the shared library is added. At first, I'll list three categories where I think some improvements could be made (even though it's not strictly necessary).
Defined, but not used: The following symbols are defined in internal headers (or source files), but not used anywhere - and are not declared in external headers. Some of them could maybe be declared in public headers, while others could possibly be removed?
Static candidates: The following symbols are only used within a single source file, and should probably be declared as static (they appear to be helper functions called by other functions in the same source file):
Publicly exported, but internal: This function is declared in a public header, yet is so clearly internal that I've marked it as hidden and not exported it from the shared library anyway. In my opinion, it should probably be removed from the public header:
Internal symbols: These symbols really are internal, because they are only used within the library, but not from the outside. Anything in this category is supposed to be a hidden symbol in the shared library, so these are all where they are supposed to be:
As a follow-up, if you wish, I can open a pull request to remove
__isns_alloc_message
from public headers and declare all the candidates I've identified asstatic
. For the declared-but-not-used case one would have to go through the functions on a case-by-case basis and decide what to do, and I don't really know the code base well enough to make a judgment call on them. (But they are only a few, so it's perfectly fine to keep them around as hidden symbols for now.)But even without the possible additional changes of cleaning up some symbols (which isn't strictly required, just nice-to-have), it would be great if you could merge this pull request, so that building a shared library is now possible. (This is the only blocker that I have before packaging it for Debian.) Thanks!