LLVM 摸鱼笔记
LLVM 學習
There are multiple reasons why pieces of GCC cannot be reused as libraries, including rampant use of global variables, weakly enforced invariants, poorly-designed data structures, sprawling code base, and the use of macros that prevent the codebase from being compiled to support more than one front-end/target pair at a time. The hardest problems to fix, though, are the inherent architectural problems that stem from its early design and age. Specifically, GCC suffers from layering problems and leaky abstractions: the back end walks front-end ASTs to generate debug info, the front ends generate back-end data structures, and the entire compiler depends on global data structures set up by the command line interface.
關於 GCC 和 LLVM 的一個對比,能更加直觀的瞭解到 LLVM 的優勢。GCC 由於其誕生的比較早,對於編譯器的分層和抽象做的不太好,使得後端代碼生成調試信息需要跑一邊前端生成的AST。全局的數據結構,濫用的宏等等導致 GCC 代碼很難重用。