简体   繁体   中英

Compiler design frontend calculation in the main function for Clang and Zig

I have started reading the source code of clang and zig-lang . Unfortunately, the source codes are complicated and I am not able to find out where is frontend of these compilers are called in the main function.

In clang , the closer place I have found is here but it does not look like processing the compilation frontend.

In zig-lang , the main function is even messier and very hard to understand. I just could find the de facto main function (main0) here .

Though, explaining the stages of these compilers and pointing to their code is appreciated, just the point of where frontends computations are called is sufficient for me.

The main zig compiler is executed from Compilation.performAllTheWork . This function loops over all the compilation items and compiles them. ( main()buildOutputTypeupdateModuleCompilation.update → Compilation.performAllTheWork)

Stage1 (the default compiler in zig 0.8.0, written in C++) is called when stage1_module items are found in the work queue from Compilation.updateStage1Module . The bulk of compilation happens from codegen_build_object (called from zig_stage1_build_object )

Stage2 (the work-in-progress faster compiler written in Zig) is more tightly integrated into the work queue because it supports incremental compilation and is called in these branches of the work queue switch.


Clang starts somewhere, maybe in clang.lib.frontend.CompilerInvocation ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM