-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[musl] use posix_spawn if a directory change was requested #131851
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @workingjubilee. Use |
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
Well, But you can do the opposite: Have a test that covers rust/library/std/src/sys/pal/unix/linux/pidfd/tests.rs Lines 47 to 49 in 86bd459
|
Hm. I guess one can write internal unit-tests where the APIs are exposed? But doing that with multiprocess situations sounds... treacherous. |
Yeah, a test attempting to exercise both paths sounds good. I'll work on that once #131823 lands.
What I would personally do is abstract the posix_spawn/fork decision into a function which returns an enum, and test that. I don't know how feasible that is, and I'd rather not block this relatively straightforward PR on that refactor :) |
Yeah, I don't wanna scope creep ya. |
99677ad
to
695bd58
Compare
All right, rebased and added a test to exercise both paths. |
This comment has been minimized.
This comment has been minimized.
Currently, not all libcs have the `posix_spawn_file_actions_addchdir_np` symbol available to them. So we attempt to do a weak symbol lookup for that function. But that only works if libc is a dynamic library -- with statically linked musl binaries the symbol lookup would never work, so we would never be able to use it even if the musl in use supported the symbol. Now that Rust has a minimum musl version of 1.2.3, all supported musl versions now include this symbol, so we can unconditionally expect it to be there. This symbol was added to libc in rust-lang/libc#3949 -- use it here. I couldn't find any tests for whether the posix_spawn path is used, but I've verified with cargo-nextest that this change works. This is a substantial improvement to nextest's performance with musl. On my workstation with a Ryzen 7950x, against https://github.com/clap-rs/clap at 61f5ee514f8f60ed8f04c6494bdf36c19e7a8126: Before: ``` Summary [ 1.071s] 879 tests run: 879 passed, 0 skipped ``` After: ``` Summary [ 0.392s] 879 tests run: 879 passed, 0 skipped ``` Fixes rust-lang#99740.
695bd58
to
a9016c8
Compare
#[cfg(not(all(target_os = "linux", target_env = "musl")))] | ||
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've moved this to the top of scope in a sensible-seeming fashion. Unfortunately, this is only called within posix_spawn
, which not every platform calls to begin with. Indeed, many cfg
it away! So this will not be called at all on platforms that don't match this cfg:
#[cfg(any(
target_os = "freebsd",
all(target_os = "linux", target_env = "gnu"),
all(target_os = "linux", target_env = "musl"),
target_os = "nto",
target_vendor = "apple",
))]
But it will still be defined for those. For those which aren't in the above set, but do use process_unix.rs
, then they will see an unused function, and then libstd will not build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right...
I guess I could probably move the function item to be function-local.
@bors try |
[musl] use posix_spawn if a directory change was requested Currently, not all libcs have the `posix_spawn_file_actions_addchdir_np` symbol available to them. So we attempt to do a weak symbol lookup for that function. But that only works if libc is a dynamic library -- with statically linked musl binaries the symbol lookup would never work, so we would never be able to use it even if the musl in use supported the symbol. Now that Rust has a minimum musl version of 1.2.3, all supported musl versions now include this symbol, so we can unconditionally expect it to be there. This symbol was added to libc in rust-lang/libc#3949 -- use it here. I couldn't find any tests for whether the posix_spawn path is used, but I've verified with cargo-nextest that this change works. This is a substantial improvement to nextest's performance with musl. On my workstation with a Ryzen 7950x, against https://github.com/clap-rs/clap at 61f5ee514f8f60ed8f04c6494bdf36c19e7a8126: Before: ``` Summary [ 1.071s] 879 tests run: 879 passed, 0 skipped ``` After: ``` Summary [ 0.392s] 879 tests run: 879 passed, 0 skipped ``` Fixes rust-lang#99740. try-job: dist-various-1 try-job: dist-various-2
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
yep, goes kaput on the solaris build. you may want to cross-compile for the illumos stdlib while testing this. |
Currently, not all libcs have the
posix_spawn_file_actions_addchdir_np
symbol available to them. So we attempt to do a weak symbol lookup for that function. But that only works if libc is a dynamic library -- with statically linked musl binaries the symbol lookup would never work, so we would never be able to use it even if the musl in use supported the symbol.Now that Rust has a minimum musl version of 1.2.3, all supported musl versions now include this symbol, so we can unconditionally expect it to be there. This symbol was added to libc in rust-lang/libc#3949 -- use it here.
I couldn't find any tests for whether the posix_spawn path is used, but I've verified with cargo-nextest that this change works. This is a substantial improvement to nextest's performance with musl. On my workstation with a Ryzen 7950x, against https://github.com/clap-rs/clap at
61f5ee514f8f60ed8f04c6494bdf36c19e7a8126:
Before:
After:
Fixes #99740.
try-job: dist-various-1
try-job: dist-various-2