-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify version (soname) for foreign-library #4052
Comments
Seems reasonable. |
OK, as requested on IRC.
Don't forget to add a test. |
Let's think about cross-platform issues. Suppose we're writing a library ELF binaries typically have versions x.y.z, sometimes x.y.z.w. Here, x.y defines compatibility. For version 3.2.1, we'd get a Mach-O binaries have a (usually single-digit) major version in the filename (e.g. 3 in libfoo.3.dylib). This is stored in the PE binaries. I haven't quite been able to figure out what the status quo is here. But I haven't been able to find a consistent file naming scheme. You can apparently set a version field in the binary, and it can have basically any value. Especially given the difference between ELF and Mach-O, I think it'd be wise to play safe and only implement a scheme for ELF here: so perhaps the field should be called However, if we're willing to restrict the user in a number of ways, we could say that we take the version to be of the form x.y.z(.w), and set the Mach-O major version to be x, its compatibility version to be x.0.0(.0), and its current version to be x.y.z(.w). And then we don't do any renaming for PE, but we simply store the input version in the relevant field in the binary. |
Adding to the previous, on Windows one can use module definition files to set the version of a library. And module definition files are already supported by cabal. So to me that reinforces the idea that library versioning is a per-platform thing. |
OK, makes sense to me! |
After some more googling, it seems that asking for a libtool-style On linux, On other unix-style operating systems, the rules differ, but are usually similar to the ones on linux, and there is some agreed rule on how this should be done (although figuring out that rule might require some research and asking around). EDIT: This does not take away from the fact that for now I'm only intending to support Linux - but at least this scheme could be applied to some other OSes, notably *BSDs, and possibly OSX. |
More opinions on the following question are welcome: how are developers supposed to specify library versions? One option is a libtool-style version-info field (with current[:revision[:age]]). Another is to fill in the fields directly (e.g. a soversion field that gets appended to the libfoo.so filename).
Arguments againts include:
There is also the possibility of offering both a libtool-style version-info field, and a field for forcing the specific fields on various platforms (possibly with different names for each field on each platform), and raising an error if both are specified. For now the support will be Linux-only. (Unless somebody is able to do other platforms.) CC @christiaanb |
I asked Reddit for some comments: https://www.reddit.com/r/haskell/comments/5bkhth/request_for_comment_specifying_versions_soname/ |
I want to note that I only know enough about dynamic linking to fix bugs... not really an expert on conventions. Regardless, I seems that version specification is way different on OS X compared to linux, as you can see here (sorta): http://stackoverflow.com/a/32280483 Although you indicate you only want to support Linux for now (which is something I strongly encourage), someday, someone might want to add OS X (or other OS) support. It would then be quite nice if he/she wouldn't have to bikeshed with the other Cabal developers a new top-level entry for the So I propose something like:
And then when the OS X implementation person comes along, all he/she has to do is add a new sub-category for the CC @mchakravarty given that he does commercial OS X development, while I mostly use my Mac just for web browsing these days. |
As @christiaanb suggests, I am strongly in favour of distinguishing platform-specific version information. At least, I don't see a good way to combine the Mach-O/macOS/iOS versioning scheme with the Linux one. |
Thanks for the reddit post and your contributions here so far! Your ideas are agreeable to me, but there are a few things that require some arbitrary decision in this setup - so I'd like to leave it up to you to bikeshed about that. For example: What to do if someone attempts to build on OSX when only Linux version data is provided? Is this a configure error, or do we ignore version data? What if both libtool and linux version data is provided? If we set a version of 3.2.1 on Linux for a foreign library |
Just commenting on the OS X bit: I assume we would still have to provide the current Anyhow, under the assumption we will still have the
|
@christiaanb: do you mean the anyway, sure, if OS-specific versions are used, and we're building on an OS that doesn't have the version, we'll just build without version data. @ezyang, could you give a few hints on parsing @christiaanb's syntax above? |
@christiaanb's proposed syntax is not going to be very easy to parse in Cabal's existing framework; I don't think we have anything that looks like it. If this is what we end up doing, we should just have separate fields for each of the subfields. (Extra benefit: you can conditionalize over them.) |
#4074 has been merged. |
Currently, when a foreign-library with the name "foo" is specified, it is built and installed as
libfoo.so
.It would be nice if we could additionally specify the version of the library.
One possibilty is to allow specifying a
version
field with a value like1.2
, such that the SONAME would becomelibfoo.so.1.2
.From this version, cabal would then generate the appropriate symlinks (
libfoo.so.1.2
andlibfoo.so
linking tolibfoo.so.1
, I believe).Alternatively we could just make the SONAME configurable directly. But then we can't really generate symlinks.
On Windows, one only versions shared objects by filename. So cabal should merely modify that in this case.
CC @edsko @dcoutts @ezyang
The text was updated successfully, but these errors were encountered: