Skip to content

rfc 1291: Add libutil to scope of libc crate on Linux #1529

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

Merged
merged 1 commit into from
Mar 31, 2016

Conversation

kamalmarhubi
Copy link
Contributor

The initial motivation for adding this library is to get access to
openpty(3) and forkpty(3). These simplify opening a pseudoterminal
master / slave pair. The functions are defined on Linux, OSX, FreeBSD,
NetBSD, and OpenBSD. On OS X, they are available without linking to any
additionaly libraries; on the other platforms they require linking with
-lutil.

On Linux, libutil is part of glibc, and defines 6 symbols:

  • forkpty
  • logwtmp
  • login_tty
  • openpty
  • login
  • logout

libutil is available in the base installs of Debian-, Fedora-, and
Arch-derived distributions, as well as openSUSE and Android, though on
Android the pty.h header that declares the functions seems not to be
available. Together, these cover the DistroWatch 0 top 10
distributions.

In musl libc, openpty(3) and forkpty(3) are included in libc.a.

On NetBSD and OpenBSD, these functions are included in libutil, which
defines about 100 functions.

On FreeBSD, these functions are included in libutil, which defines about
200 functions.

@kamalmarhubi
Copy link
Contributor Author

r? @alexcrichton

@alexcrichton
Copy link
Member

It would be helpful to also provide some rationale as to why this new library should be picked up by default. For example it would be nice to see how compatible this is across platforms (not just Linux), across various C libraries on Linux (like MUSL), etc. It would also be useful to know whether this is available throughout various distributions of Linux.

@kamalmarhubi
Copy link
Contributor Author

Ah yes I meant to do that. I've updated the commit message with a bunch of detail regarding openpty(3) and forkpty(3). Is that more like what you had in mind?

The initial motivation for adding this library is to get access to
`openpty(3)` and `forkpty(3)`. These simplify opening a pseudoterminal
master / slave pair. The functions are defined on Linux, OSX, FreeBSD,
NetBSD, and OpenBSD. On OS X, they are available without linking to any
additionaly libraries; on the other platforms they require linking with
`-lutil`.

On Linux, libutil is part of glibc, and defines 6 symbols:
- forkpty
- logwtmp
- login_tty
- openpty
- login
- logout

libutil is available in the base installs of Debian-, Fedora-, and
Arch-derived distributions, as well as openSUSE and Android, though on
Android the `pty.h` header that declares the functions seems not to be
available.  Together, these cover the DistroWatch [0] top 10
distributions.

In musl libc, `openpty(3)` and `forkpty(3)` are included in `libc.a`.

On NetBSD and OpenBSD, these functions are included in libutil, which
defines about 100 functions.

On FreeBSD, these functions are included in libutil, which defines about
200 functions.

[0]: http://distrowatch.com/
@alexcrichton alexcrichton self-assigned this Mar 7, 2016
@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Mar 7, 2016
@alexcrichton
Copy link
Member

Thanks @kamalmarhubi! These seem like they're widely available enough and somewhat standard enough that it appears reasonable to me to include them.

@kamalmarhubi
Copy link
Contributor Author

@alexcrichton what's the process on an RFC change like this?

@alexcrichton
Copy link
Member

This falls under the purview of the libs team, so we'll move this into FCP when we get a chance to get around to this (our triage meeting is on Wednesdays)

@kamalmarhubi
Copy link
Contributor Author

👍 thanks for the details!

@brson
Copy link
Contributor

brson commented Mar 23, 2016

I have some reservations about this. Right now the things libc links to can reasonably be described as part of the C runtime - they are all things that a C compiler will link you to by default in some scenario - crt, compiler-rt, m, dl, pthreads. I don't know that libutil is in this same category.

@codyps
Copy link

codyps commented Mar 24, 2016

@brson what do you mean "will link you to by default"? IIRC, pthreads, m, and dl all require one to provide explicit link flags on common plaftorms.

@nagisa
Copy link
Member

nagisa commented Mar 24, 2016

IIRC, pthreads, m, and dl all require one to provide explicit link flags on common plaftorms.

This is only true for glibc-based platforms. System.dylib, libmusl and many other saner runtimes link to everything by default.

@codyps
Copy link

codyps commented Mar 24, 2016

@nagisa do those saner runtimes also link libutil (or whatever library has the symbols noted above) by default?

If so, it would sound like those libutil symbols could resonably be defined as part of the C runtime, by @brson 's definition.

@alexcrichton
Copy link
Member

🔔 This RFC is now entering its week-long final comment period 🔔

@alexcrichton alexcrichton added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed I-nominated labels Mar 24, 2016
@kamalmarhubi
Copy link
Contributor Author

The symbols in libutil for glibc are present in libc.a for musl, and at least some are available without additional linking on OS X. I tried to make this clear in the commit message; should I put that information somewhere else?

@alexcrichton
Copy link
Member

The libs team discussed this RFC during triage today and the decision was to merge. The libutil.a library seems ubiquitous enough to add and the functions are common enough too.

Thanks again for the RFC @kamalmarhubi!

@alexcrichton alexcrichton merged commit 504fc53 into rust-lang:master Mar 31, 2016
@kamalmarhubi
Copy link
Contributor Author

yay!

kamalmarhubi added a commit to kamalmarhubi/libc that referenced this pull request Mar 31, 2016
The functions were added for Apple in rust-lang#202. Adding them to other
platforms was pending an amendment to RFC 1291 to expand the scope of
libc to include libutil. The amendment was merged as
  rust-lang/rfcs#1529
kamalmarhubi added a commit to kamalmarhubi/libc that referenced this pull request Apr 1, 2016
The functions were added for Apple in rust-lang#202. Adding them to other
platforms was pending an amendment to RFC 1291 to expand the scope of
libc to include libutil. The amendment was merged as
  rust-lang/rfcs#1529
bors added a commit to rust-lang/libc that referenced this pull request Apr 1, 2016
unix: Add openpty(3) and forkpty(3) for non-Apple platforms

The functions were added for Apple in #202. Adding them to other
platforms was pending an amendment to RFC 1291 to expand the scope of
libc to include libutil. The amendment was merged as
  rust-lang/rfcs#1529
kamalmarhubi added a commit to kamalmarhubi/libc that referenced this pull request Apr 2, 2016
The functions were added for Apple in rust-lang#202. Adding them to other
platforms was pending an amendment to RFC 1291 to expand the scope of
libc to include libutil. The amendment was merged as
  rust-lang/rfcs#1529
bors added a commit to rust-lang/libc that referenced this pull request Apr 2, 2016
unix: Add openpty(3) and forkpty(3) for non-Apple platforms

The functions were added for Apple in #202. Adding them to other
platforms was pending an amendment to RFC 1291 to expand the scope of
libc to include libutil. The amendment was merged as
  rust-lang/rfcs#1529
@Centril Centril added the A-libc Proposals relating to the libc crate. label Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-libc Proposals relating to the libc crate. final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants