Rollup merge of #79845 - jyn514:python3, r=Mark-Simulacrum
Fix rustup support in default_build_triple for python3 bootstrap completely ignores all errors when detecting a rustup version, so this wasn't noticed before. Fixes the following error: ``` rustup not detected: a bytes-like object is required, not 'str' falling back to auto-detect ``` This also takes the opportunity to only call rustup and other external commands only once during startup. Follow-up to https://github.com/rust-lang/rust/pull/78513.
This commit is contained in:
commit
f80c6aeb87
1 changed files with 8 additions and 3 deletions
|
@ -192,8 +192,10 @@ def default_build_triple(verbose):
|
||||||
# If the user already has a host build triple with an existing `rustc`
|
# If the user already has a host build triple with an existing `rustc`
|
||||||
# install, use their preference. This fixes most issues with Windows builds
|
# install, use their preference. This fixes most issues with Windows builds
|
||||||
# being detected as GNU instead of MSVC.
|
# being detected as GNU instead of MSVC.
|
||||||
|
default_encoding = sys.getdefaultencoding()
|
||||||
try:
|
try:
|
||||||
version = subprocess.check_output(["rustc", "--version", "--verbose"])
|
version = subprocess.check_output(["rustc", "--version", "--verbose"])
|
||||||
|
version = version.decode(default_encoding)
|
||||||
host = next(x for x in version.split('\n') if x.startswith("host: "))
|
host = next(x for x in version.split('\n') if x.startswith("host: "))
|
||||||
triple = host.split("host: ")[1]
|
triple = host.split("host: ")[1]
|
||||||
if verbose:
|
if verbose:
|
||||||
|
@ -204,7 +206,6 @@ def default_build_triple(verbose):
|
||||||
print("rustup not detected: {}".format(e))
|
print("rustup not detected: {}".format(e))
|
||||||
print("falling back to auto-detect")
|
print("falling back to auto-detect")
|
||||||
|
|
||||||
default_encoding = sys.getdefaultencoding()
|
|
||||||
required = sys.platform != 'win32'
|
required = sys.platform != 'win32'
|
||||||
ostype = require(["uname", "-s"], exit=required)
|
ostype = require(["uname", "-s"], exit=required)
|
||||||
cputype = require(['uname', '-m'], exit=required)
|
cputype = require(['uname', '-m'], exit=required)
|
||||||
|
@ -794,7 +795,7 @@ class RustBuild(object):
|
||||||
env.setdefault("RUSTFLAGS", "")
|
env.setdefault("RUSTFLAGS", "")
|
||||||
env["RUSTFLAGS"] += " -Cdebuginfo=2"
|
env["RUSTFLAGS"] += " -Cdebuginfo=2"
|
||||||
|
|
||||||
build_section = "target.{}".format(self.build_triple())
|
build_section = "target.{}".format(self.build)
|
||||||
target_features = []
|
target_features = []
|
||||||
if self.get_toml("crt-static", build_section) == "true":
|
if self.get_toml("crt-static", build_section) == "true":
|
||||||
target_features += ["+crt-static"]
|
target_features += ["+crt-static"]
|
||||||
|
@ -825,7 +826,11 @@ class RustBuild(object):
|
||||||
run(args, env=env, verbose=self.verbose)
|
run(args, env=env, verbose=self.verbose)
|
||||||
|
|
||||||
def build_triple(self):
|
def build_triple(self):
|
||||||
"""Build triple as in LLVM"""
|
"""Build triple as in LLVM
|
||||||
|
|
||||||
|
Note that `default_build_triple` is moderately expensive,
|
||||||
|
so use `self.build` where possible.
|
||||||
|
"""
|
||||||
config = self.get_toml('build')
|
config = self.get_toml('build')
|
||||||
if config:
|
if config:
|
||||||
return config
|
return config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue