summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py5
-rw-r--r--mesonbuild/compilers/compilers.py3
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py4
3 files changed, 11 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index f665e610a..f7ba6468a 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.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)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index b59733745..8bc1294f8 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -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)
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 5dcebecef..d6ebd6e0d 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -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):