今日已更新 498 条资讯 | 累计 20470 条内容
关于我们

标签:#compiling

找到 2 篇相关文章

开发者

C++ Optimized Compilation Ways

The very common way we know to compile a C++ program is by running the following command: g++ filename.cpp -o filename Talking in terms of stages of optimized compilation, this method is the basic one — we can say stage 0, also written as: g++ -O0 filename.cpp -o filename There are a few more, from zero to three. Let's talk about these ways of compilation. 1] -O0 : No Optimization (Default) Fast compile time. Every variable gets a real stack slot; nothing gets reordered or removed. 2] -O1 : Basic Optimization Some dead code elimination. Simple register allocation. 3] -O2 : 'Standard' Optimization Register allocation. Dead code elimination. Inlining small functions. Loop unrolling and vectorization. Constant folding/propagation. Does not enable optimizations that trade accuracy/safety for speed. 4] -O3 : More Aggressive than -O2 Sometimes faster, sometimes not. Can hurt cache performance. Other than this, there is also a space-optimization option. 5] -Os : Optimization for Size Instead of Speed The command to use these optimizations is as follows: g++ -O2 filename.cpp -o filename Remember, in -O2 the "O" is a capital letter, not a zero — the same applies to the other optimization levels. If you don't know what's going on, or you just wish to compile C++ files the way developers do, use the following standard command: g++ -O2 filename.cpp -o filename

2026-07-16 原文 →
开发者

How I Built My Own Programming Language from Scratch

I Built a Programming Language Called Zen Building a programming language had been something I wanted to do for a long time. What I didn't realize when I started was how much work exists beyond parsing a few tokens and generating some code. A language is not just a parser or a compiler backend. It is tooling, developer experience, documentation, installation, error handling, runtime support, and countless design decisions. After multiple attempts and many lessons learned, I'm excited to share Zen. Why a Third Attempt? Zen is not the first language project I started. My first attempts taught me a lot, but they never reached a stage where I felt comfortable sharing them publicly. The architecture was incomplete, important components were missing, and the overall developer experience wasn't where I wanted it to be. Instead of abandoning the idea, I kept iterating. Each attempt helped me better understand: Compiler architecture Language design LLVM Runtime integration Tooling and usability Error handling Project structure Zen is the result of those lessons. What Is Zen? Zen is a programming language with its own compiler pipeline and LLVM-based backend. The goal was not just to generate code, but to create a complete language ecosystem that developers can actually install and use. Zen currently includes: Lexer Parser AST generation LLVM IR generation Native executable generation through LLVM Runtime integration Standard library integration Command-line tooling Installation system Documentation website Compiler Pipeline The compilation process follows a traditional compiler architecture: Source Code ↓ Lexer ↓ Parser ↓ AST ↓ LLVM IR Generation ↓ LLVM Optimization ↓ Object Files ↓ Native Executable LLVM handles optimization and machine code generation, allowing Zen to produce native binaries. Command Line Interface Zen provides several commands for development and inspection: zen run zen build zen ir zen ast zen tokens zen clean This allows users to inspect different stage

2026-06-12 原文 →