This devcontainer is configured for the LLVM Learning Tutorial for the Procesadores de Lenguajes course. It uses the script setup.sh to install LLVM and related tools in a GitHub Codespaces environment. Use it as a template for your own LLVM projects.
- Base Image: Ubuntu 22.04 with C++ development tools
- LLVM: Version 17 with:
clangandclang++compilerslldlinkerllvm-configutilities- Development headers and tools
- Node.js: Version 20 (for LLVM JavaScript bindings if needed)
- VS Code Extensions:
- C/C++ Tools
- CMake Tools
- Clang-D language server
- Makefile Tools
-
Open in Codespaces:
- Click "Code" → "Codespaces" → "Create codespace on main"
- Wait ~3-5 minutes for setup to complete (LLVM installation takes time)
-
Verify Installation:
llvm-config --version clang --version bash scripts/llvm-health-check.sh
-
First End-to-End Run (factorial):
cd /workspaces/hello-llvm clang --target=x86_64-pc-linux-gnu examples/factorial-main.ll examples/factorial.ll -o tmp/f ./tmp/fExpected output:
120Note: these
.llfiles were generated on macOS, so in Linux/Codespaces you should keep the explicit--target=x86_64-pc-linux-gnuto avoid linker errors. -
Run Examples:
cd examples clang -S factorial.c -emit-llvm -o factorial.ll cat factorial.ll -
Optional: connect via SSH from your local terminal:
gh codespace list gh codespace ssh -c <codespace-name>
This project keeps SSH disabled by default to reduce startup time. If you need it, enable it by setting
ENABLE_SSHD=1in .devcontainer/devcontainer.json undercontainerEnv, then rebuild/create the Codespace.
To compile C to LLVM IR:
clang -S -emit-llvm yourfile.c -o yourfile.llTo compile C to assembly:
clang -S yourfile.c -o yourfile.s- The container pre-installs LLVM 17 by default
- All apt cache is cleaned after installation to minimize container size
- SSH keys are not mounted by default in Codespaces. Use GitHub authentication or Codespaces secrets when needed.
- SSH server installation is optional (
ENABLE_SSHD=1) to avoid extra setup time in classroom scenarios.
- If Codespaces fails while creating the container with a mount error mentioning
/.ssh, remove custommountsentries from .devcontainer/devcontainer.json.