Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rustup support in default_build_triple for python3 #79845

Merged
merged 1 commit into from
Dec 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ def default_build_triple(verbose):
# If the user already has a host build triple with an existing `rustc`
# 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"])
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:
Expand All @@ -204,7 +206,6 @@ def default_build_triple(verbose):
print("rustup not detected: {}".format(e))
print("falling back to auto-detect")

default_encoding = sys.getdefaultencoding()
required = sys.platform != 'win32'
ostype = require(["uname", "-s"], exit=required)
cputype = require(['uname', '-m'], exit=required)
Expand Down Expand Up @@ -794,7 +795,7 @@ def build_bootstrap(self):
env.setdefault("RUSTFLAGS", "")
env["RUSTFLAGS"] += " -Cdebuginfo=2"

build_section = "target.{}".format(self.build_triple())
build_section = "target.{}".format(self.build)
target_features = []
if self.get_toml("crt-static", build_section) == "true":
target_features += ["+crt-static"]
Expand Down Expand Up @@ -825,7 +826,11 @@ def build_bootstrap(self):
run(args, env=env, verbose=self.verbose)

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')
if config:
return config
Expand Down