Skip to content
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

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

Merged
merged 1 commit into from Mar 31, 2016

Conversation

Projects
None yet
6 participants
@kamalmarhubi
Copy link
Contributor

kamalmarhubi commented Mar 4, 2016

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

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 4, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 5, 2016

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 kamalmarhubi force-pushed the kamalmarhubi:libc-libutil branch from 66df245 to b547ddb Mar 5, 2016

@kamalmarhubi

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 5, 2016

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?

rfc 1291: Add libutil to scope of libc crate on Linux
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/

@kamalmarhubi kamalmarhubi force-pushed the kamalmarhubi:libc-libutil branch from b547ddb to 504fc53 Mar 5, 2016

@alexcrichton alexcrichton self-assigned this Mar 7, 2016

@alexcrichton alexcrichton added the T-libs label Mar 7, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 7, 2016

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

@kamalmarhubi

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 21, 2016

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

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 21, 2016

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

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 21, 2016

👍 thanks for the details!

@brson

This comment has been minimized.

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.

@jmesmon

This comment has been minimized.

Copy link

jmesmon 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

This comment has been minimized.

Copy link
Contributor

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.

@jmesmon

This comment has been minimized.

Copy link

jmesmon 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

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 24, 2016

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

@kamalmarhubi

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 24, 2016

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

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 31, 2016

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

This comment has been minimized.

Copy link
Contributor Author

kamalmarhubi commented Mar 31, 2016

yay!

kamalmarhubi added a commit to kamalmarhubi/libc that referenced this pull request Mar 31, 2016

unix: Add openpty(3) and forkpty(3) for non-Apple platforms
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

unix: Add openpty(3) and forkpty(3) for non-Apple platforms
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

Auto merge of #246 - kamalmarhubi:openpty, r=alexcrichton
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

unix: Add openpty(3) and forkpty(3) for non-Apple platforms
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

Auto merge of #246 - kamalmarhubi:openpty, r=alexcrichton
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 label Nov 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.