compilers: Make sure to not use ccache in compiler checks

ccache was used in all command lines but disabled using CCACHE_DISABLE
in Compiler.compile() method. Wrapping invokations still has a cost,
especially on Windows.

With sccache things are even worse because CCACHE_DISABLE was not
respected at all, making configure *extremely* slow on Windows when
sccache is installed.
pull/10744/merge
Xavier Claessens 3 years ago committed by Eli Schwartz
parent 2961adb8c8
commit e68fcac919
  1. 7
      mesonbuild/compilers/compilers.py
  2. 5
      mesonbuild/compilers/mixins/clike.py
  3. 6
      mesonbuild/compilers/mixins/elbrus.py
  4. 2
      mesonbuild/compilers/mixins/gnu.py
  5. 2
      mesonbuild/compilers/rust.py

@ -503,6 +503,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
linker: T.Optional['DynamicLinker'] = None,
full_version: T.Optional[str] = None, is_cross: bool = False):
self.exelist = ccache + exelist
self.exelist_no_ccache = exelist
# In case it's been overridden by a child class already
if not hasattr(self, 'file_suffixes'):
self.file_suffixes = lang_suffixes[self.language]
@ -593,8 +594,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def symbols_have_underscore_prefix(self, env: 'Environment') -> bool:
raise EnvironmentException('%s does not support symbols_have_underscore_prefix ' % self.get_id())
def get_exelist(self) -> T.List[str]:
return self.exelist.copy()
def get_exelist(self, ccache: bool = True) -> T.List[str]:
return self.exelist.copy() if ccache else self.exelist_no_ccache.copy()
def get_linker_exelist(self) -> T.List[str]:
return self.linker.get_exelist()
@ -815,7 +816,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
if extra_args:
commands += extra_args
# Generate full command-line with the exelist
command_list = self.get_exelist() + commands.to_native()
command_list = self.get_exelist(ccache=not no_ccache) + commands.to_native()
mlog.debug('Running compile:')
mlog.debug('Working directory: ', tmpdirname)
mlog.debug('Command line: ', ' '.join(command_list), '\n')

@ -179,9 +179,6 @@ class CLikeCompiler(Compiler):
def get_depfile_suffix(self) -> str:
return 'd'
def get_exelist(self) -> T.List[str]:
return self.exelist.copy()
def get_preprocess_only_args(self) -> T.List[str]:
return ['-E', '-P']
@ -1194,7 +1191,7 @@ class CLikeCompiler(Compiler):
if self.id != 'clang':
raise mesonlib.MesonException('Cannot find framework path with non-clang compiler')
# Construct the compiler command-line
commands = self.get_exelist() + ['-v', '-E', '-']
commands = self.get_exelist(ccache=False) + ['-v', '-E', '-']
commands += self.get_always_args()
# Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
commands += env.coredata.get_external_args(self.for_machine, self.language)

@ -48,7 +48,7 @@ class ElbrusCompiler(GnuLikeCompiler):
def get_library_dirs(self, env: 'Environment', elf_class: T.Optional[int] = None) -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
stdo = Popen_safe(self.get_exelist(ccache=False) + ['--print-search-dirs'], env=os_env)[1]
for line in stdo.split('\n'):
if line.startswith('libraries:'):
# lcc does not include '=' in --print-search-dirs output. Also it could show nonexistent dirs.
@ -59,7 +59,7 @@ class ElbrusCompiler(GnuLikeCompiler):
def get_program_dirs(self, env: 'Environment') -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
stdo = Popen_safe(self.get_exelist(ccache=False) + ['--print-search-dirs'], env=os_env)[1]
for line in stdo.split('\n'):
if line.startswith('programs:'):
# lcc does not include '=' in --print-search-dirs output.
@ -70,7 +70,7 @@ class ElbrusCompiler(GnuLikeCompiler):
def get_default_include_dirs(self) -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
p = subprocess.Popen(self.exelist + ['-xc', '-E', '-v', '-'], env=os_env, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = subprocess.Popen(self.get_exelist(ccache=False) + ['-xc', '-E', '-v', '-'], env=os_env, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stderr = p.stderr.read().decode('utf-8', errors='replace')
includes = []
for line in stderr.split('\n'):

@ -184,7 +184,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return gnulike_instruction_set_args.get(instruction_set, None)
def get_default_include_dirs(self) -> T.List[str]:
return gnulike_default_include_dirs(tuple(self.exelist), self.language).copy()
return gnulike_default_include_dirs(tuple(self.get_exelist(ccache=False)), self.language).copy()
@abc.abstractmethod
def openmp_flags(self) -> T.List[str]:

@ -110,7 +110,7 @@ class RustCompiler(Compiler):
return rust_buildtype_args[buildtype]
def get_sysroot(self) -> str:
cmd = self.exelist + ['--print', 'sysroot']
cmd = self.get_exelist(ccache=False) + ['--print', 'sysroot']
p, stdo, stde = Popen_safe(cmd)
return stdo.split('\n', maxsplit=1)[0]

Loading…
Cancel
Save