Hacking on Clang is surprisingly easy
mort.coffee
mort.coffee
Oh, and buy a Threadripper. Seriously, you won't regret it.
[0] TableGen is LLVM's internal DSL swiss army knife. You can separately enable optimizations for TableGen independently of optimizations in the resulting LLVM builds, which you should basically always do unless you're working on TableGen itself.
Do you have a trick to link serially? I usually just do a `ninja -j 1` after the main build has failed.
[0]: https://github.com/icecc/icecream [1]: https://github.com/mozilla/sccache
Threadrippers seem really nice, but I did this on my laptop, not a desktop. Plus, when linking with debug symbols, my 16GB of RAM is by far a bigger limit than my four cores; I can't even run two link processes simultaneously without one of them being OOM killed (if I'm lucky).
How much difference are we talking? Do you have a concrete Intel CPU you can compare against to give ballpark numbers? And is this with various mitigations enabled or disabled?
Threadripper 3960x & 3970x from Nov 2019:
https://www.phoronix.com/scan.php?page=article&item=amd-linu...
^ <2min to compile LLVM 6
Core i9 9900K from Oct 2018:
https://www.phoronix.com/scan.php?page=article&item=intel-co...
^ here’s another, to give you an idea of how things have changed in the last ~year or so
For the article funny it refers to lisp.
Could maybe could you share your setup/workflow? For example do you use any IDEs? I'm trying to use Clion but it seems 16GB of RAM is not enough.
Any tips would be appreciated :)
When I wanted to test out a change, I had print statements in the clang source code and wrote a small test file which I could use to decide whether the prints I saw matched the prints I expected to see. Revolutionary stuff, I know. One trick I like when working with huge projects is to do my printf debugging with `fprintf(stderr, ...)` instead of the project's standard logging, just to avoid having to fight with log levels and such. (These print statements should obviously be removed once they're no longer necessary; here again, using fprintf helps, because they stand out.)
I didn't even think about tests, but I'm happy to report now that the entire test suite still works after my change. I don't think any kind of test-driven debugging would have worked here; almost none of the challenge was in the actual code behind the feature, it was all mostly just work to try to understand the code base. For example, "Oh, this looks like it's where lambdas are parsed. Let me add a print here and try to compile a file with a lambda to see if I'm right", or "Ok, I think I should end up in this branch if I have a fat arrow token in a lambda expression, let's add a print statement and modify the test file to check if that's true".
I don't know about a watch mode, but I'm not sure how much that would save you as you'd constantly be relinking a very large project. It might even be counter productive. As for tooling and editors, the build system is well integrated with visual studio on Windows, and I think xcode on mac os. For linting the llvm project has clang-format and clang-tidy which are excellent tools for any C++ project. I believe there is an extensive system test suite written in Python described in the hacking docs.
Bazel makes that simple for C++ projects.
https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
[](auto &&a, auto &&b) { return a.id() < b.id(); };
I vary much prefer the version above than the one author proposes for replacement. C++ is a beast as it is. No reason to introduce more miracles there. My opinion of coursehttps://clang.llvm.org/docs/Tooling.html
That way you don't have to maintain your own branch of clang.