Skip to content

Workaround in ZipArchiver when posix_spawn_file_actions_addchdir_np is unavailable #7187

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 2 commits into from
Jan 8, 2024

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Dec 12, 2023

Motivation:
swift package-registry publish tool doesn't work in Amazon Linux 2 because it has an older version of Glibc that doesn't support posix_spawn_file_actions_addchdir_np.

Modifications:
Add workaround in ZipArchiver that does cd <working directory> && zip ... when posix_spawn_file_actions_addchdir_np is not available.

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 12, 2023

@swift-ci please test

completion: completion
)
} else {
let process = Foundation.Process()
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably use TSC's process since it handles stdout and stderr better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use TSC.Process we would hit the same blocker (i.e., the Glibc check) that's preventing publish from working.

Copy link
Contributor

Choose a reason for hiding this comment

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

only if we set the working directory, no?

Copy link
Contributor

@tomerd tomerd Dec 12, 2023

Choose a reason for hiding this comment

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

in fact I believe if we set the working directory in Foundation process we will also run into the same issue because its also using posix_spawn_file_actions_addchdir

Copy link
Contributor

Choose a reason for hiding this comment

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

Using posix_spawn_file_actions_addchdir is good, that's what we want right? The issue is just if that's not available, then we need to fail (and not just call chdir).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to make this work when posix_spawn_file_actions_addchdir is not available instead of failing. And rather than having different code paths, we do the same for all scenarios (except on Windows) so we'd know sooner if it breaks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yim-lee the only way to make this work on UNIX without posix_spawn_file_actions_addchdir is to reimplement with fork+exec.

Do you happen to know which systems lack posix_spawn_file_actions_addchdir?

Copy link
Contributor Author

@yim-lee yim-lee Dec 14, 2023

Choose a reason for hiding this comment

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

@weissi We are trying to make something works for Amazon Linux 2, which has an earlier version of glibc.

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, thanks. if that's still an important target platform then it would need to be fork+exec there

@neonichu
Copy link
Contributor

Do we actually need the check? We could just always cd to keep things simpler, right?

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 12, 2023

Do we actually need the check? We could just always cd to keep things simpler, right?

My concern is the change might potentially change/break existing behavior, but we can always fix it if it happens I suppose.

@neonichu
Copy link
Contributor

Right, the advantage would be that we learn about the breakage quicker since we would exercise the same code in more scenarios.

@yim-lee yim-lee force-pushed the al2-registry-publish branch from 4fff895 to d698cdb Compare December 13, 2023 02:03
@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 13, 2023

Updated per feedback.

@swift-ci please test

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 13, 2023

@swift-ci please test Windows platform

@MaxDesiatov
Copy link
Contributor

@swift-ci test macos

@yim-lee yim-lee force-pushed the al2-registry-publish branch from d698cdb to 2f30d19 Compare December 20, 2023 19:08
@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 20, 2023

Rebased.

@swift-ci please test

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 20, 2023

@swift-ci please test Windows

1 similar comment
@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 20, 2023

@swift-ci please test Windows

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 20, 2023

@swift-ci please test Linux

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 20, 2023

@swift-ci please test Windows

@MaxDesiatov
Copy link
Contributor

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor

@swift-ci test

…s unavailable

Motivation:
`swift package-registry publish` tool doesn't work in Amazon Linux 2 because it has an older version of Glibc that doesn't support `posix_spawn_file_actions_addchdir_np`.

Modifications:
Add workaround in `ZipArchiver` that does `cd <working directory> && zip ...` when `posix_spawn_file_actions_addchdir_np` is not available.
@yim-lee yim-lee force-pushed the al2-registry-publish branch from 2f30d19 to 27c24b9 Compare January 5, 2024 17:13
@yim-lee
Copy link
Contributor Author

yim-lee commented Jan 5, 2024

@swift-ci please test

@yim-lee
Copy link
Contributor Author

yim-lee commented Jan 5, 2024

@swift-ci please test Windows

@yim-lee
Copy link
Contributor Author

yim-lee commented Jan 5, 2024

Build timed out. @swift-ci please test Windows

@neonichu
Copy link
Contributor

neonichu commented Jan 5, 2024

@swift-ci please test Windows

@yim-lee yim-lee merged commit 8ff74e3 into swiftlang:main Jan 8, 2024
@yim-lee yim-lee deleted the al2-registry-publish branch January 8, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants