
compile-compcert
by letta-ai
A shared repository for skills.
SKILL.md
name: compile-compcert description: Guidance for building CompCert, a formally verified C compiler. This skill applies when tasks involve compiling CompCert from source, setting up Coq/OCaml environments with opam, or building software with strict proof assistant dependencies. Use for CompCert compilation, Coq-dependent project builds, or formal verification toolchain setup.
Building CompCert (Verified C Compiler)
Overview
CompCert is a formally verified optimizing C compiler. Building it requires careful coordination of Coq (proof assistant), OCaml, and Menhir (parser generator) versions. The primary challenge is ensuring version compatibility across all dependencies before beginning compilation.
Critical Pre-Build Analysis
Before installing any dependencies, perform these steps in order:
1. Obtain Source First
Download and extract the CompCert source before installing dependencies:
- Download the specific version tarball from GitHub releases or official mirrors
- Extract and locate the
configurescript - Read the configure script to identify supported Coq versions
2. Check Version Requirements
Examine CompCert's configure script to find exact dependency requirements:
- Supported Coq version range (often specific minor versions only)
- Required OCaml version
- Required Menhir version
- The configure script typically contains explicit version checks
3. Verify System Compatibility
Check system requirements before proceeding:
- Architecture (x86_64 is most commonly supported for full backend)
- Operating system (Linux is primary target)
- Available memory (builds can be memory-intensive)
- Disk space for build artifacts
Dependency Installation Approach
Environment Setup with opam
CompCert requires opam (OCaml Package Manager) for managing OCaml and Coq:
- Initialize opam if not already done
- Create a switch with appropriate OCaml version
- Set up the environment:
eval $(opam env) - Install dependencies in correct order: OCaml → Menhir → Coq
Version Selection Strategy
To avoid wasted effort from incompatible versions:
- Check CompCert's configure script BEFORE installing Coq
- Install the highest compatible Coq version within the supported range
- Ensure Menhir version matches requirements
- Verify all versions after installation
Build Process
Configuration
Run configure with appropriate target:
- Common targets:
x86_64-linux,x86_32-linux,arm-linux - Check available targets with
./configure --help - Note the installation prefix and binary locations
Compilation
Build considerations:
- Full build includes proof checking and can be memory-intensive
- If encountering OOM (Out of Memory) errors:
- Reduce parallel jobs (
make -j1instead of parallel) - Consider adding swap space if in a container that allows it
- Monitor memory usage during proof checking phases
- Reduce parallel jobs (
Installation and Verification
After successful build:
- Note where
ccompbinary is installed - Create symlinks if binary needs to be at a specific location
- Test with a simple C program compilation
- Verify the reported version matches expected version
Common Pitfalls
Dependency Order Mistakes
- Installing Coq before checking CompCert's requirements wastes time
- Multiple failed installation attempts consume significant resources
- Always read project requirements before installing dependencies
Memory Issues
- Coq proof checking is memory-intensive
- Container environments may have memory limits
- Swap creation may be restricted in some environments
- Sequential builds (
-j1) use less memory than parallel builds
Environment Persistence
- opam environment must be sourced in each shell session
eval $(opam env)needed before running opam-installed tools- Consider setting up persistent environment configuration
Version Verification
- CompCert version reported at runtime may differ from release tag
- Version 3.13.1 source may report as "3.13" at runtime
- Verify functionality rather than relying solely on version strings
Verification Checklist
Before considering the task complete:
- Binary exists at required location
-
ccomp --versionexecutes without error - Simple C program compiles successfully
- Generated executable runs correctly
- Any linker warnings are understood (some are benign)
Resource Management
Cleanup Considerations
After successful build:
- Source tarballs can be removed
- Extracted source directories may be kept for reference or removed
- Build artifacts in source tree consume significant space
Security Notes
- Verify source downloads against official checksums when available
- Building from official release tarballs preferred over arbitrary commits
- Note and investigate any unexpected warnings during compilation
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon