module-driver
模块分析:driver
1. 角色定位
driver/ 实现 ccomp
与相关工具的命令行驱动,管理预处理、编译、汇编与链接流程,并负责生成各种中间输出。
2.
编译主入口(Driver.ml)
- 入口函数组织:
process_c_file/process_i_file/process_s_file/process_S_file- 根据
-E,-S,-c等选项控制流程
compile_c_file:- 设置中间 IR dump 输出目标
parse_c_file→Compiler.transf_c_program→Asmexpand.expand_programPrintAsm.print_program输出汇编
- 汇编与链接:调用
Assembler/Linker模块,依赖外部工具链
3.
前端配置(Frontend.ml)
- 负责宏、ABI、机器配置初始化:
predefined_macros+abi_macrosMachine.config按Configuration.arch等参数设置
- 提供统一的
parse_c_file:- 初始化 Debug/Sections/CPragmas
- 调用
Parse.preprocessed_file+C2C.convertProgram
4. 选项与配置管理
Clflags.ml,CommonOptions.ml管理编译选项Configuration.ml记录目标架构/ABI/工具链信息Driveraux.ml管理临时文件与通用辅助
5. 交互工具
Interp.ml:解释器模式(-interp)执行 C 代码Timing.ml:时间统计