Skip to content

Commit

Permalink
Rollup merge of #110909 - john-h-k:build/no-rustc-version-darwin, r=j…
Browse files Browse the repository at this point in the history
…yn514

Skip `rustc` version detection on macOS

Fixes #104723
  • Loading branch information
JohnTitor authored Apr 28, 2023
2 parents 75be558 + cffc10b commit 00b9ce5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,25 @@ def default_build_triple(verbose):
# install, use their preference. This fixes most issues with Windows builds
# being detected as GNU instead of MSVC.
default_encoding = sys.getdefaultencoding()
try:
version = subprocess.check_output(["rustc", "--version", "--verbose"],
stderr=subprocess.DEVNULL)
version = version.decode(default_encoding)
host = next(x for x in version.split('\n') if x.startswith("host: "))
triple = host.split("host: ")[1]
if verbose:
print("detected default triple {} from pre-installed rustc".format(triple))
return triple
except Exception as e:

if sys.platform == 'darwin':
if verbose:
print("pre-installed rustc not detected: {}".format(e))
print("not using rustc detection as it is unreliable on macOS")
print("falling back to auto-detect")
else:
try:
version = subprocess.check_output(["rustc", "--version", "--verbose"],
stderr=subprocess.DEVNULL)
version = version.decode(default_encoding)
host = next(x for x in version.split('\n') if x.startswith("host: "))
triple = host.split("host: ")[1]
if verbose:
print("detected default triple {} from pre-installed rustc".format(triple))
return triple
except Exception as e:
if verbose:
print("pre-installed rustc not detected: {}".format(e))
print("falling back to auto-detect")

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

0 comments on commit 00b9ce5

Please sign in to comment.