Skip to content

Commit 00b9ce5

Browse files
authored
Rollup merge of #110909 - john-h-k:build/no-rustc-version-darwin, r=jyn514
Skip `rustc` version detection on macOS Fixes #104723
2 parents 75be558 + cffc10b commit 00b9ce5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/bootstrap/bootstrap.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,25 @@ def default_build_triple(verbose):
209209
# install, use their preference. This fixes most issues with Windows builds
210210
# being detected as GNU instead of MSVC.
211211
default_encoding = sys.getdefaultencoding()
212-
try:
213-
version = subprocess.check_output(["rustc", "--version", "--verbose"],
214-
stderr=subprocess.DEVNULL)
215-
version = version.decode(default_encoding)
216-
host = next(x for x in version.split('\n') if x.startswith("host: "))
217-
triple = host.split("host: ")[1]
218-
if verbose:
219-
print("detected default triple {} from pre-installed rustc".format(triple))
220-
return triple
221-
except Exception as e:
212+
213+
if sys.platform == 'darwin':
222214
if verbose:
223-
print("pre-installed rustc not detected: {}".format(e))
215+
print("not using rustc detection as it is unreliable on macOS")
224216
print("falling back to auto-detect")
217+
else:
218+
try:
219+
version = subprocess.check_output(["rustc", "--version", "--verbose"],
220+
stderr=subprocess.DEVNULL)
221+
version = version.decode(default_encoding)
222+
host = next(x for x in version.split('\n') if x.startswith("host: "))
223+
triple = host.split("host: ")[1]
224+
if verbose:
225+
print("detected default triple {} from pre-installed rustc".format(triple))
226+
return triple
227+
except Exception as e:
228+
if verbose:
229+
print("pre-installed rustc not detected: {}".format(e))
230+
print("falling back to auto-detect")
225231

226232
required = sys.platform != 'win32'
227233
ostype = require(["uname", "-s"], exit=required)

0 commit comments

Comments
 (0)