diff options
author | Haibo Huang <hhb@google.com> | 2020-04-24 13:39:53 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-04-24 13:39:53 -0700 |
commit | 362106a6bf996f6ddb37d65b9a03a436f7b30ec7 (patch) | |
tree | f8989ef68aac2c075be1ef97875474a1efc13be9 /toolchains.py | |
parent | e12c534a1ddb7b4ae7c3b699d04347b5129bddc0 (diff) | |
download | llvm_android-362106a6bf996f6ddb37d65b9a03a436f7b30ec7.tar.gz |
Explicitly sets the toolchain used to build runtime.
This fixed PGO build. In that build, stage2 is instrumented. In the old
implementation, stage1 will be used to build runtimes.
Change-Id: Ia350b9ec5257131692743a853f5fe22638b87933
Diffstat (limited to 'toolchains.py')
-rw-r--r-- | toolchains.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/toolchains.py b/toolchains.py index e1c03db..73a8d3d 100644 --- a/toolchains.py +++ b/toolchains.py @@ -17,10 +17,8 @@ import functools from pathlib import Path -from typing import Optional from builder_registry import BuilderRegistry -import hosts import paths import version @@ -77,7 +75,8 @@ def get_prebuilt_toolchain() -> Toolchain: return _build_toolchain_for_path(paths.CLANG_PREBUILT_DIR, Path('.')) -def _get_toolchain_from_builder(builder) -> Toolchain: +def get_toolchain_from_builder(builder) -> Toolchain: + """Gets the toolchain from a toolchain builder.""" return _build_toolchain_for_path(builder.install_dir, builder.output_dir) @@ -85,12 +84,17 @@ def get_toolchain_by_name(name: str) -> Toolchain: """Tet a toolchain by name.""" if name == 'prebuilt': return get_prebuilt_toolchain() - return _get_toolchain_from_builder(BuilderRegistry.get(name)) + return get_toolchain_from_builder(BuilderRegistry.get(name)) + + +_RUNTIME_TOOLCHAIN: Toolchain = get_prebuilt_toolchain() +def set_runtime_toolchain(toolchain: Toolchain) -> None: + """Sets the toolchain used to build runtime.""" + global _RUNTIME_TOOLCHAIN # pylint: disable=global-statement + _RUNTIME_TOOLCHAIN = toolchain def get_runtime_toolchain() -> Toolchain: """Gets the toolchain used to build runtime.""" - builder = BuilderRegistry.get('stage2') - if not builder or builder.build_instrumented or builder.debug_build: - builder = BuilderRegistry.get('stage1') - return _get_toolchain_from_builder(builder) + global _RUNTIME_TOOLCHAIN # pylint: disable=global-statement + return _RUNTIME_TOOLCHAIN |