Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions builder/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ class PKG_TOOLS(Enum):

'versions': {
'default': {},
'latest': {}, # Latest stable/qualification version
'3': {
'c': "clang-3.9",
'cxx': "clang++-3.9",
Expand Down
31 changes: 27 additions & 4 deletions builder/core/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def _compiler_version(cc):


def _find_compiler_tool(name, versions):
# Filter out 'latest' from versions list. It will be handled separately.
versions = [v for v in versions if v != 'latest']

# look for the default tool, and see if the version is in the search set
path = util.where(name, resolve_symlinks=False)
if path:
Expand Down Expand Up @@ -180,8 +183,20 @@ def find_gcc_tool(name, version=None):
@staticmethod
def find_llvm_tool(name, version=None):
""" Finds clang, clang-tidy, lld, etc at a specific version, or the
latest one available """
versions = [version] if version else _clang_versions()
latest one available. If version is 'latest', resolves it dynamically. """
Comment on lines 185 to +186
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we are trying to resolve the latest one available when the version is not set, but we are also introducing a new latest version?
Sounds like we should just resolve the latest version dynamically when the version is None instead of the latest one in the hard-coded list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We introduce latest to be explicit about what we want to do when calling from CI; find the latest version of clang that can be used from llvm. None simply asks to use any available version and doesn't go through the process of looking for latest from llvm. I think we should keep this separation in behavior.

if version == 'latest':
# Import here to avoid circular dependency
from builder.imports.llvm import LLVM
resolved_version = LLVM.resolve_latest_version()
if resolved_version:
versions = [resolved_version]
else:
# Fall back to searching all known versions
versions = _clang_versions()
elif version:
versions = [version]
else:
versions = _clang_versions()
return _find_compiler_tool(name, versions)

@staticmethod
Expand Down Expand Up @@ -228,7 +243,8 @@ def _find_msvc(version, install_vswhere=True):

@staticmethod
def find_compiler(compiler, version=None):
""" Returns path, found_version for the requested compiler if it is installed """
""" Returns path, found_version for the requested compiler if it is installed.
If version is 'latest' for clang, it will be resolved dynamically. """
if compiler == 'clang':
if current_os() == "macos":
return Toolchain.find_apple_llvm_compiler(compiler, version)
Expand Down Expand Up @@ -329,7 +345,14 @@ def _find_compiler():

@staticmethod
def is_compiler_installed(compiler, version):
""" Returns True if the specified compiler is already installed, False otherwise """
""" Returns True if the specified compiler is already installed, False otherwise.
For 'latest' version of 'clang' compiler, this will resolve the actual version first. """
if version == 'latest' and compiler == 'clang':
# Import here to avoid circular dependency
from builder.imports.llvm import LLVM
resolved_version = LLVM.resolve_latest_version()
if resolved_version:
version = resolved_version
compiler_path, found_version = Toolchain.find_compiler(
compiler, version)
return compiler_path != None
Loading