Skip to content

rustc need a way to generate versioned libraries #22399

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

Closed
semarie opened this issue Feb 16, 2015 · 6 comments
Closed

rustc need a way to generate versioned libraries #22399

semarie opened this issue Feb 16, 2015 · 6 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. O-linux Operating system: Linux P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.

Comments

@semarie
Copy link
Contributor

semarie commented Feb 16, 2015

The traditionnal way for a package distribution system (think dpkg for Debian, or ports under OpenBSD) to copte with upgrade of shared libraries is to have libraries with versioned number like libfoo.so.MAJOR.MINOR.

The rational for OpenBSD could be found here: http://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs
It is designed for OpenBSD specifically, but it spots several issues and invalids solutions (like renaming the file after linking).

To resume the problem is (in the example of packaging rustc program):

  • I want to package rustc under OpenBSD.
  • rustc come with shared libs (libstd-4e7c5e5c.so for example).
  • the library isn't versioned.
  • so any futur upgrade of rustc package will break any compiled program that depends of libstd-4e7c5e5c.so (the file will change, some functions will changes, or be added or be removed).

Having versioned libraries permit the package distribution system to have, at the same time, multiple version of the same library (libstd-4e7c5e5c.so.1.0 and libstd-4e7c5e5c.so.3.1 for example), and having binaries that depend of differents versions.

@steveklabnik steveklabnik added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Feb 16, 2015
@steveklabnik
Copy link
Member

This is effectively part of rust-lang/rfcs#600 . Right now, you need to have the exact same SHA of the compiler to use a shared library, which is why it's done this way.

@huonw
Copy link
Member

huonw commented Feb 16, 2015

I'm not 100% sure this is dependent on having a stable ABI... AIUI, this issue more related to being able to match the file format packagers expect. That is, we do currently version libraries and binaries via the included hash (it should change as versions change), but packagers expect the file format to include the trailing version numbers instead. (Maybe some are flexible enough to work with alternate versioning schemes?)

Having a non-stable ABI means one cannot easily release patches for already released dynamic libraries, but I suspect we're not intending to do so for the compiler, given the short 6 week release schedule and it doesn't mean we can't be able to conform to the file format expected.

That said, the lack of a non-stable ABI means that release dynamically linked Rust programs is slightly pointless.

@huonw huonw reopened this Feb 16, 2015
@semarie
Copy link
Contributor Author

semarie commented Feb 16, 2015

A simple way to accomodate could be to having a codegen option extra_extension that do similary job than extra_filename option, but after the extension ?

Packagers will be able to follow their file format without too much effort.

@cuviper
Copy link
Member

cuviper commented Oct 30, 2015

If there's an ELF DT_SONAME tag, then there absolutely is an expectation of a stable ABI. Sometimes it's libfoo.so.MAJOR, but it could be any ABI stamp committed to long ago, like glibc's current libc.so.6. The usual setup then is a symlink chain libfoo.so (for linker -lfoo) -> $SONAME (for ld.so loading DT_NEEDED) -> the-real-libfoo.so, where the final name can take many forms.

Then on top of this you can have symbol versions, which lets you safely extend an SONAME and even replace old symbols with better ones. See Ulrich Drepper's How To Write Shared Libraries, especially section 3 on ABIs.

That's what library versioning is really about, IMO. But Rust doesn't set any SONAME right now anyway, and shouldn't bother until there's a stable ABI. And even then, the developer has to really commit to maintaining a stable interface themselves too.

@brson brson added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-tools P-low Low priority O-linux Operating system: Linux labels Apr 4, 2017
@Mark-Simulacrum Mark-Simulacrum added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 24, 2017
@steveklabnik
Copy link
Member

Triage: no movement.

@Mark-Simulacrum Mark-Simulacrum added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Mar 10, 2024
@jieyouxu jieyouxu added the needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. label Mar 1, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Mar 1, 2025

Triage: I'm going to close this issue on the rust-lang/rust issue tracker as unactionable because while this seems like a very reasonable feature request, this definitely needs an RFC to figure out a design that addresses the concerns.

@jieyouxu jieyouxu closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. O-linux Operating system: Linux P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants