TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to learn compilers: LLVM Edition

221 pointsby AlexDenisovover 3 years ago

6 comments

CalChrisover 3 years ago
1. <i>Getting Started with LLVM Core Libraries</i><p>It&#x27;s a bit dated (covers DAGISel rather than GlobalISel) but it gives a thorough introduction.<p>2. LLVM Developer Meeting tutorials<p>These are <i>really</i> good although you&#x27;ll have to put them in order yourself. They will be out of date, a little. LLVM is a moving target. Also, you don&#x27;t have to go through every tutorial. For example, MLIR is not for me.<p>3. LLVM documentation<p>I spent less time reading this than going through the Developer Meeting tutorials. I generally use it as a reference.<p>4. Discord, LLVM email list, git blame, LLVM Weekly<p>... because you will have questions.<p>5. MyFirstTypoFix (in the docs)<p>... when it comes time to submit a patch.<p>6. Mips backend<p>If you&#x27;re doing a backend, you will need a place to start. The LLVM documentation points you to the horribly out of date SPARC backend. Don&#x27;t even touch that. AArch64 and x86 are very full featured and thus very complex (100 kloc+). Don&#x27;t use those either. RISC-V is ok but concerns itself mostly with supporting new RISC-V features rather than keeping up to date with LLVM compiler services. Don&#x27;t use that either although <i>definitely</i> work through Alex Bradbury&#x27;s RISC-V backend tutorials. Read the Mips backend. It is actively maintained. It has good GlobalISel support almost on par with the flagship AArch64 and x86 backends.<p>BTW, Chris Lattner is a super nice guy.
评论 #29120607 未加载
评论 #29121785 未加载
chrisaycockover 3 years ago
I learned a lot about LLVM by looking at the compiler output from Clang:<p><pre><code> clang -emit-llvm -S sample.cpp </code></pre> The article mentions Clang&#x27;s AST, which can also be emitted:<p><pre><code> clang -Xclang -ast-dump -fsyntax-only sample.cpp </code></pre> And for checking compiler outputs across lots of languages and implementations, there&#x27;s always Matt Godbolt&#x27;s Compiler Explorer:<p><pre><code> https:&#x2F;&#x2F;godbolt.org</code></pre>
anonymousDanover 3 years ago
I have to say personally I find general program analysis (e.g. for security) a much more interesting topic than most vanilla compiler courses. For example I recently came across this course by the maintainers of soot: <a href="https:&#x2F;&#x2F;youtube.com&#x2F;playlist?list=PLamk8lFsMyPXrUIQm5naAQ08aK2ctv6gE" rel="nofollow">https:&#x2F;&#x2F;youtube.com&#x2F;playlist?list=PLamk8lFsMyPXrUIQm5naAQ08a...</a><p>Any pointers to similar courses much appreciated!
评论 #29125162 未加载
评论 #29131117 未加载
评论 #29127882 未加载
andrewchambersover 3 years ago
More great things:<p>- <a href="https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;" rel="nofollow">https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;vnmakarov&#x2F;mir" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vnmakarov&#x2F;mir</a>
评论 #29132443 未加载
tester34over 3 years ago
since here&#x27;s many compiler hackers then I&#x27;d want to ask question:<p>How do you distribute your frontend with LLVM?<p>Let&#x27;s say that I have lexer, parser and emitter written in e.g Haskell (random example)<p>I emit LLVM IR and then I use LLVM to generate something other<p>but the problem is, that I need to have LLVM binaries and I&#x27;d rather avoid telling people that want to contribute to my OSS project to install LLVM because it&#x27;s painful process as hell<p>So I thought about just adding &quot;binaries&quot; folder to my repo and put executables there, but the problem is that they&#x27;re huge as hell! and also when you&#x27;re on linux, then you don&#x27;t need windows&#x27; binaries<p>Another problem is that LLVM installer doesnt include all LLVM components that I need (llc and wasm-ld), so I gotta compile it and tell cmake (iirc) to generate those<p>I thought about creating 2nd repo where there&#x27;d be all binaries compiles for all platforms: mac, linux, windows and after cloning my_repo1, then instruction would point to download specific binaries<p>How you people do it?
评论 #29118791 未加载
评论 #29119677 未加载
评论 #29125138 未加载
评论 #29118649 未加载
Lamad123over 3 years ago
You could&#x27;ve mentioned Crafting Interpreters. It&#x27;s an excellent book!!! (At least for the rest of us, mere mortals!)
评论 #29126847 未加载