Skip to content

[MSVC/Fortran] Add /Fd flag when /Zi or /ZI flags are detected

Rafaël Kooi requested to merge RA-Kooi/waf:MSVCFix into master

Fixes #1731

As discussed on IRC, we should use the /Fd flag to prevent races with the linking step.
The compiler generates a PDB file with the name vcx0.pdb, where x is the compiler major version.
When compiling a project the compiler will complain about concurrent writes to the PDB, and suggest /FS as solution.
There are 2 reasons why we shouldn't use /FS:

  1. It serializes writes to the PDB file through mspdbserv, which causes a race with the linking step.
    This race is caused by the compiler exiting after compilation has finished, but mspdbserv still writing to the PDB.
    A possible solution would be to communicate with mspdbserv somehow to see if the writes to the PDB have been completed.
  2. It slows down the build quite a bit.

Currently this code does the following things:

  • Detect -Zi, /Zi, -ZI, and /ZI, and inserts a per source file unique /Fd flag.
  • Strip the /-FS and /-MP flags, /MP is stripped because it enables /FS, and /MP would interfere with task generation.
  • Add the PDB as an output node, and linker dependency.

Merge request reports