in builder/core/toolchain.py [0:0]
def default_compiler(target=None, arch=None):
""" Finds the system default compiler and returns (compiler, version) """
if Toolchain._default_compiler and Toolchain._default_version:
return Toolchain._default_compiler, Toolchain._default_version
if target and arch and _is_cross_compile(target, arch):
return 'gcc', '4.8'
def _find_compiler():
compiler = None
version = None
platform = current_os()
if platform != 'windows':
# resolve CC and /usr/bin/cc
for env_cc in (util.where(os.environ.get('CC', None)), util.where('cc')):
if env_cc:
cc, ccver = _compiler_version(env_cc)
if cc and ccver:
return cc, ccver
# Try to find clang or gcc
clang_path, clang_version = Toolchain.find_llvm_tool(
'clang')
gcc_path, gcc_version = Toolchain.find_gcc_tool('gcc')
if clang_path:
compiler = 'clang'
version = clang_version
elif gcc_path:
compiler = 'gcc'
version = gcc_version
else:
print(
'Neither GCC or Clang could be found on this system, perhaps not installed yet?')
else:
compiler = 'msvc'
version = Toolchain.find_msvc()[1]
if not compiler or not version:
print('WARNING: Default compiler could not be found')
print('Default Compiler: {} {}'.format(compiler, version))
return compiler, version
Toolchain._default_compiler, Toolchain._default_version = _find_compiler()
return Toolchain._default_compiler, Toolchain._default_version