diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-05-23 20:30:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-23 20:30:11 +0200 |
| commit | 8b69895ec2ee4b85ef5311468accf12f4460ec12 (patch) | |
| tree | 11556ba2152492dc8a316e46936368fdd93004ac | |
| parent | a4836e996567c87ebffb499a3c08246d7af3068e (diff) | |
| parent | 1f862a82e2ed32a0c9a6dc33fb7cf32ed7195653 (diff) | |
| download | rust-8b69895ec2ee4b85ef5311468accf12f4460ec12.tar.gz rust-8b69895ec2ee4b85ef5311468accf12f4460ec12.zip | |
Rollup merge of #141374 - jeremyd2019:patch-1, r=jieyouxu
make shared_helpers exe function work for both cygwin and non-cygwin hosts On Cygwin, it needs to not append .exe, because /proc/self/exe (and therefore `std::env::current_exe`) does not include the .exe extension, breaking bootstrap's rustc wrapper. On hosts other than Cygwin, it *does* need to append .exe because the file really does have a .exe extension, and non-Cygwin hosts won't be doing the same filename rewriting that Cygwin does when looking for a file X but finding only X.exe in its place. Arising from discussion in https://github.com/rust-lang/rust/pull/140154#pullrequestreview-2855782812 ``@mati865`` ``@Berrysoft``
| -rw-r--r-- | src/bootstrap/src/utils/shared_helpers.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bootstrap/src/utils/shared_helpers.rs b/src/bootstrap/src/utils/shared_helpers.rs index 08e1c21e58e..561af34a447 100644 --- a/src/bootstrap/src/utils/shared_helpers.rs +++ b/src/bootstrap/src/utils/shared_helpers.rs @@ -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") |
