Skip to content

Fall back to launching subprocesses without a working directory #1272

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

Merged
merged 1 commit into from
May 9, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 9, 2024

Details from #1271

Amazon Linux 2 and CentOS 7 have a glibc that doesn’t support posix_spawn_file_actions_addchdir_np and thus TSCBasic.Process can’t launch a process on these platforms with the working directory set. We currently fall back to launching the index tasks without a working directory on these platforms, which I think is fine because SwiftPM gives us compiler arguments with absolute paths. But we should figure something out.

Using Foundation.Process is not an option because it runs chdir on the current process for Posix platforms, which is racy if there are multiple subprocesses being spawned simultaneously. On Windows TSCBasic.Processs uses Foundation.Process and Foundation.Process properly set the working directory of the subprocesses on Windows, so Windows is not a problem.

rdar://127797048

Details from swiftlang#1271

> Amazon Linux 2 and CentOS 7 have a glibc that doesn’t support `posix_spawn_file_actions_addchdir_np` and thus `TSCBasic.Process` can’t launch a process on these platforms with the working directory set. We currently fall back to launching the index tasks without a working directory on these platforms, which I think is fine because SwiftPM gives us compiler arguments with absolute paths. But we should figure something out.
>
> Using `Foundation.Process` is not an option because it runs `chdir` on the current process for Posix platforms, which is racy if there are multiple subprocesses being spawned simultaneously. On Windows `TSCBasic.Processs` uses `Foundation.Process` and `Foundation.Process` properly set the working directory of the subprocesses on Windows, so Windows is not a problem.

rdar://127797048
@ahoppen ahoppen requested a review from bnbarham May 9, 2024 17:26
@ahoppen ahoppen requested a review from benlangmuir as a code owner May 9, 2024 17:26
@ahoppen
Copy link
Member Author

ahoppen commented May 9, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge May 9, 2024 19:01
@ahoppen ahoppen merged commit 73cec82 into swiftlang:main May 9, 2024
3 checks passed
@ahoppen ahoppen deleted the working-directory branch May 14, 2024 04:14
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.

1 participant