Skip to content

stty: support any baud on Linux, replace nix with rustix - #15299

Open
oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:stty-unsafe
Open

oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:stty-unsafe

Conversation

@oech3

@oech3 oech3 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.84%

1 warning, 1 note

⚠️ 123 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 398 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory cp_recursive_deep_tree[(120, 4)] 532.6 KB 699.2 KB -23.82%
⚡ CPU Simulation true_consecutive_calls 350.2 ns 294.7 ns +18.85%
⚡ Memory du_deep_tree[(100, 3)] 82.4 KB 76.5 KB +7.68%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing oech3:stty-unsafe (c6fc86b) with main (679d1f2)2

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (eb7d426) during the generation of this report, so 679d1f2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread src/uu/stty/Cargo.toml Outdated
Comment thread src/uu/stty/src/stty.rs Outdated
Comment thread src/uu/stty/src/stty.rs Outdated
Comment thread src/uu/stty/src/stty.rs Outdated
@oech3
oech3 marked this pull request as draft October 13, 2026 16:36
Comment thread src/uu/stty/src/stty.rs Outdated
@oech3
oech3 force-pushed the stty-unsafe branch 5 times, most recently from 8c0b529 to 39bc936 Compare October 13, 2026 17:09
@oech3 oech3 changed the title stty: remove unsafe & cfg stty: replace nix with rustix Oct 13, 2026
@oech3 oech3 changed the title stty: replace nix with rustix stty: support any baud on Linux, replace nix with rustix Oct 13, 2026
@oech3
oech3 force-pushed the stty-unsafe branch 2 times, most recently from ff11e70 to f100d7d Compare October 13, 2026 17:47
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/dd/nocache_fail is now passing!
Note: The gnu test tests/rm/rm-readdir-fail was skipped on 'main' but is now failing.

@oech3
oech3 force-pushed the stty-unsafe branch 2 times, most recently from 9be3124 to d420658 Compare October 13, 2026 18:30
@oech3

This comment was marked as outdated.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Would it be possible to separate the refactor replacing nix with rustix from the fix for #8719 into separate PRs?

@oech3

oech3 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

It is very difficult since rustix automatically supports any baud and nix and rustix cannot be mixed.

@oech3

This comment was marked as resolved.

@oech3

This comment was marked as outdated.

@xtqqczze xtqqczze left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on Linux when arbitrary baud rates are not supported (i.e. with glibc < 2.42)? Do we panic, return an error, or fall back to a different behavior?

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

This should work for all libcs since this does not use glibc's API and uses ioctl directly. But I don't have legacy glibc.
I'm not sure if stty 51 test works on the CI. Currently, most stty tests are skipped due to missing console.

@xtqqczze

Copy link
Copy Markdown
Collaborator

This should work for all libcs since this does not use glibc's API and uses ioctl directly.

We have downstream consumers using rustix/use-libc cfg, so stty uses the glibc API in that case?

@oech3

This comment was marked as resolved.

@oech3

oech3 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

nix (thus libc) creates a struct using cfset*speed (missing support for any baud on legacy glibc) at user space RAM and passes it to ioctl.
rustix creates a struct by its own way and passes it to ioctl.

@oech3

This comment was marked as resolved.

@xtqqczze

Copy link
Copy Markdown
Collaborator

I think I understand now: in Rustix tcgetattr, tcgetwinsize, tcsetattr, tcsetwinsize are implemented using syscalls rather than libc, even when the use_libc feature is enabled?

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

use_libc uses C-ioctl wrapper. So we bypasses cfset*speed which caused panic. (Thus, stty 51 worked under scripts).

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

So use_libc allows us LD_PRELOADing C-ioctl. But patching bad-speed.sh to intercept it changes meaning.

@oech3
oech3 force-pushed the stty-unsafe branch 2 times, most recently from 692124b to 7e3e80e Compare October 17, 2026 03:02
@oech3
oech3 force-pushed the stty-unsafe branch 2 times, most recently from a4b22f0 to acbcf89 Compare October 18, 2026 07:48
@oech3

oech3 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

hopefully last rebase against confliction

Comment thread src/uu/stty/src/flags.rs Outdated
Comment thread src/uu/stty/src/flags.rs
@oech3

This comment was marked as resolved.

@oech3

oech3 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Unfortunately, we still need to map enum baud rates for stty --save at least on Linux. BSDs,Cygwin do not require enum.

Comment thread src/uu/stty/src/flags.rs
@xtqqczze

Copy link
Copy Markdown
Collaborator

fuzz failures tracked by #15567.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Switching to rustix has enabled support for AIX targets. Could you consider pushing a commit removing the cfg exclusion in this PR, or addressing it in a follow-up PR?

@oech3

oech3 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

I cannot much care about minor targets. I'd like to keep diff minimal at here.

@oech3 oech3 mentioned this pull request Oct 21, 2026
@xtqqczze

Copy link
Copy Markdown
Collaborator

There will be follow-up work in any case for OUTPUT_FLAGS target cfg's, so fine for now.

@oech3

oech3 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@sylvestre Would you consider merging this?

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stty: support B460800 and B921600 baud rates stty: support arbitrary baudrate (at least on linux) as GNU coreutils 9.8

3 participants