Usage
Examples
Arguments
JavaScript or TypeScript source file
Output executable file path (
.exe on Windows)Compiler Options
C compiler to use:
clang, gcc, or zigclang: Default, good optimization and performancegcc: Alternative, widely availablezig: Experimental, cross-compilation support
C compiler optimization level:
Ofast, O3, O2, O1, or O0Ofast: Maximum optimization (default), may break strict complianceO3: Aggressive optimizationO2: Moderate optimization, good balanceO1: Basic optimizationO0: No C compiler optimization, fastest compilation
JavaScript Compilation Flags
All standard optimization flags apply:Porffor optimization level (0-3)
Debug mode - disables stripping, includes debug symbols
Enable TypeScript parsing
Optimize using type annotations
Compilation Process
The native compilation involves multiple stages:- JavaScript → Wasm: Porffor compiles JS to WebAssembly
- Wasm → C: 2c translates Wasm bytecode to C source
- C → Native: C compiler produces native executable
- Strip: Symbols removed (unless
-dflag used)
Output Binary Details
By default, output binaries are:- Fully optimized with
-Ofast - Stripped of debug symbols
- Statically linked where possible
- Platform-specific native code
Platform Support
- Linux
- macOS
- Windows
Performance Tuning
Maximum Performance
- JavaScript optimizations (
-O3) - Aggressive C optimization (
--cO=Ofast) - Type-based optimization (
--opt-types)
Debug Performance
- Debugging crashes
- Profiling with external tools
- Understanding generated code
Balanced Build
- Development iteration
- Reasonable performance
- Faster compile times
Compiler-Specific Features
- Clang (Default)
- GCC
- Zig
- Modern optimization techniques
- Good error messages
- Fast compilation
- Recommended for most use cases
Binary Size Comparison
Binaries include no runtime dependencies - Porffor has zero constant runtime/preluded code.
Debugging Native Binaries
Environment Variables
Override C compiler (alternative to
--compiler)Troubleshooting
Compiler Not Found
Runtime Errors
Large Binary Size
Slow Compilation
Cross-Compilation
While Porffor itself is platform-independent, native compilation produces platform-specific binaries.Comparison with Other Approaches
| Feature | Native | Wasm | Run |
|---|---|---|---|
| Startup Time | Fastest | Fast | Fast |
| Binary Size | Small | Smaller | N/A |
| Performance | Best | Excellent | Very Good |
| Portability | Platform-specific | Cross-platform | Requires Porffor |
| Distribution | Single binary | Requires runtime | Source code |
Next Steps
C Output
View generated C source code
Profile
Optimize before compiling
Lambda
Deploy as serverless function
Run Command
Test before compiling