# 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:
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)
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"]
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
filtered_submodules = []
submodules_names = []
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
+ external_llvm_provided = self.get_toml('llvm-config') or self.downloading_llvm()
+ llvm_needed = not self.get_toml('codegen-backends', 'rust') \
+ or "llvm" in self.get_toml('codegen-backends', 'rust')
for module in submodules:
if module.endswith("llvm-project"):
- # Don't sync the llvm-project submodule either if an external LLVM
- # was provided, or if we are downloading LLVM. Also, if the
- # submodule has been initialized already, sync it anyways so that
- # it doesn't mess up contributor pull requests.
- if self.get_toml('llvm-config') or self.downloading_llvm():
+ # Don't sync the llvm-project submodule if an external LLVM was
+ # provided, if we are downloading LLVM or if the LLVM backend is
+ # not being built. Also, if the submodule has been initialized
+ # already, sync it anyways so that it doesn't mess up contributor
+ # pull requests.
+ if external_llvm_provided or not llvm_needed:
if self.get_toml('lld') != 'true' and not llvm_checked_out:
continue
check = self.check_submodule(module, slow_submodules)