Only link to generated pch object when using msvc. (#12957)

backend: Only link to generated pch object when using msvc
pull/12971/head
Elliot 9 months ago committed by GitHub
parent 675c323b19
commit e4622ff1ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      mesonbuild/backend/ninjabackend.py
  2. 3
      mesonbuild/compilers/compilers.py
  3. 4
      mesonbuild/compilers/mixins/visualstudio.py

@ -3121,7 +3121,10 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += self._generate_single_compile(target, compiler)
commands += self.get_compile_debugfile_args(compiler, target, objname)
dep = dst + '.' + compiler.get_depfile_suffix()
return commands, dep, dst, [objname], source
link_objects = [objname] if compiler.should_link_pch_object() else []
return commands, dep, dst, link_objects, source
def generate_gcc_pch_command(self, target, compiler, pch):
commands = self._generate_single_compile(target, compiler)

@ -843,6 +843,9 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]:
return []
def should_link_pch_object(self) -> bool:
return False
def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]:
return self.linker.get_debugfile_name(targetfile)

@ -425,6 +425,10 @@ class MSVCCompiler(VisualStudioLikeCompiler):
def get_pch_base_name(self, header: str) -> str:
return os.path.basename(header)
# MSVC requires linking to the generated object file when linking a build target
# that uses a precompiled header
def should_link_pch_object(self) -> bool:
return True
class ClangClCompiler(VisualStudioLikeCompiler):

Loading…
Cancel
Save