diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-05 03:49:09 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-10 00:40:16 +0530 |
commit | 88f1d400c070fdd95d00298584c6ac18cf087a14 (patch) | |
tree | 430e8fdd8cf5679c0c1093eff4e89d96f446ba25 | |
parent | 69756fdabb123b3e0499f6daa0f32ef06b406614 (diff) | |
download | meson-88f1d400c070fdd95d00298584c6ac18cf087a14.zip meson-88f1d400c070fdd95d00298584c6ac18cf087a14.tar.gz meson-88f1d400c070fdd95d00298584c6ac18cf087a14.tar.bz2 |
Fix debug PCH builds with MSVC 2012 and later
With MSVC 2013 and newer, using pre-compiled headers with .pdb debugging
fails with the following error message:
fatal error C1041: cannot open program database '[...]\prog.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS
So we use /FS when PCH is enabled. When PCH is enabled and debugging is
disabled, this will have no effect since .pdb files will not be written.
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 63380bd..af96f3d 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1694,9 +1694,9 @@ rule FORTRAN_DEP_HACK if target.has_pch(): tfilename = self.get_target_filename_abs(target) - return compiler.get_compile_debugfile_args(tfilename) + return compiler.get_compile_debugfile_args(tfilename, pch=True) else: - return compiler.get_compile_debugfile_args(objfile) + return compiler.get_compile_debugfile_args(objfile, pch=False) def get_link_debugfile_args(self, linker, target, outname): return linker.get_link_debugfile_args(outname) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 2feae88..bbe6a72 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -435,7 +435,7 @@ class Compiler(): # Some compilers (msvc) write debug info to a separate file. # These args specify where it should be written. - def get_compile_debugfile_args(self, rel_obj): + def get_compile_debugfile_args(self, rel_obj, **kwargs): return [] def get_link_debugfile_args(self, rel_obj): @@ -1883,10 +1883,19 @@ class VisualStudioCCompiler(CCompiler): raise MesonException('Compiling test app failed.') return not(warning_text in stde or warning_text in stdo) - def get_compile_debugfile_args(self, rel_obj): + def get_compile_debugfile_args(self, rel_obj, pch=False): pdbarr = rel_obj.split('.')[:-1] pdbarr += ['pdb'] - return ['/Fd' + '.'.join(pdbarr)] + args = ['/Fd' + '.'.join(pdbarr)] + # When generating a PDB file with PCH, all compile commands write + # to the same PDB file. Hence, we need to serialize the PDB + # writes using /FS since we do parallel builds. This slows down the + # build obviously, which is why we only do this when PCH is on. + # This was added in Visual Studio 2013 (MSVC 18.0). Before that it was + # always on: https://msdn.microsoft.com/en-us/library/dn502518.aspx + if pch and mesonlib.version_compare(self.version, '>=18.0'): + args = ['/FS'] + args + return args def get_link_debugfile_args(self, targetfile): pdbarr = targetfile.split('.')[:-1] |