C compilation behind the scenes

简介:
1. Preprocessing: fix the source.
The first thing the compiler needs to do is fix the source. It needs to add in 
any extra header files it’s been told about using the #include directive. 
It might also need to expand or skip over some sections of the program. 
Once it’s done, the source code will be ready for the actual compilation.

2. Compilation: translate into assembly.
The C programming language probably seems pretty low level, but 
the truth is it’s not low level enough for the computer to understand. The 
computer only really understands very low-level machine code 
instructions, and the first step to generate machine code is to convert 
the C source code into assembly language symbols like this: 

movq  -24(%rbp), %rax
movzbl  (%rax), %eax
movl  %eax, %edx

Looks pretty obscure? Assembly language describes the individual 
instructions the central processor will have to follow when running the 
program. The C compiler has a whole set of recipes for each of the 
different parts of the C language. These recipes will tell the compiler how 
to convert an if statement or a function call into a sequence of assembly 
language instructions. But even assembly isn’t low level enough for the 
computer. That’s why it needs…


3. Assembly: generate the object code.
The compiler will need to assemble the symbol codes into machine or 
object code. This is the actual binary code that will be executed by 
the circuits inside the CPU. 

10010101 00100101 11010101 01011100

So are you all done? After all, you’ve taken the original C source code 
and converted it into the 1s and 0s that the computer’s circuits need. 
But no, there’s still one more step. If you give the computer several files 
to compile for a program, the compiler will generate a piece of object 
code for each source file. But in order for these separate object files to 
form a single executable program, one more thing has to occur…

4. Linking: put it all together.
Once you have all of the separate pieces of object code, you need to 
fit them together like jigsaw pieces to form the executable program. 
The compiler will connect the code in one piece of object code that 
calls a function in another piece of object code. Linking will also make 
sure that the program is able to call library code properly. Finally, the 
program will be written out into the executable program file using 
a format that is supported by the operating system. The file format 
is important, because it will allow the operating system to load the 
program into memory and make it run.

图例 : 
C compilation behind the scenes - 德哥@Digoal - The Heart,The World.
 
C compilation behind the scenes - 德哥@Digoal - The Heart,The World.
 
目录
相关文章
|
3天前
|
弹性计算 人工智能 安全
云上十五年——「弹性计算十五周年」系列客户故事(第二期)
阿里云弹性计算十五年深耕,以第九代ECS g9i实例引领算力革新。携手海尔三翼鸟、小鹏汽车、微帧科技等企业,实现性能跃升与成本优化,赋能AI、物联网、智能驾驶等前沿场景,共绘云端增长新图景。
|
9天前
|
存储 弹性计算 人工智能
【2025云栖精华内容】 打造持续领先,全球覆盖的澎湃算力底座——通用计算产品发布与行业实践专场回顾
2025年9月24日,阿里云弹性计算团队多位产品、技术专家及服务器团队技术专家共同在【2025云栖大会】现场带来了《通用计算产品发布与行业实践》的专场论坛,本论坛聚焦弹性计算多款通用算力产品发布。同时,ECS云服务器安全能力、资源售卖模式、计算AI助手等用户体验关键环节也宣布升级,让用云更简单、更智能。海尔三翼鸟云服务负责人刘建锋先生作为特邀嘉宾,莅临现场分享了关于阿里云ECS g9i推动AIoT平台的场景落地实践。
【2025云栖精华内容】 打造持续领先,全球覆盖的澎湃算力底座——通用计算产品发布与行业实践专场回顾
|
8天前
|
人工智能 自然语言处理 自动驾驶
关于举办首届全国大学生“启真问智”人工智能模型&智能体大赛决赛的通知
关于举办首届全国大学生“启真问智”人工智能模型&智能体大赛决赛的通知
|
8天前
|
云安全 人工智能 自然语言处理
阿里云x硅基流动:AI安全护栏助力构建可信模型生态
阿里云AI安全护栏:大模型的“智能过滤系统”。
|
9天前
|
编解码 自然语言处理 文字识别
Qwen3-VL再添丁!4B/8B Dense模型开源,更轻量,仍强大
凌晨,Qwen3-VL系列再添新成员——Dense架构的Qwen3-VL-8B、Qwen3-VL-4B 模型,本地部署友好,并完整保留了Qwen3-VL的全部表现,评测指标表现优秀。
661 7
Qwen3-VL再添丁!4B/8B Dense模型开源,更轻量,仍强大
|
4天前
|
人工智能 运维 Java
Spring AI Alibaba Admin 开源!以数据为中心的 Agent 开发平台
Spring AI Alibaba Admin 正式发布!一站式实现 Prompt 管理、动态热更新、评测集构建、自动化评估与全链路可观测,助力企业高效构建可信赖的 AI Agent 应用。开源共建,现已上线!
|
11天前
|
存储 机器学习/深度学习 人工智能
大模型微调技术:LoRA原理与实践
本文深入解析大语言模型微调中的关键技术——低秩自适应(LoRA)。通过分析全参数微调的计算瓶颈,详细阐述LoRA的数学原理、实现机制和优势特点。文章包含完整的PyTorch实现代码、性能对比实验以及实际应用场景,为开发者提供高效微调大模型的实践指南。
786 2
|
2天前
|
编解码 文字识别 算法
一张图能装下“千言万语”?DeepSeek-OCR 用视觉压缩长文本,效率提升10倍!
一张图能装下“千言万语”?DeepSeek-OCR 用视觉压缩长文本,效率提升10倍!
342 10