Building stuff from source
I wish more C&#x2F;C++ projects used &quot;unity builds&quot; -- there&#x27;s only one translation unit containing all the code, usually by #include-ing all the .c and .cpp files. It makes &quot;build configuration&quot; incredibly easy by largely doing away with it. And C&#x2F;C++ compilers just copy paste your code in via the preprocessor when doing #include of headers, etc., anyway, so it&#x27;s not a wacky concept at all.<p>- It&#x27;s just one compiler invocation. If you want to support multiple compilers, just write that one invocation for each one. Usually clang and gcc will be the exact same. cl and clang-cl similarly. Even if you support multiple platforms, writing N command lines for N platforms is usually less characters than any build system out there, and simpler, and less opaque as well.<p>- You can guarantee exactly the flags you want are being set. No more problems where you set -fwrapv or -march or whatever on one sub-project, but forgot on another, etc., or trouble figuring out what&#x27;s the &quot;CMake way&quot; of specifying something. Getting these types of flags working with build tools becomes quite frustrating and error prone the more specific your requirements are.<p>- Not something I dealt with working at trading companies, but distro package maintainers can very easily patch in their own flags, or more often can get by without even that if your unity build can just put $CFLAGS or $CXXFLAGS at the end of the command line.<p>- Wouldn&#x27;t tout this as a major benefit as it has saved me maybe once, but it basically forces a compiler error for certain violations of the One Definition Rule, because the compiler can see the duplicate and conflicting definition at compile time, instead of the linker silently picking one of the conflicting definitions and masking the problem.<p>I&#x27;ve found that there are ample ways to keep compilation speed pretty reasonable (we&#x27;re talking &lt;10 seconds), even compiling all code at once on large, complicated projects. The general solution is to not let your compile times get crazy in the first place, which means not using a lot of general purpose external dependencies or templates.<p>Another technique is, for dev, split the unity build in two. Unity build of files you&#x27;re actively working on or of files you need to use -O0 or -0g on for a while, and unity of the rest, and link.<p>Games people often carry that idea of a split unity build further. Split the structure of the code itself, and have an &quot;infrastructure&quot; unity build, a &quot;business logic&quot; unity build, and the infra code actually dynamically loads the logic .so&#x2F;.dll, and can reload it on demand (so you can iterate fast on logic, without recompiling or even linking your infra code). I don&#x27;t work on games so this hasn&#x27;t been worth it for my projects, but I have definitely worked on projects structured with a control process (slow, smart, size not a critical issue), and a worker process (fast, dumb, size critical), which gets you pretty much the same structure by different means. You can easily get 1s turnaround for builds of the worker. I never used this structure specifically in order to help dev turnaround, rather it was intrinsic to the project requirements and faster dev was a happy knock-on effect.<p>I&#x27;d be a happy man if I saw a post like this in the future that at least started with:<p><pre><code>    If you see build.sh or build.ps1&#x2F;bat, just run that and you&#x27;re done.
</code></pre>
Edit, PS: &quot;unity build&quot; obviously has nothing to do with Unity the game engine. In fact, I never even called them &quot;unity builds&quot; at work, I had never heard that term. I always called it a blob build, or a STU (single translation unit) build, or whatever analogy was funny that day.