Skip to content

Cygwin support in rustc #140154

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 4 commits into from
May 19, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/shared_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn dylib_path() -> Vec<std::path::PathBuf> {
/// Given an executable called `name`, return the filename for the
/// executable for a particular target.
pub fn exe(name: &str, target: &str) -> String {
if target.contains("windows") || target.contains("cygwin") {
if target.contains("windows") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused by this. I just had to re-discover this change because bootstrap panicked not finding rustc-main when it was named rustc-main.exe, cross-compiling from Windows to Cygwin. While Cygwin does have 'magic' that will let you access a file X.exe by the name X, some other host wouldn't know to do that. What was the problem that reverting this change addressed, and is there maybe some other way to fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rustc wrapper of bootstrap failed to determine the correct parameters. The wrapper is executed like /foo/rustc /bar/rustc --baz.

I think there should be other solutions, but it's only a bootstrap tool. So rely on the cygwin magic is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought that bootstrap tool was the general way to cross-compile rust (build != host), and that should work for build != cygwin host = cygwin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well it might be complex then... Although the bootstrap tool should provide a way to cross-compile, it's not that common to cross compile from Windows to a Unix platform (Cygwin). Yet it would be better if it can support that case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Linux to Cygwin should work though? I might try that and see.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would bet that would require this exe function to append .exe though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually yes. They appended .exe. I removed it.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe there should be a special case for Cygwin host? Otherwise, .exe would be expected.

Copy link
Contributor

@jeremyd2019 jeremyd2019 May 21, 2025

Choose a reason for hiding this comment

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

I think there has to be a special case for Cygwin host somewhere, because current_exe returns without the .exe extension on a Cygwin host, but the real filename does have a .exe extension (which other hosts would have to know).

$ /usr/bin/readlink.exe /proc/self/exe
/usr/bin/readlink

Copy link
Contributor

Choose a reason for hiding this comment

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

This was fixed in #141374

format!("{name}.exe")
} else if target.contains("uefi") {
format!("{name}.efi")
Expand Down
Loading