From 1b390f44cfefa3a83af6056f136964e24c22af66 Mon Sep 17 00:00:00 2001 From: John Kelly Date: Thu, 27 Apr 2023 17:39:58 +0100 Subject: [PATCH 1/2] Skip rustc version detection on macOS --- src/bootstrap/bootstrap.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 680a8da6adf20..98e62f0011013 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -209,19 +209,24 @@ 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 verbose: - print("pre-installed rustc not detected: {}".format(e)) - print("falling back to auto-detect") + + if sys.platform == 'darwin': + 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) From cffc10b2c82f97e45121710af7ddf617e177b5e7 Mon Sep 17 00:00:00 2001 From: John Kelly Date: Thu, 27 Apr 2023 20:55:36 +0100 Subject: [PATCH 2/2] Comment round #1 --- src/bootstrap/bootstrap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 98e62f0011013..9c6c917ac4a2b 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -211,8 +211,9 @@ def default_build_triple(verbose): default_encoding = sys.getdefaultencoding() if sys.platform == 'darwin': - print("not using rustc detection as it is unreliable on macOS") - print("falling back to auto-detect") + if verbose: + 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"],