about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-05 17:08:13 +0200
committerGitHub <noreply@github.com>2022-07-05 17:08:13 +0200
commita82f4a574efeb44d413035eac5beee61e4611a18 (patch)
tree395d7e7cb6804c20e5b7a0704067cb58a06db3ba
parent70ade7d503a4dcd3552c17a56fddd18bfd53c98d (diff)
parent9ac4a4e67a2d217179a465bc865e31915682c93c (diff)
downloadrust-a82f4a574efeb44d413035eac5beee61e4611a18.tar.gz
rust-a82f4a574efeb44d413035eac5beee61e4611a18.zip
Rollup merge of #98895 - ChrisDenton:no-elves-allowed, r=jyn514
bootstrap.py: Always use `.exe` for Windows

This ensures that it will run the Windows executable if other files in the directory (such as Linux executables) have the same file name minus the extension. I've been tripped up by this a few times where both `bootstrap` and `bootstrap.exe` end up in the same directory.

This PR avoids ever having to see the following message:

`OSError: [WinError 193] %1 is not a valid Win32 application`
-rw-r--r--src/bootstrap/bootstrap.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 3c2f1bdb142..9301c5a2ff3 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -152,6 +152,10 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
     if verbose:
         print("running: " + ' '.join(args))
     sys.stdout.flush()
+    # Ensure that the .exe is used on Windows just in case a Linux ELF has been
+    # compiled in the same directory.
+    if os.name == 'nt' and not args[0].endswith('.exe'):
+        args[0] += '.exe'
     # Use Popen here instead of call() as it apparently allows powershell on
     # Windows to not lock up waiting for input presumably.
     ret = subprocess.Popen(args, **kwargs)