Skip to content

Instantly share code, notes, and snippets.

@didito
Last active July 21, 2023 08:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save didito/b7b2fc85951ca5a5669dd2e9373814af to your computer and use it in GitHub Desktop.
Save didito/b7b2fc85951ca5a5669dd2e9373814af to your computer and use it in GitHub Desktop.
1. C/C++ BUILDS:
================
MSVC:
=====
c1.dll: the C frontend
c1xx.dll: the C++ frontend
c2.dll: the optimizer
measure:
- use /Bt flag, to get time spent in frontend vs backend compiler parts
- use /d1reportTime for only frontend
- use /d2cgsummary for cl.exe
- use /d2:-cgsummary for the linker
- use /showIncludes
- use /time for the linker
possible culprits:
- forced inline
- templates (parser and optimizer)
- const
- remove __assume
- file I/O (includes) -> SSD, RAM drive
advice:
- use PCH
- use forward declarations
- minimize includes
- use pimpl idiom
- strip dead code
- unity / lump builds
- linker: use /DEBUG:fastlink (beware of problembs in VS2015, i.e. with VTune)
http://lectem.github.io/msvc/reverse-engineering/build/2019/01/21/MSVC-hidden-flags.html
https://blogs.msdn.microsoft.com/vcblog/2018/01/04/visual-studio-2017-throughput-improvements-and-advice/
http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
http://aras-p.info/blog/2018/01/12/Minimizing-windows.h/
http://aras-p.info/blog/2017/10/24/Slow-to-Compile-Table-Initializers/
http://aras-p.info/blog/2017/10/09/Forced-Inlining-Might-Be-Slow/
Dumping Object Memory Layout:
- /d1reportAllClassLayout
- /d1reportAllClassLayout
https://ofekshilon.com/2010/11/07/d1reportallclasslayout-dumping-object-memory-layout/
http://www.lenholgate.com/blog/2014/07/useful-undocumented-visual-studio-compiler-switches.html
Clang:
======
-fsave-optimization-record
Dumping Object Memory Layout:
-fdump-record-layouts / -fdump-record-layouts-simple / -fdump-vtable-layouts
https://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang
GCC:
====
-ftree-vectorize
-fopt-info-vec-missed
--fdump-class-hierarchy / --fdump-translation-unit / --fdump-tree-original
more Infos:
===========
https://slides.com/onqtam/faster_builds#/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment