rust-lang / rust-lang/libc

termios: support arbitrary baud rates with glibc 2.42+ on Linux

Open
#5,230 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-API-request S-blocked
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

glibc 2.42.0 made API / ABI changes to expose arbitrary baud rates in the functions from <termios.h>:

  • On Linux, the <termios.h> interface now supports arbitrary baud rates;
    speed_t is redefined to simply be the baud rate specified as an
    unsigned int, which matches the kernel interface.

https://lists.gnu.org/archive/html/info-gnu/2025-07/msg00011.html

Since 0.2.179, libc explicitly links against the symbols from the old ABI that only exposes the baud rate as enum constants: https://github.com/rust-lang/libc/pull/4882

It would be nice if the libc crate could expose functions that accept / return arbitrary baud rates on Linux too. It looks like this is already the case on *BSD, and only on Linux and Android, the old enums are still used (at least according to the docs for the nix crate).

Alternatively, the existing APIs in libc could start targeting the new glibc ABI in a future major version of the libc crate - but it's possibly too late for 1.0.0, since it would require raising the minimum supported glibc version to 2.42 - which unfortunately would mean that it would take ages for those APIs to ever change to what is exposed by the underlying platform?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing termios bindings in the libc crate and the <termios.h> API and ABI changes introduced by glibc 2.42. Compare the Linux and Android bindings with the already-arbitrary-rate BSD APIs, then determine whether compatibility APIs or a future ABI change is appropriate; done means the supported design and platform behavior are clearly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, linux, rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.