Skip to content

make shared_helpers exe function work for both cygwin and non-cygwin hosts #141374

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
11 changes: 10 additions & 1 deletion src/bootstrap/src/utils/shared_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ 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") {
// On Cygwin, the decision to append .exe or not is not as straightforward.
// Executable files do actually have .exe extensions so on hosts other than
// Cygwin it is necessary. But on a Cygwin host there is magic happening
// that redirects requests for file X to file X.exe if it exists, and
// furthermore /proc/self/exe (and thus std::env::current_exe) always
// returns the name *without* the .exe extension. For comparisons against
// that to match, we therefore do not append .exe for Cygwin targets on
// a Cygwin host.
if target.contains("windows") || (cfg!(not(target_os = "cygwin")) && target.contains("cygwin"))
{
format!("{name}.exe")
} else if target.contains("uefi") {
format!("{name}.efi")
Expand Down
Loading