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

Vendor dependency os_pipe #822

Merged
merged 4 commits into from
Jul 20, 2023
Merged

Vendor dependency os_pipe #822

merged 4 commits into from
Jul 20, 2023

Conversation

NobodyXu
Copy link
Collaborator

Signed-off-by: Jiahao XU Jiahao_XU@outlook.com

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@nagisa
Copy link
Member

nagisa commented Jul 18, 2023

Could you provide motivation for this change in the PR description?

@NobodyXu
Copy link
Collaborator Author

Could you provide motivation for this change in the PR description?

Its motivation was explained by @thomcc and @joshtriplett on zulip

@workingjubilee
Copy link
Member

Jotting out a quick resummary is still good.

@thomcc
Copy link
Member

thomcc commented Jul 19, 2023

Basically the reason is that the existing crate is not particularly portable, and this fixes those issues (it's not actually a straight vendoring).

My stance is that this optimization is not really worth this complexity and non-portability (this PR even has to explicitly compile_error on non-windows/non-unix, which is something we would support prior to #780 so long as std::process/std::fs worked...), but we've already landed it, and this at least reduces the number of things people have to PR in order to get their targets working.

@NobodyXu
Copy link
Collaborator Author

NobodyXu commented Jul 19, 2023

this PR even has to explicitly compile_error on non-windows/non-unix, which is something we would support prior to #780 so long as std::process/std::fs worked...)

@thomcc I just looked into rust's stdlib and I've found that process spawning is only supported on windows and unix.

In the stdlib's sys module, it supports the following OSes:

  • unix
  • windows
  • solid_asp3
  • hermit
  • wasi
  • wasm
  • sgx: cfg(all(target_vendor = "fortanix", target_env = "sgx"))

And I found that other than Unix and Windows, none support process spawning:

FYI, here is the link to unsupported/process.rs, it simply panics on process spawning.

@thomcc So no, my PR does not introduce any regression since cc only support windows and unix before it lands and process spawning on non-unix and non-windows OS has never been supported by stdlib anyway.

meme

@NobodyXu
Copy link
Collaborator Author

NobodyXu commented Jul 19, 2023

@thomcc I also discovered a pattern in rust's stdlib: OS that does not support pipe creation also don't support process spawning.

P.S. I was just wondering how many OSes support process spawning but does not support pipe creation to see how much regression/damage my PR introduced and whether @thomcc is right that it should be reverted, turns out there's none in rust stdlib.

tests/support/mod.rs Outdated Show resolved Hide resolved
tests/support/mod.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@joshtriplett
Copy link
Member

I'm wondering if we can simplify this substantially.

The PipeReader/PipeWriter wrappers are nice for the os_pipe crate to keep users from mixing up the two ends and reading/writing the wrong one, but they add substantial complexity. For the purposes of this crate, it seems sufficient to return (File, File), and take care to use them correctly.

That then eliminates the need for impl_Read_by_forward and impl_Write_by_forward, as well as the From impls converting to Stdio (because File already supports that).

I also don't think it's worth including the test-support binaries in src/bin, and the tests that depend on those.

@joshtriplett
Copy link
Member

joshtriplett and others added 3 commits July 20, 2023 11:47
Eliminate the separate PipeReader and PipeWriter types, and just use
File. Remove unused windows-sys features. Remove added test
infrastructure.

Revert unrelated changes.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

This is a lot more reasonable. Thanks to both you and @joshtriplett for all the changes.

@thomcc thomcc merged commit b030a29 into rust-lang:main Jul 20, 2023
16 checks passed
@NobodyXu NobodyXu deleted the vendored/os-pipe branch July 20, 2023 04:41
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.

5 participants