Map file is a plaintext file that contains information about where certain names and symbols exist in a binary produced by the linker. It also contain detailed information on all sections in your binary (code, data, etc.) and which OBJ/LIB each symbol is defined in. The Windows debuggers (like windbg.exe) can use map files to help locate where a program crashed based on a crash address. Map files are an old technology: with modern releases of the MSVC toolset, PDB (Program Database) files do everything map files do and more.
Producing a map file takes a long time. If you see the linker switch /MAP in your build but you don’t have a need for map files, you should remove the switch to speed up your build. We’ve done work recently to speed up the production of a map file but generating map files will be a slow process.
If you are one of the few who needs map files (for example, to quickly check whether interested set of functions or data are laid out in expected or correct order in binary), rest assured that we’re not removing them. However, here are a few points as to why you should turn off /MAP and simply use PDBs:
- Turning off map file generation reduces your build time. Though we recently improved throughput of map file generation in full linking scenario, the linker is not able to incrementally update an existing map file produced by prior linking, which hurts incremental linking throughput. This is different for PDB file, which can be surgically updated by the linker during incremental linking.
- Unlike PDB files, there is no strong binding between a binary and its corresponding map file. It is difficult to track which map file is for which versioned binary.
- Unlike PDB files, there is no support like symbol server for map files.
- Information in a PDB file is a superset of what is in a map file. In practice, almost all builds will by default produce PDB files.
Lastly, we have published DIA APIs that people can use to write their own tools to retrieve from PDB file all the information that is available today in a map file.
In closing
We know that build throughput is important for developers and we are continuing to improve our toolset’s throughput performance. You can read more about what we’re doing to improve throughput in our recent Visual Studio 2017 Throughput Improvements and Advice blog post. And remember to check your build to see if you’re generating unneeded map files!
If you have any feedback or suggestions for us, let us know. We can be reached via the comments below, via email (visualcpp@microsoft.com) and you can provide feedback via Help > Report A Problem in the product, or via Developer Community. You can also find us on Twitter (@VisualC) and Facebook (msftvisualcpp).
0 comments