Only link to generated pch object when using msvc. (#12957)
backend: Only link to generated pch object when using msvc
This commit is contained in:
parent
675c323b19
commit
e4622ff1ee
|
@ -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…
Reference in New Issue