clang-tool-chain 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of clang-tool-chain might be problematic. Click here for more details.
- clang_tool_chain/__init__.py +0 -0
- clang_tool_chain/__version__.py +4 -0
- clang_tool_chain/checksums.py +270 -0
- clang_tool_chain/cli.py +575 -0
- clang_tool_chain/downloader.py +1325 -0
- clang_tool_chain/downloads/README.md +144 -0
- clang_tool_chain/downloads/__init__.py +22 -0
- clang_tool_chain/downloads/__main__.py +11 -0
- clang_tool_chain/downloads/create_hardlink_archive.py +390 -0
- clang_tool_chain/downloads/create_iwyu_archives.py +330 -0
- clang_tool_chain/downloads/deduplicate_binaries.py +217 -0
- clang_tool_chain/downloads/download_binaries.py +463 -0
- clang_tool_chain/downloads/expand_archive.py +260 -0
- clang_tool_chain/downloads/extract_mingw_sysroot.py +349 -0
- clang_tool_chain/downloads/fetch_and_archive.py +1376 -0
- clang_tool_chain/downloads/strip_binaries.py +436 -0
- clang_tool_chain/downloads/test_compression.py +259 -0
- clang_tool_chain/fetch.py +158 -0
- clang_tool_chain/paths.py +93 -0
- clang_tool_chain/sccache_runner.py +160 -0
- clang_tool_chain/wrapper.py +1383 -0
- clang_tool_chain-1.0.2.dist-info/METADATA +1766 -0
- clang_tool_chain-1.0.2.dist-info/RECORD +26 -0
- clang_tool_chain-1.0.2.dist-info/WHEEL +4 -0
- clang_tool_chain-1.0.2.dist-info/entry_points.txt +31 -0
- clang_tool_chain-1.0.2.dist-info/licenses/LICENSE +204 -0
|
@@ -0,0 +1,1766 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clang-tool-chain
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Clang Tool Chain - C/C++ compilation toolchain utilities
|
|
5
|
+
Project-URL: Homepage, https://github.com/zackees/clang-tool-chain
|
|
6
|
+
Project-URL: Repository, https://github.com/zackees/clang-tool-chain
|
|
7
|
+
Project-URL: Issues, https://github.com/zackees/clang-tool-chain/issues
|
|
8
|
+
Author: Zachary Vorhies
|
|
9
|
+
Maintainer: Zachary Vorhies
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: c,clang,compiler,cpp,toolchain
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: fasteners>=0.19.0
|
|
25
|
+
Requires-Dist: pyzstd>=0.16.0
|
|
26
|
+
Requires-Dist: uv-iso-env>=1.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: black>=24.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: isort>=5.13.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: mypy>=1.8.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pyright>=1.1.350; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-xdist>=3.5.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.3.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: sccache>=0.7.0; extra == 'dev'
|
|
38
|
+
Provides-Extra: sccache
|
|
39
|
+
Requires-Dist: sccache>=0.7.0; extra == 'sccache'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# Clang Tool Chain
|
|
43
|
+
|
|
44
|
+
**A zero-configuration Python package that distributes pre-built Clang/LLVM binaries with automatic downloading and installation.**
|
|
45
|
+
|
|
46
|
+
[](https://pypi.org/project/clang-tool-chain/)
|
|
47
|
+
[](https://pepy.tech/project/clang-tool-chain)
|
|
48
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/lint.yml)
|
|
49
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/test-win.yml)
|
|
50
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/test-linux-x86.yml)
|
|
51
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/test-linux-arm.yml)
|
|
52
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/test-macos-x86.yml)
|
|
53
|
+
[](https://github.com/zackees/clang-tool-chain/actions/workflows/test-macos-arm.yml)
|
|
54
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
55
|
+
[](https://www.python.org/downloads/)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ⚡ Quick Start
|
|
60
|
+
|
|
61
|
+
Get compiling in 30 seconds:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Install the package
|
|
65
|
+
pip install clang-tool-chain
|
|
66
|
+
|
|
67
|
+
# Compile C code - binaries download automatically on first use!
|
|
68
|
+
echo 'int main() { return 0; }' > hello.c
|
|
69
|
+
clang-tool-chain-c hello.c -o hello
|
|
70
|
+
./hello # Windows: .\hello.exe
|
|
71
|
+
|
|
72
|
+
# Verify installation (optional but recommended)
|
|
73
|
+
clang-tool-chain-test # Runs 7 diagnostic tests
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**That's it!** The LLVM toolchain (~52-91 MB) downloads automatically on first use. No manual setup required.
|
|
77
|
+
|
|
78
|
+
> **Note:** This package currently uses:
|
|
79
|
+
> - **LLVM 21.1.5** for Windows and Linux
|
|
80
|
+
> - **LLVM 19.1.6** for macOS (21.1.5 coming soon)
|
|
81
|
+
>
|
|
82
|
+
> See [Platform Support Matrix](#-platform-support-matrix) for details.
|
|
83
|
+
|
|
84
|
+
### ⚠️ Windows Users: GNU ABI by Default (v2.0+)
|
|
85
|
+
|
|
86
|
+
**IMPORTANT:** Starting with v2.0.0, Windows defaults to GNU ABI (MinGW-w64) for cross-platform consistency.
|
|
87
|
+
|
|
88
|
+
This matches the behavior of [zig cc](https://ziglang.org/learn/overview/#cross-compiling-is-a-first-class-use-case) and ensures consistent C++ ABI across all platforms.
|
|
89
|
+
|
|
90
|
+
**What this means:**
|
|
91
|
+
- ✅ **C++11 strict mode works** - No C++14 extensions in standard library headers
|
|
92
|
+
- ✅ **Cross-platform consistency** - Same ABI on Windows/Linux/macOS
|
|
93
|
+
- ✅ **Arduino/embedded compatibility** - Matches GCC/GNU toolchain behavior
|
|
94
|
+
- ⚠️ **Cannot link with MSVC libraries** - Different C++ ABI (use MSVC variant if needed)
|
|
95
|
+
|
|
96
|
+
**Default behavior (GNU ABI):**
|
|
97
|
+
```bash
|
|
98
|
+
clang-tool-chain-c main.c -o program # Uses x86_64-w64-mingw32 target
|
|
99
|
+
clang-tool-chain-cpp main.cpp -o program # Uses GNU ABI, libc++ stdlib
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**For MSVC ABI (Windows-specific projects):**
|
|
103
|
+
```bash
|
|
104
|
+
clang-tool-chain-c-msvc main.c -o program.exe # Uses x86_64-pc-windows-msvc
|
|
105
|
+
clang-tool-chain-cpp-msvc main.cpp -o program.exe # Uses MSVC ABI, MSVC stdlib
|
|
106
|
+
|
|
107
|
+
# With sccache for compilation caching
|
|
108
|
+
clang-tool-chain-sccache-c-msvc main.c -o program.exe
|
|
109
|
+
clang-tool-chain-sccache-cpp-msvc main.cpp -o program.exe
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Download sizes:**
|
|
113
|
+
- **First run (GNU target):** ~100-120 MB (includes MinGW-w64 sysroot)
|
|
114
|
+
- **MSVC variant:** ~50 MB (uses Visual Studio SDK if available)
|
|
115
|
+
|
|
116
|
+
**Windows SDK Requirements:**
|
|
117
|
+
|
|
118
|
+
MSVC variants require Visual Studio or Windows SDK for system headers/libraries. The package automatically:
|
|
119
|
+
- ✅ Detects SDK via environment variables (WindowsSdkDir, VCToolsInstallDir, etc.)
|
|
120
|
+
- ⚠️ Shows helpful setup instructions if SDK not found
|
|
121
|
+
- 🔧 Suggests alternatives (Visual Studio Dev Prompt, vcvarsall.bat, or GNU ABI)
|
|
122
|
+
|
|
123
|
+
**When to use MSVC variant:**
|
|
124
|
+
- Linking with MSVC-compiled libraries (DLLs with C++ APIs)
|
|
125
|
+
- Windows-specific projects requiring Visual Studio integration
|
|
126
|
+
- COM/WinRT/Windows Runtime components
|
|
127
|
+
- Using Windows SDK features not available in MinGW
|
|
128
|
+
|
|
129
|
+
**When to use GNU ABI (default):**
|
|
130
|
+
- Cross-platform projects (same ABI on all platforms)
|
|
131
|
+
- Strict C++11 mode (MSVC requires C++14 extensions)
|
|
132
|
+
- No Windows SDK installation required
|
|
133
|
+
- Arduino/embedded projects (matches GCC)
|
|
134
|
+
|
|
135
|
+
### 📋 Command Quick Reference
|
|
136
|
+
|
|
137
|
+
| Task | Command (Default) | Windows MSVC Variant |
|
|
138
|
+
|------|-------------------|---------------------|
|
|
139
|
+
| **Compile C** | `clang-tool-chain-c main.c -o program` | `clang-tool-chain-c-msvc main.c -o program.exe` |
|
|
140
|
+
| **Compile C++** | `clang-tool-chain-cpp main.cpp -o program` | `clang-tool-chain-cpp-msvc main.cpp -o program.exe` |
|
|
141
|
+
| **Cached C** | `clang-tool-chain-sccache-c main.c -o program` | `clang-tool-chain-sccache-c-msvc main.c -o program.exe` |
|
|
142
|
+
| **Cached C++** | `clang-tool-chain-sccache-cpp main.cpp -o program` | `clang-tool-chain-sccache-cpp-msvc main.cpp -o program.exe` |
|
|
143
|
+
| **Link Objects** | `clang-tool-chain-ld obj1.o obj2.o -o program` | N/A (use compiler) |
|
|
144
|
+
| **Create Library** | `clang-tool-chain-ar rcs libname.a obj1.o obj2.o` | Same |
|
|
145
|
+
| **Format Code** | `clang-tool-chain-format -i file.cpp` | Same |
|
|
146
|
+
| **Check Installation** | `clang-tool-chain info` | Same |
|
|
147
|
+
| **Verify Setup** | `clang-tool-chain-test` | Same |
|
|
148
|
+
|
|
149
|
+
**Note:** MSVC variants (`*-msvc`) are Windows-only and require Visual Studio or Windows SDK. Automatic SDK detection with helpful error messages included.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 📦 Installation
|
|
154
|
+
|
|
155
|
+
### From PyPI (Recommended)
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install clang-tool-chain
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### From Source
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Clone the repository
|
|
165
|
+
git clone https://github.com/zackees/clang-tool-chain.git
|
|
166
|
+
cd clang-tool-chain
|
|
167
|
+
|
|
168
|
+
# Install dependencies
|
|
169
|
+
./install
|
|
170
|
+
|
|
171
|
+
# Or manually with uv
|
|
172
|
+
uv venv --python 3.11
|
|
173
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
174
|
+
uv pip install -e ".[dev]"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Note:** Binaries download automatically on first use. No manual setup required!
|
|
178
|
+
|
|
179
|
+
**macOS Users:** Requires Xcode Command Line Tools for system headers. Run `xcode-select --install` if not already installed.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 🎯 Why clang-tool-chain?
|
|
184
|
+
|
|
185
|
+
### The Problem
|
|
186
|
+
|
|
187
|
+
Installing LLVM/Clang traditionally requires:
|
|
188
|
+
- Large downloads (1-3 GB installer/archive)
|
|
189
|
+
- System-wide installation with admin privileges
|
|
190
|
+
- Manual PATH configuration
|
|
191
|
+
- Platform-specific installation procedures
|
|
192
|
+
- Version management headaches in CI/CD
|
|
193
|
+
|
|
194
|
+
### The Solution
|
|
195
|
+
|
|
196
|
+
`clang-tool-chain` provides:
|
|
197
|
+
|
|
198
|
+
| Feature | clang-tool-chain | Full LLVM Install | System Compiler | zig cc |
|
|
199
|
+
|---------|------------------|-------------------|-----------------|--------|
|
|
200
|
+
| **Size** | 52-91 MB | 1-3 GB | Varies | ~80 MB |
|
|
201
|
+
| **Setup Time** | < 30 seconds | 5-15 minutes | Varies | < 30 seconds |
|
|
202
|
+
| **Admin Required** | ❌ No | ✅ Yes (usually) | ✅ Yes | ❌ No |
|
|
203
|
+
| **Auto Download** | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
|
|
204
|
+
| **Version Control** | ✅ Pin in requirements | ❌ System-wide | ❌ System-wide | ⚠️ Tied to Zig version |
|
|
205
|
+
| **Cross-Platform** | ✅ Identical on all OS | ❌ Different procedures | ❌ Different versions | ✅ Yes |
|
|
206
|
+
| **Cross-Compilation** | Platform-specific | ❌ Complex | ❌ Complex | ✅ Single binary, all targets |
|
|
207
|
+
| **CI/CD Ready** | ✅ Zero config | ❌ Complex setup | ⚠️ Depends on runner | ✅ Zero config |
|
|
208
|
+
| **Offline After DL** | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
|
|
209
|
+
| **Python Integration** | ✅ Native | ❌ Manual | ❌ Manual | ❌ Manual |
|
|
210
|
+
|
|
211
|
+
### Perfect For
|
|
212
|
+
|
|
213
|
+
- **CI/CD Pipelines** - Reproducible builds with pinned toolchain versions
|
|
214
|
+
- **Educational Environments** - Students get started instantly without installation hassles
|
|
215
|
+
- **Development Teams** - Everyone uses the exact same compiler version
|
|
216
|
+
- **Containerized Builds** - Minimal Docker image overhead
|
|
217
|
+
- **Python Projects** - Seamless integration with Python build systems
|
|
218
|
+
|
|
219
|
+
### Not Recommended For
|
|
220
|
+
|
|
221
|
+
- **Production Embedded Systems** - Use vendor-specific toolchains
|
|
222
|
+
- **Kernel Development** - System compilers with specific patches
|
|
223
|
+
- **Custom LLVM Builds** - If you need specific LLVM patches/features
|
|
224
|
+
- **Air-Gapped Environments** - Requires manual setup (see [Offline Mode](#offline-mode))
|
|
225
|
+
- **Cross-Compilation to Different Architectures** - Use `zig cc` for multi-target cross-compilation
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## ✨ Features
|
|
230
|
+
|
|
231
|
+
- **Automatic Download on First Use** - Zero-configuration installation to `~/.clang-tool-chain/`
|
|
232
|
+
- **Manifest-Based Distribution** - Version-controlled releases with SHA256 checksum verification
|
|
233
|
+
- **Ultra-Optimized Archives** - 94.3% size reduction via binary stripping, deduplication, and zstd-22 compression
|
|
234
|
+
- **Cross-Platform Support** - Windows x64, macOS x64/ARM64, Linux x64/ARM64
|
|
235
|
+
- **Concurrent-Safe Installation** - File locking prevents race conditions in parallel builds
|
|
236
|
+
- **Python Wrapper Commands** - 22 entry points for all essential LLVM tools
|
|
237
|
+
- **Pre-Built Binaries** - Clang 21.1.5 (Linux/Windows), 19.1.6 (macOS)
|
|
238
|
+
- **Essential Toolchain Utilities** - Compilers, linkers, binary utilities, and code formatters
|
|
239
|
+
- **Automatic macOS SDK Detection** - Seamlessly finds system headers on macOS without configuration
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 🚀 Usage
|
|
244
|
+
|
|
245
|
+
### CLI Commands
|
|
246
|
+
|
|
247
|
+
Manage your toolchain installation:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Show installation information and available tools
|
|
251
|
+
clang-tool-chain info
|
|
252
|
+
|
|
253
|
+
# Run diagnostic tests (verify installation)
|
|
254
|
+
clang-tool-chain test
|
|
255
|
+
|
|
256
|
+
# List all available wrapper commands
|
|
257
|
+
clang-tool-chain list-tools
|
|
258
|
+
|
|
259
|
+
# Show version of a specific tool
|
|
260
|
+
clang-tool-chain version clang
|
|
261
|
+
clang-tool-chain version clang++
|
|
262
|
+
|
|
263
|
+
# Show path to binaries directory
|
|
264
|
+
clang-tool-chain path
|
|
265
|
+
|
|
266
|
+
# Show path to specific tool
|
|
267
|
+
clang-tool-chain path clang
|
|
268
|
+
|
|
269
|
+
# Show package and LLVM versions
|
|
270
|
+
clang-tool-chain package-version
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Wrapper Commands
|
|
274
|
+
|
|
275
|
+
#### Compiling C Code
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Simple compilation
|
|
279
|
+
clang-tool-chain-c hello.c -o hello
|
|
280
|
+
|
|
281
|
+
# With optimization
|
|
282
|
+
clang-tool-chain-c -O2 hello.c -o hello
|
|
283
|
+
|
|
284
|
+
# With debugging symbols
|
|
285
|
+
clang-tool-chain-c -g hello.c -o hello
|
|
286
|
+
|
|
287
|
+
# Check version
|
|
288
|
+
clang-tool-chain-c --version
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### Compiling C++ Code
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Simple compilation
|
|
295
|
+
clang-tool-chain-cpp hello.cpp -o hello
|
|
296
|
+
|
|
297
|
+
# With C++20 standard
|
|
298
|
+
clang-tool-chain-cpp -std=c++20 hello.cpp -o hello
|
|
299
|
+
|
|
300
|
+
# With optimization and warnings
|
|
301
|
+
clang-tool-chain-cpp -O3 -Wall -Wextra hello.cpp -o hello
|
|
302
|
+
|
|
303
|
+
# Check version
|
|
304
|
+
clang-tool-chain-cpp --version
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### Using the Build Utility
|
|
308
|
+
|
|
309
|
+
The `clang-tool-chain-build` command provides a simple way to compile projects:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Build a single C file
|
|
313
|
+
clang-tool-chain-build hello.c
|
|
314
|
+
|
|
315
|
+
# Build a C++ file with custom output name
|
|
316
|
+
clang-tool-chain-build hello.cpp -o myprogram
|
|
317
|
+
|
|
318
|
+
# Build with optimization
|
|
319
|
+
clang-tool-chain-build -O2 hello.c
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### CMake Integration
|
|
323
|
+
|
|
324
|
+
**Option 1: Environment Variables (Recommended)**
|
|
325
|
+
|
|
326
|
+
```cmake
|
|
327
|
+
# CMakeLists.txt
|
|
328
|
+
cmake_minimum_required(VERSION 3.15)
|
|
329
|
+
project(MyProject)
|
|
330
|
+
|
|
331
|
+
# No changes needed - respects CC/CXX environment variables
|
|
332
|
+
add_executable(myapp main.cpp)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
export CC=clang-tool-chain-c
|
|
337
|
+
export CXX=clang-tool-chain-cpp
|
|
338
|
+
cmake -B build
|
|
339
|
+
cmake --build build
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Option 2: Direct Compiler Specification**
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
cmake -B build \
|
|
346
|
+
-DCMAKE_C_COMPILER=clang-tool-chain-c \
|
|
347
|
+
-DCMAKE_CXX_COMPILER=clang-tool-chain-cpp
|
|
348
|
+
cmake --build build
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### Linking
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Link object files
|
|
355
|
+
clang-tool-chain-ld obj1.o obj2.o -o program
|
|
356
|
+
|
|
357
|
+
# Create shared library (Linux/macOS)
|
|
358
|
+
clang-tool-chain-ld -shared obj1.o obj2.o -o libmylib.so
|
|
359
|
+
|
|
360
|
+
# Create DLL (Windows)
|
|
361
|
+
clang-tool-chain-ld -shared obj1.o obj2.o -o mylib.dll
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Binary Utilities
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
# Create static library
|
|
368
|
+
clang-tool-chain-ar rcs libmylib.a obj1.o obj2.o
|
|
369
|
+
|
|
370
|
+
# List symbols in binary
|
|
371
|
+
clang-tool-chain-nm program
|
|
372
|
+
|
|
373
|
+
# List symbols in library
|
|
374
|
+
clang-tool-chain-nm libmylib.a
|
|
375
|
+
|
|
376
|
+
# Disassemble binary
|
|
377
|
+
clang-tool-chain-objdump -d program
|
|
378
|
+
|
|
379
|
+
# Show all headers
|
|
380
|
+
clang-tool-chain-objdump -x program
|
|
381
|
+
|
|
382
|
+
# Strip debug symbols
|
|
383
|
+
clang-tool-chain-strip program -o program.stripped
|
|
384
|
+
|
|
385
|
+
# Copy and modify object files
|
|
386
|
+
clang-tool-chain-objcopy --strip-debug program program.stripped
|
|
387
|
+
|
|
388
|
+
# Generate archive index
|
|
389
|
+
clang-tool-chain-ranlib libmylib.a
|
|
390
|
+
|
|
391
|
+
# Read ELF headers (Linux)
|
|
392
|
+
clang-tool-chain-readelf -h program
|
|
393
|
+
|
|
394
|
+
# Show program headers
|
|
395
|
+
clang-tool-chain-readelf -l program
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
#### Code Formatting and Analysis
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
# Format C/C++ code (in-place)
|
|
402
|
+
clang-tool-chain-format -i myfile.cpp
|
|
403
|
+
|
|
404
|
+
# Format with specific style
|
|
405
|
+
clang-tool-chain-format -i -style=LLVM myfile.cpp
|
|
406
|
+
|
|
407
|
+
# Check formatting (don't modify)
|
|
408
|
+
clang-tool-chain-format myfile.cpp
|
|
409
|
+
|
|
410
|
+
# Run static analysis
|
|
411
|
+
clang-tool-chain-tidy myfile.cpp -- -std=c++17
|
|
412
|
+
|
|
413
|
+
# Run with specific checks
|
|
414
|
+
clang-tool-chain-tidy -checks='-*,readability-*' myfile.cpp --
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
#### sccache Integration (Optional)
|
|
418
|
+
|
|
419
|
+
Speed up repeated builds with compilation caching:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# Install with sccache support
|
|
423
|
+
pip install clang-tool-chain[sccache]
|
|
424
|
+
# Or: cargo install sccache
|
|
425
|
+
|
|
426
|
+
# Compile with sccache caching
|
|
427
|
+
clang-tool-chain-sccache-c main.c -o main
|
|
428
|
+
clang-tool-chain-sccache-cpp main.cpp -o main
|
|
429
|
+
|
|
430
|
+
# Query cache statistics
|
|
431
|
+
clang-tool-chain-sccache --show-stats
|
|
432
|
+
|
|
433
|
+
# Clear cache statistics
|
|
434
|
+
clang-tool-chain-sccache --zero-stats
|
|
435
|
+
|
|
436
|
+
# Manage sccache server
|
|
437
|
+
clang-tool-chain-sccache --start-server
|
|
438
|
+
clang-tool-chain-sccache --stop-server
|
|
439
|
+
clang-tool-chain-sccache --version
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**How it works:**
|
|
443
|
+
- Caches compilation results locally for faster rebuilds
|
|
444
|
+
- Transparent caching layer on top of clang
|
|
445
|
+
- Requires `sccache` binary in PATH
|
|
446
|
+
- Works with distributed caching backends (optional)
|
|
447
|
+
|
|
448
|
+
### All Available Commands
|
|
449
|
+
|
|
450
|
+
| Command | Tool | Description |
|
|
451
|
+
|---------|------|-------------|
|
|
452
|
+
| `clang-tool-chain` | CLI | Main management interface |
|
|
453
|
+
| `clang-tool-chain-test` | Diagnostic | Run 7 diagnostic tests to verify installation |
|
|
454
|
+
| `clang-tool-chain-fetch` | Fetch utility | Manual download utility for pre-fetching binaries |
|
|
455
|
+
| `clang-tool-chain-paths` | Path utility | Get installation paths in JSON format |
|
|
456
|
+
| `clang-tool-chain-fetch-archive` | Archive utility | Maintainer tool for creating optimized archives |
|
|
457
|
+
| `clang-tool-chain-c` | `clang` | C compiler (GNU ABI on Windows) |
|
|
458
|
+
| `clang-tool-chain-cpp` | `clang++` | C++ compiler (GNU ABI on Windows) |
|
|
459
|
+
| `clang-tool-chain-c-msvc` | `clang` | C compiler (MSVC ABI, Windows only) |
|
|
460
|
+
| `clang-tool-chain-cpp-msvc` | `clang++` | C++ compiler (MSVC ABI, Windows only) |
|
|
461
|
+
| `clang-tool-chain-build` | Build utility | Simple build tool for C/C++ |
|
|
462
|
+
| `clang-tool-chain-sccache` | `sccache` | Direct sccache access (stats, management) |
|
|
463
|
+
| `clang-tool-chain-sccache-c` | `sccache` + `clang` | C compiler with sccache caching |
|
|
464
|
+
| `clang-tool-chain-sccache-cpp` | `sccache` + `clang++` | C++ compiler with sccache caching |
|
|
465
|
+
| `clang-tool-chain-ld` | `lld` / `lld-link` | LLVM linker |
|
|
466
|
+
| `clang-tool-chain-ar` | `llvm-ar` | Archive/library creator |
|
|
467
|
+
| `clang-tool-chain-nm` | `llvm-nm` | Symbol table viewer |
|
|
468
|
+
| `clang-tool-chain-objdump` | `llvm-objdump` | Object file dumper/disassembler |
|
|
469
|
+
| `clang-tool-chain-objcopy` | `llvm-objcopy` | Object file copier/modifier |
|
|
470
|
+
| `clang-tool-chain-ranlib` | `llvm-ranlib` | Archive index generator |
|
|
471
|
+
| `clang-tool-chain-strip` | `llvm-strip` | Symbol stripper |
|
|
472
|
+
| `clang-tool-chain-readelf` | `llvm-readelf` | ELF file reader |
|
|
473
|
+
| `clang-tool-chain-as` | `llvm-as` | LLVM assembler |
|
|
474
|
+
| `clang-tool-chain-dis` | `llvm-dis` | LLVM disassembler |
|
|
475
|
+
| `clang-tool-chain-format` | `clang-format` | Code formatter |
|
|
476
|
+
| `clang-tool-chain-tidy` | `clang-tidy` | Static analyzer/linter |
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## 📚 Examples
|
|
481
|
+
|
|
482
|
+
### Hello World (C)
|
|
483
|
+
|
|
484
|
+
```c
|
|
485
|
+
// hello.c
|
|
486
|
+
#include <stdio.h>
|
|
487
|
+
|
|
488
|
+
int main() {
|
|
489
|
+
printf("Hello from clang-tool-chain!\n");
|
|
490
|
+
return 0;
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
clang-tool-chain-c hello.c -o hello
|
|
496
|
+
./hello
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Hello World (C++)
|
|
500
|
+
|
|
501
|
+
```cpp
|
|
502
|
+
// hello.cpp
|
|
503
|
+
#include <iostream>
|
|
504
|
+
|
|
505
|
+
int main() {
|
|
506
|
+
std::cout << "Hello from clang-tool-chain!" << std::endl;
|
|
507
|
+
return 0;
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
clang-tool-chain-cpp hello.cpp -o hello
|
|
513
|
+
./hello
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### Multi-File Compilation
|
|
517
|
+
|
|
518
|
+
```c
|
|
519
|
+
// math_ops.h
|
|
520
|
+
#ifndef MATH_OPS_H
|
|
521
|
+
#define MATH_OPS_H
|
|
522
|
+
int add(int a, int b);
|
|
523
|
+
int multiply(int a, int b);
|
|
524
|
+
#endif
|
|
525
|
+
|
|
526
|
+
// math_ops.c
|
|
527
|
+
#include "math_ops.h"
|
|
528
|
+
int add(int a, int b) { return a + b; }
|
|
529
|
+
int multiply(int a, int b) { return a * b; }
|
|
530
|
+
|
|
531
|
+
// main.c
|
|
532
|
+
#include <stdio.h>
|
|
533
|
+
#include "math_ops.h"
|
|
534
|
+
|
|
535
|
+
int main() {
|
|
536
|
+
printf("5 + 3 = %d\n", add(5, 3));
|
|
537
|
+
printf("5 * 3 = %d\n", multiply(5, 3));
|
|
538
|
+
return 0;
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
# Compile and link in one step
|
|
544
|
+
clang-tool-chain-c main.c math_ops.c -o program
|
|
545
|
+
./program
|
|
546
|
+
|
|
547
|
+
# Or compile separately then link
|
|
548
|
+
clang-tool-chain-c -c math_ops.c -o math_ops.o
|
|
549
|
+
clang-tool-chain-c -c main.c -o main.o
|
|
550
|
+
clang-tool-chain-c main.o math_ops.o -o program
|
|
551
|
+
./program
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Creating a Static Library
|
|
555
|
+
|
|
556
|
+
```bash
|
|
557
|
+
# Compile source files to object files
|
|
558
|
+
clang-tool-chain-c -c math_ops.c -o math_ops.o
|
|
559
|
+
clang-tool-chain-c -c string_ops.c -o string_ops.o
|
|
560
|
+
|
|
561
|
+
# Create static library
|
|
562
|
+
clang-tool-chain-ar rcs libmylib.a math_ops.o string_ops.o
|
|
563
|
+
|
|
564
|
+
# Generate archive index (optional but recommended)
|
|
565
|
+
clang-tool-chain-ranlib libmylib.a
|
|
566
|
+
|
|
567
|
+
# Link against the library
|
|
568
|
+
clang-tool-chain-c main.c -L. -lmylib -o program
|
|
569
|
+
./program
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Cross-Platform Build Script
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
#!/bin/bash
|
|
576
|
+
# build.sh - Cross-platform build script
|
|
577
|
+
|
|
578
|
+
set -e
|
|
579
|
+
|
|
580
|
+
# Compile
|
|
581
|
+
echo "Compiling..."
|
|
582
|
+
clang-tool-chain-c -O2 -Wall -Wextra src/*.c -o myprogram
|
|
583
|
+
|
|
584
|
+
# Strip symbols for release
|
|
585
|
+
echo "Stripping symbols..."
|
|
586
|
+
clang-tool-chain-strip myprogram -o myprogram.release
|
|
587
|
+
|
|
588
|
+
echo "Build complete: myprogram.release"
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
## 🚀 CI/CD Integration
|
|
594
|
+
|
|
595
|
+
### GitHub Actions
|
|
596
|
+
|
|
597
|
+
```yaml
|
|
598
|
+
# .github/workflows/build.yml
|
|
599
|
+
name: Build
|
|
600
|
+
|
|
601
|
+
on: [push, pull_request]
|
|
602
|
+
|
|
603
|
+
jobs:
|
|
604
|
+
build:
|
|
605
|
+
runs-on: ${{ matrix.os }}
|
|
606
|
+
strategy:
|
|
607
|
+
matrix:
|
|
608
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
609
|
+
|
|
610
|
+
steps:
|
|
611
|
+
- uses: actions/checkout@v3
|
|
612
|
+
|
|
613
|
+
- name: Set up Python
|
|
614
|
+
uses: actions/setup-python@v4
|
|
615
|
+
with:
|
|
616
|
+
python-version: '3.11'
|
|
617
|
+
|
|
618
|
+
- name: Install clang-tool-chain
|
|
619
|
+
run: pip install clang-tool-chain
|
|
620
|
+
|
|
621
|
+
- name: Compile project
|
|
622
|
+
run: |
|
|
623
|
+
clang-tool-chain-c src/main.c -o program
|
|
624
|
+
./program # Binaries download automatically on first use!
|
|
625
|
+
|
|
626
|
+
- name: Upload artifact
|
|
627
|
+
uses: actions/upload-artifact@v3
|
|
628
|
+
with:
|
|
629
|
+
name: program-${{ matrix.os }}
|
|
630
|
+
path: program*
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### GitLab CI
|
|
634
|
+
|
|
635
|
+
```yaml
|
|
636
|
+
# .gitlab-ci.yml
|
|
637
|
+
image: python:3.11
|
|
638
|
+
|
|
639
|
+
stages:
|
|
640
|
+
- build
|
|
641
|
+
- test
|
|
642
|
+
|
|
643
|
+
build:
|
|
644
|
+
stage: build
|
|
645
|
+
script:
|
|
646
|
+
- pip install clang-tool-chain
|
|
647
|
+
- clang-tool-chain-c src/main.c -o program # Auto-downloads on first use
|
|
648
|
+
- clang-tool-chain-strip program
|
|
649
|
+
artifacts:
|
|
650
|
+
paths:
|
|
651
|
+
- program
|
|
652
|
+
|
|
653
|
+
test:
|
|
654
|
+
stage: test
|
|
655
|
+
script:
|
|
656
|
+
- ./program
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### Docker
|
|
660
|
+
|
|
661
|
+
```dockerfile
|
|
662
|
+
# Dockerfile
|
|
663
|
+
FROM python:3.11-slim
|
|
664
|
+
|
|
665
|
+
# Install clang-tool-chain
|
|
666
|
+
RUN pip install clang-tool-chain
|
|
667
|
+
|
|
668
|
+
# Pre-download binaries (optional - they auto-download on first use)
|
|
669
|
+
RUN clang-tool-chain info || true
|
|
670
|
+
|
|
671
|
+
# Copy source code
|
|
672
|
+
COPY src/ /app/src/
|
|
673
|
+
WORKDIR /app
|
|
674
|
+
|
|
675
|
+
# Build
|
|
676
|
+
RUN clang-tool-chain-c src/main.c -o program
|
|
677
|
+
|
|
678
|
+
CMD ["./program"]
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
**Build and run:**
|
|
682
|
+
```bash
|
|
683
|
+
docker build -t myapp .
|
|
684
|
+
docker run myapp
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
### Azure Pipelines
|
|
688
|
+
|
|
689
|
+
```yaml
|
|
690
|
+
# azure-pipelines.yml
|
|
691
|
+
trigger:
|
|
692
|
+
- main
|
|
693
|
+
|
|
694
|
+
pool:
|
|
695
|
+
vmImage: 'ubuntu-latest'
|
|
696
|
+
|
|
697
|
+
steps:
|
|
698
|
+
- task: UsePythonVersion@0
|
|
699
|
+
inputs:
|
|
700
|
+
versionSpec: '3.11'
|
|
701
|
+
|
|
702
|
+
- script: |
|
|
703
|
+
pip install clang-tool-chain
|
|
704
|
+
clang-tool-chain-c src/main.c -o program
|
|
705
|
+
displayName: 'Build with clang-tool-chain'
|
|
706
|
+
|
|
707
|
+
- task: PublishBuildArtifacts@1
|
|
708
|
+
inputs:
|
|
709
|
+
pathToPublish: 'program'
|
|
710
|
+
artifactName: 'executable'
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
---
|
|
714
|
+
|
|
715
|
+
## 🌍 Platform Support Matrix
|
|
716
|
+
|
|
717
|
+
| Platform | Architecture | LLVM Version | Archive Size | Installed Size | Status |
|
|
718
|
+
|----------|--------------|--------------|--------------|----------------|--------|
|
|
719
|
+
| Windows | x86_64 | 21.1.5 | ~100 MB* | ~350 MB | ✅ Stable |
|
|
720
|
+
| Linux | x86_64 | 21.1.5 | ~88 MB | ~350 MB | ✅ Stable |
|
|
721
|
+
| Linux | ARM64 | 21.1.5 | ~91 MB | ~340 MB | ✅ Stable |
|
|
722
|
+
| macOS | x86_64 | 19.1.6 | ~75 MB | ~300 MB | ✅ Stable |
|
|
723
|
+
| macOS | ARM64 | 19.1.6 | ~71 MB | ~285 MB | ✅ Stable |
|
|
724
|
+
|
|
725
|
+
\* **Windows Downloads:**
|
|
726
|
+
- **GNU target (default):** ~100 MB (LLVM + MinGW-w64 sysroot)
|
|
727
|
+
- **MSVC target (opt-in):** ~50 MB (LLVM only, requires Visual Studio SDK)
|
|
728
|
+
|
|
729
|
+
**Note:** macOS uses LLVM 19.1.6 due to availability of pre-built binaries. LLVM 21.1.5 support coming soon.
|
|
730
|
+
|
|
731
|
+
### Requirements
|
|
732
|
+
|
|
733
|
+
- **Python**: 3.10 or higher
|
|
734
|
+
- **Disk Space**: ~100 MB for archive + ~200-350 MB installed
|
|
735
|
+
- **Internet**: Required for initial download (works offline after installation)
|
|
736
|
+
- **Operating System**:
|
|
737
|
+
- Windows 10+ (x64)
|
|
738
|
+
- macOS 11+ (x64 or ARM64/Apple Silicon) - **Requires Xcode Command Line Tools**: `xcode-select --install`
|
|
739
|
+
- Linux with glibc 2.27+ (x64 or ARM64)
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
|
|
743
|
+
## ⚙️ Configuration
|
|
744
|
+
|
|
745
|
+
### Environment Variables
|
|
746
|
+
|
|
747
|
+
- **`CLANG_TOOL_CHAIN_DOWNLOAD_PATH`**: Override default installation location
|
|
748
|
+
|
|
749
|
+
```bash
|
|
750
|
+
# Linux/macOS
|
|
751
|
+
export CLANG_TOOL_CHAIN_DOWNLOAD_PATH=/custom/path
|
|
752
|
+
clang-tool-chain-c hello.c -o hello
|
|
753
|
+
|
|
754
|
+
# Windows
|
|
755
|
+
set CLANG_TOOL_CHAIN_DOWNLOAD_PATH=C:\custom\path
|
|
756
|
+
clang-tool-chain-c hello.c -o hello
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
**Use cases:**
|
|
760
|
+
- Testing different toolchain versions
|
|
761
|
+
- Shared installations across projects
|
|
762
|
+
- Network or cache drives
|
|
763
|
+
- CI/CD artifact caching
|
|
764
|
+
|
|
765
|
+
### macOS SDK Detection (Automatic)
|
|
766
|
+
|
|
767
|
+
macOS users no longer need to manually configure SDK paths! The toolchain automatically detects your Xcode Command Line Tools SDK using `xcrun`.
|
|
768
|
+
|
|
769
|
+
**Requirements:**
|
|
770
|
+
```bash
|
|
771
|
+
xcode-select --install # One-time setup
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
**How it works:**
|
|
775
|
+
- Automatically injects `-isysroot` when compiling on macOS
|
|
776
|
+
- Detects SDK via `xcrun --show-sdk-path`
|
|
777
|
+
- Respects `SDKROOT` environment variable if set
|
|
778
|
+
- Uses explicit `-isysroot` flag if provided by user
|
|
779
|
+
- Disabled with `CLANG_TOOL_CHAIN_NO_SYSROOT=1`
|
|
780
|
+
|
|
781
|
+
**Advanced Configuration:**
|
|
782
|
+
```bash
|
|
783
|
+
# Use custom SDK path (standard macOS variable)
|
|
784
|
+
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
|
|
785
|
+
|
|
786
|
+
# Disable automatic SDK detection (not recommended)
|
|
787
|
+
export CLANG_TOOL_CHAIN_NO_SYSROOT=1
|
|
788
|
+
|
|
789
|
+
# Explicit SDK path (takes priority)
|
|
790
|
+
clang-tool-chain-c -isysroot /path/to/sdk hello.c -o hello
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
**Automatic injection is skipped when:**
|
|
794
|
+
- User explicitly provides `-isysroot` in arguments
|
|
795
|
+
- `SDKROOT` environment variable is set
|
|
796
|
+
- Freestanding compilation flags are used (`-nostdinc`, `-nostdinc++`, `-nostdlib`, `-ffreestanding`)
|
|
797
|
+
- `CLANG_TOOL_CHAIN_NO_SYSROOT=1` is set
|
|
798
|
+
|
|
799
|
+
No configuration needed - just compile!
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## ⚡ Performance
|
|
804
|
+
|
|
805
|
+
### Compilation Speed
|
|
806
|
+
|
|
807
|
+
clang-tool-chain uses unmodified LLVM binaries - expect **identical performance** to official LLVM releases.
|
|
808
|
+
|
|
809
|
+
### Download Benchmarks (First Use)
|
|
810
|
+
|
|
811
|
+
| Connection | Archive Size | Download Time |
|
|
812
|
+
|------------|--------------|---------------|
|
|
813
|
+
| Fiber (100 Mbps) | 52 MB | ~5 seconds |
|
|
814
|
+
| Cable (20 Mbps) | 52 MB | ~25 seconds |
|
|
815
|
+
| DSL (5 Mbps) | 52 MB | ~90 seconds |
|
|
816
|
+
|
|
817
|
+
Subsequent compilations are **instant** (no download).
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## 🎯 Windows Target Selection
|
|
822
|
+
|
|
823
|
+
### Default Behavior (GNU ABI - Recommended)
|
|
824
|
+
|
|
825
|
+
The default Windows target is `x86_64-w64-mingw32` (GNU ABI) for cross-platform consistency:
|
|
826
|
+
|
|
827
|
+
```bash
|
|
828
|
+
# These commands use GNU ABI by default on Windows:
|
|
829
|
+
clang-tool-chain-c hello.c -o hello
|
|
830
|
+
clang-tool-chain-cpp hello.cpp -o hello
|
|
831
|
+
|
|
832
|
+
# Equivalent to explicitly specifying:
|
|
833
|
+
clang-tool-chain-c --target=x86_64-w64-mingw32 hello.c -o hello
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
**Why GNU ABI is default:**
|
|
837
|
+
1. **Cross-platform consistency** - Same ABI on Linux/macOS/Windows
|
|
838
|
+
2. **C++11 strict mode support** - MSVC headers require C++14 features even in C++11 mode
|
|
839
|
+
3. **Embedded/Arduino compatibility** - Matches GCC toolchain behavior
|
|
840
|
+
4. **Modern C++ standard library** - Uses LLVM's libc++ (same as macOS/Linux)
|
|
841
|
+
|
|
842
|
+
This matches the approach of [zig cc](https://ziglang.org/learn/overview/#cross-compiling-is-a-first-class-use-case) and other modern cross-platform toolchains.
|
|
843
|
+
|
|
844
|
+
### MSVC ABI (Windows-Specific Projects)
|
|
845
|
+
|
|
846
|
+
For Windows-native projects that need MSVC compatibility:
|
|
847
|
+
|
|
848
|
+
```bash
|
|
849
|
+
# Use MSVC variants for Windows-specific development:
|
|
850
|
+
clang-tool-chain-c-msvc main.c -o program.exe
|
|
851
|
+
clang-tool-chain-cpp-msvc main.cpp -o program.exe
|
|
852
|
+
|
|
853
|
+
# Or explicitly specify MSVC target with default commands:
|
|
854
|
+
clang-tool-chain-c --target=x86_64-pc-windows-msvc main.c -o program.exe
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
**Use MSVC ABI when:**
|
|
858
|
+
- Linking with MSVC-compiled DLLs (with C++ APIs)
|
|
859
|
+
- Using Windows SDK features not in MinGW
|
|
860
|
+
- Requiring Visual Studio debugger integration
|
|
861
|
+
- Building COM/WinRT/Windows Runtime components
|
|
862
|
+
|
|
863
|
+
### Comparison Table
|
|
864
|
+
|
|
865
|
+
| Feature | GNU ABI (Default) | MSVC ABI (Opt-in) |
|
|
866
|
+
|---------|------------------|------------------|
|
|
867
|
+
| **C++ Standard Library** | libc++ (LLVM) | MSVC STL |
|
|
868
|
+
| **C++ ABI** | Itanium (like GCC) | Microsoft |
|
|
869
|
+
| **Cross-platform consistency** | ✅ Yes | ❌ Windows-only |
|
|
870
|
+
| **C++11 strict mode** | ✅ Works | ❌ Requires C++14+ |
|
|
871
|
+
| **Link with MSVC libs** | ❌ C++ ABI mismatch | ✅ Compatible |
|
|
872
|
+
| **Arduino/embedded** | ✅ Compatible | ❌ Different ABI |
|
|
873
|
+
| **Download size** | ~100 MB | ~50 MB |
|
|
874
|
+
| **Requires Visual Studio** | ❌ No | ⚠️ Recommended |
|
|
875
|
+
|
|
876
|
+
### Advanced: Manual Target Selection
|
|
877
|
+
|
|
878
|
+
You can override the target for any compilation:
|
|
879
|
+
|
|
880
|
+
```bash
|
|
881
|
+
# Force GNU target (default on Windows anyway):
|
|
882
|
+
clang-tool-chain-c --target=x86_64-w64-mingw32 main.c
|
|
883
|
+
|
|
884
|
+
# Force MSVC target:
|
|
885
|
+
clang-tool-chain-c --target=x86_64-pc-windows-msvc main.c
|
|
886
|
+
|
|
887
|
+
# Cross-compile for Linux from Windows:
|
|
888
|
+
clang-tool-chain-c --target=x86_64-unknown-linux-gnu main.c
|
|
889
|
+
|
|
890
|
+
# Cross-compile for macOS from Windows:
|
|
891
|
+
clang-tool-chain-c --target=arm64-apple-darwin main.c
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
**Note:** Cross-compilation requires appropriate sysroots (not included by default).
|
|
895
|
+
|
|
896
|
+
---
|
|
897
|
+
|
|
898
|
+
## 🔧 How It Works
|
|
899
|
+
|
|
900
|
+
### Architecture Overview
|
|
901
|
+
|
|
902
|
+
`clang-tool-chain` uses a sophisticated three-layer architecture:
|
|
903
|
+
|
|
904
|
+
```
|
|
905
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
906
|
+
│ CLI Layer (cli.py) │
|
|
907
|
+
│ Commands: info, version, list-tools, path, package-version │
|
|
908
|
+
└─────────────────────────────────────────────────────────────┘
|
|
909
|
+
↓
|
|
910
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
911
|
+
│ Wrapper Layer (wrapper.py) │
|
|
912
|
+
│ • Platform Detection (win/linux/darwin) │
|
|
913
|
+
│ • Architecture Normalization (x86_64/arm64) │
|
|
914
|
+
│ • Binary Resolution (.exe handling, tool alternatives) │
|
|
915
|
+
│ • Process Execution (os.execv on Unix, subprocess on Win) │
|
|
916
|
+
│ • macOS SDK Auto-Detection (xcrun integration) │
|
|
917
|
+
└─────────────────────────────────────────────────────────────┘
|
|
918
|
+
↓
|
|
919
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
920
|
+
│ Downloader Layer (downloader.py) │
|
|
921
|
+
│ • Fetch root manifest from GitHub │
|
|
922
|
+
│ • Fetch platform-specific manifest │
|
|
923
|
+
│ • Download .tar.zst archive with progress │
|
|
924
|
+
│ • Verify SHA256 checksum │
|
|
925
|
+
│ • Extract with pyzstd decompression │
|
|
926
|
+
│ • File locking (prevents concurrent downloads) │
|
|
927
|
+
│ • Atomic installation with 'done.txt' marker │
|
|
928
|
+
└─────────────────────────────────────────────────────────────┘
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
### Manifest-Based Distribution System
|
|
932
|
+
|
|
933
|
+
The package uses a **two-tier manifest system** for version management:
|
|
934
|
+
|
|
935
|
+
1. **Root Manifest** (`downloads-bins/assets/clang/manifest.json`) - Indexes all platforms and architectures
|
|
936
|
+
2. **Platform Manifests** (`downloads-bins/assets/clang/{platform}/{arch}/manifest.json`) - Contains version info, download URLs, and SHA256 checksums
|
|
937
|
+
|
|
938
|
+
**On first use:**
|
|
939
|
+
```
|
|
940
|
+
User runs: clang-tool-chain-c hello.c -o hello
|
|
941
|
+
↓
|
|
942
|
+
Check: ~/.clang-tool-chain/{platform}/{arch}/done.txt exists?
|
|
943
|
+
↓ (No)
|
|
944
|
+
Acquire lock: ~/.clang-tool-chain/{platform}-{arch}.lock
|
|
945
|
+
↓
|
|
946
|
+
Fetch: Root manifest → Platform manifest
|
|
947
|
+
↓
|
|
948
|
+
Download: .tar.zst archive to temp directory
|
|
949
|
+
↓
|
|
950
|
+
Verify: SHA256 checksum
|
|
951
|
+
↓
|
|
952
|
+
Extract: Using pyzstd + tarfile (with safety filters)
|
|
953
|
+
↓
|
|
954
|
+
Mark complete: Write done.txt
|
|
955
|
+
↓
|
|
956
|
+
Release lock → Execute tool
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
### Platform Detection
|
|
960
|
+
|
|
961
|
+
Automatic platform and architecture detection:
|
|
962
|
+
|
|
963
|
+
| System | Platform | Architecture | Install Path |
|
|
964
|
+
|--------|----------|--------------|--------------|
|
|
965
|
+
| Windows 10+ | `win` | `x86_64` | `~/.clang-tool-chain/clang/win/x86_64/` |
|
|
966
|
+
| Linux | `linux` | `x86_64` | `~/.clang-tool-chain/clang/linux/x86_64/` |
|
|
967
|
+
| Linux | `linux` | `arm64` | `~/.clang-tool-chain/clang/linux/arm64/` |
|
|
968
|
+
| macOS | `darwin` | `x86_64` | `~/.clang-tool-chain/clang/darwin/x86_64/` |
|
|
969
|
+
| macOS | `darwin` | `arm64` | `~/.clang-tool-chain/clang/darwin/arm64/` |
|
|
970
|
+
|
|
971
|
+
### Binary Resolution
|
|
972
|
+
|
|
973
|
+
The wrapper automatically handles platform differences:
|
|
974
|
+
- **Windows**: Adds `.exe` extension, uses `lld-link` instead of `lld`
|
|
975
|
+
- **Unix**: Uses `lld` or `ld.lld`, handles `chmod +x` permissions
|
|
976
|
+
- **macOS**: Automatically detects and injects SDK path via `xcrun`
|
|
977
|
+
- **Alternative Names**: Supports tool aliases (e.g., `clang` → `clang-cl` on Windows)
|
|
978
|
+
|
|
979
|
+
---
|
|
980
|
+
|
|
981
|
+
## 🔧 Additional Utilities
|
|
982
|
+
|
|
983
|
+
### clang-tool-chain-test
|
|
984
|
+
|
|
985
|
+
Run diagnostic tests to verify your installation:
|
|
986
|
+
|
|
987
|
+
```bash
|
|
988
|
+
# Run 7 diagnostic tests
|
|
989
|
+
clang-tool-chain-test
|
|
990
|
+
|
|
991
|
+
# Or via main CLI:
|
|
992
|
+
clang-tool-chain test
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
**Tests performed:**
|
|
996
|
+
1. Platform detection
|
|
997
|
+
2. Toolchain installation verification
|
|
998
|
+
3. clang binary resolution
|
|
999
|
+
4. clang++ binary resolution
|
|
1000
|
+
5. clang version check
|
|
1001
|
+
6. C compilation test
|
|
1002
|
+
7. C++ compilation test
|
|
1003
|
+
|
|
1004
|
+
This command is especially useful for debugging installation issues in GitHub Actions or other CI/CD environments.
|
|
1005
|
+
|
|
1006
|
+
### clang-tool-chain-fetch
|
|
1007
|
+
|
|
1008
|
+
Manual download utility for pre-fetching binaries:
|
|
1009
|
+
|
|
1010
|
+
```bash
|
|
1011
|
+
# Fetch binaries for current platform
|
|
1012
|
+
clang-tool-chain-fetch
|
|
1013
|
+
|
|
1014
|
+
# Check what would be downloaded
|
|
1015
|
+
clang-tool-chain-fetch --dry-run
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
### clang-tool-chain-paths
|
|
1019
|
+
|
|
1020
|
+
Get installation paths in JSON format (useful for scripting):
|
|
1021
|
+
|
|
1022
|
+
```bash
|
|
1023
|
+
# Get all paths
|
|
1024
|
+
clang-tool-chain-paths
|
|
1025
|
+
|
|
1026
|
+
# Example output:
|
|
1027
|
+
# {
|
|
1028
|
+
# "install_dir": "/home/user/.clang-tool-chain/clang/linux/x86_64",
|
|
1029
|
+
# "bin_dir": "/home/user/.clang-tool-chain/clang/linux/x86_64/bin",
|
|
1030
|
+
# "clang": "/home/user/.clang-tool-chain/clang/linux/x86_64/bin/clang"
|
|
1031
|
+
# }
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
```bash
|
|
1035
|
+
# Use in scripts
|
|
1036
|
+
BIN_DIR=$(clang-tool-chain-paths | python -c "import sys,json; print(json.load(sys.stdin)['bin_dir'])")
|
|
1037
|
+
echo "Binaries located at: $BIN_DIR"
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
---
|
|
1041
|
+
|
|
1042
|
+
## 🔬 Advanced Topics
|
|
1043
|
+
|
|
1044
|
+
### Manual Installation (Without Auto-Download)
|
|
1045
|
+
|
|
1046
|
+
If you need to manually install binaries (e.g., for offline environments):
|
|
1047
|
+
|
|
1048
|
+
1. **Download archive:**
|
|
1049
|
+
```bash
|
|
1050
|
+
wget https://raw.githubusercontent.com/zackees/clang-tool-chain-bins/main/assets/clang/win/x86_64/llvm-21.1.5-win-x86_64.tar.zst
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
2. **Extract to installation directory:**
|
|
1054
|
+
```bash
|
|
1055
|
+
# Create installation directory
|
|
1056
|
+
mkdir -p ~/.clang-tool-chain/clang/win/x86_64
|
|
1057
|
+
|
|
1058
|
+
# Extract archive
|
|
1059
|
+
python -m clang_tool_chain.downloads.expand_archive \
|
|
1060
|
+
llvm-21.1.5-win-x86_64.tar.zst \
|
|
1061
|
+
~/.clang-tool-chain/clang/win/x86_64
|
|
1062
|
+
|
|
1063
|
+
# Mark as complete
|
|
1064
|
+
touch ~/.clang-tool-chain/clang/win/x86_64/done.txt
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
3. **Verify installation:**
|
|
1068
|
+
```bash
|
|
1069
|
+
clang-tool-chain info
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
### Offline Mode
|
|
1073
|
+
|
|
1074
|
+
After initial download, `clang-tool-chain` works completely offline:
|
|
1075
|
+
|
|
1076
|
+
```bash
|
|
1077
|
+
# First use (requires internet)
|
|
1078
|
+
clang-tool-chain-c hello.c -o hello # Downloads binaries
|
|
1079
|
+
|
|
1080
|
+
# Subsequent uses (offline)
|
|
1081
|
+
clang-tool-chain-c world.c -o world # Uses cached binaries
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
**For fully offline environments:**
|
|
1085
|
+
1. Pre-download binaries on a machine with internet
|
|
1086
|
+
2. Package `~/.clang-tool-chain/` directory
|
|
1087
|
+
3. Extract to target machines
|
|
1088
|
+
4. Ensure `done.txt` exists in platform directory
|
|
1089
|
+
|
|
1090
|
+
### Version Pinning
|
|
1091
|
+
|
|
1092
|
+
Pin specific LLVM versions in `requirements.txt`:
|
|
1093
|
+
|
|
1094
|
+
```txt
|
|
1095
|
+
# requirements.txt
|
|
1096
|
+
clang-tool-chain==1.0.1 # Pins package version (currently uses LLVM 21.1.5/19.1.6)
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
**Future:** The package will support multiple LLVM versions via manifest updates.
|
|
1100
|
+
|
|
1101
|
+
### Concurrent Build Safety
|
|
1102
|
+
|
|
1103
|
+
The downloader uses **file locking** (`fasteners.InterProcessLock`) to prevent race conditions:
|
|
1104
|
+
|
|
1105
|
+
```python
|
|
1106
|
+
# Multiple processes can safely call this simultaneously
|
|
1107
|
+
clang-tool-chain-c hello.c -o hello # Process 1
|
|
1108
|
+
clang-tool-chain-c world.c -o world # Process 2
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
**What happens:**
|
|
1112
|
+
1. Process 1 acquires lock `~/.clang-tool-chain/win-x86_64.lock`
|
|
1113
|
+
2. Process 2 waits for lock
|
|
1114
|
+
3. Process 1 downloads and installs binaries
|
|
1115
|
+
4. Process 1 writes `done.txt` and releases lock
|
|
1116
|
+
5. Process 2 acquires lock, sees `done.txt`, skips download
|
|
1117
|
+
6. Both processes compile successfully
|
|
1118
|
+
|
|
1119
|
+
**Perfect for:**
|
|
1120
|
+
- Parallel CI/CD builds
|
|
1121
|
+
- Multi-core test runners
|
|
1122
|
+
- Concurrent development environments
|
|
1123
|
+
|
|
1124
|
+
---
|
|
1125
|
+
|
|
1126
|
+
## ❓ FAQ
|
|
1127
|
+
|
|
1128
|
+
### What happens on first use?
|
|
1129
|
+
|
|
1130
|
+
On first use, `clang-tool-chain` automatically:
|
|
1131
|
+
1. Detects your platform and architecture
|
|
1132
|
+
2. Fetches the manifest for your platform
|
|
1133
|
+
3. Downloads the appropriate archive (~52-91 MB)
|
|
1134
|
+
4. Verifies the SHA256 checksum
|
|
1135
|
+
5. Extracts to `~/.clang-tool-chain/clang/{platform}/{arch}/`
|
|
1136
|
+
6. Executes your command
|
|
1137
|
+
|
|
1138
|
+
**Total time:** ~10-60 seconds depending on internet speed.
|
|
1139
|
+
|
|
1140
|
+
### Can I use clang-tool-chain offline?
|
|
1141
|
+
|
|
1142
|
+
Yes! After the initial download, `clang-tool-chain` works completely offline. The binaries are cached in `~/.clang-tool-chain/`.
|
|
1143
|
+
|
|
1144
|
+
### How do I update to a new LLVM version?
|
|
1145
|
+
|
|
1146
|
+
Currently, the LLVM version is tied to the package version. To update:
|
|
1147
|
+
```bash
|
|
1148
|
+
pip install --upgrade clang-tool-chain
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
Future versions will support multiple LLVM versions via manifest updates.
|
|
1152
|
+
|
|
1153
|
+
### Is it safe to delete `~/.clang-tool-chain/`?
|
|
1154
|
+
|
|
1155
|
+
Yes! Deleting this directory just removes the cached binaries. They will re-download automatically on next use.
|
|
1156
|
+
|
|
1157
|
+
### Can I use multiple LLVM versions simultaneously?
|
|
1158
|
+
|
|
1159
|
+
Not currently. Each `clang-tool-chain` package version maps to specific LLVM versions (see Platform Support Matrix). Use virtual environments to isolate different package versions:
|
|
1160
|
+
|
|
1161
|
+
```bash
|
|
1162
|
+
# Environment 1: LLVM 21.1.5
|
|
1163
|
+
python -m venv env1
|
|
1164
|
+
source env1/bin/activate
|
|
1165
|
+
pip install clang-tool-chain==1.0.1
|
|
1166
|
+
|
|
1167
|
+
# Environment 2: Future LLVM version
|
|
1168
|
+
python -m venv env2
|
|
1169
|
+
source env2/bin/activate
|
|
1170
|
+
pip install clang-tool-chain==1.1.0 # (hypothetical future version)
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
### How does checksum verification work?
|
|
1174
|
+
|
|
1175
|
+
Every archive download is verified against SHA256 checksums stored in the platform manifests. If the checksum doesn't match, the download is rejected and an error is raised. This protects against:
|
|
1176
|
+
- Corrupted downloads
|
|
1177
|
+
- Man-in-the-middle attacks
|
|
1178
|
+
- File tampering
|
|
1179
|
+
|
|
1180
|
+
### Why does macOS use LLVM 19.1.6 instead of 21.1.5?
|
|
1181
|
+
|
|
1182
|
+
LLVM 21.1.5 pre-built binaries for macOS were not available at the time of initial release. We're working on building and distributing LLVM 21.1.5 for macOS. Track progress in the repository issues.
|
|
1183
|
+
|
|
1184
|
+
### Can I contribute new platforms or architectures?
|
|
1185
|
+
|
|
1186
|
+
Yes! See the [Maintainer Tools](#-maintainer-tools) section for how to create optimized archives. Pull requests welcome!
|
|
1187
|
+
|
|
1188
|
+
### Does this work in Docker containers?
|
|
1189
|
+
|
|
1190
|
+
Absolutely! See the [CI/CD Integration](#-cicd-integration) section for Docker examples. The automatic download works seamlessly in containers.
|
|
1191
|
+
|
|
1192
|
+
### How much disk space do I need?
|
|
1193
|
+
|
|
1194
|
+
- **Download:** ~52-91 MB (archive)
|
|
1195
|
+
- **Installed:** ~200-350 MB (extracted binaries)
|
|
1196
|
+
- **Total:** ~252-441 MB per platform
|
|
1197
|
+
|
|
1198
|
+
The archive is deleted after extraction, so you only need space for the installed binaries.
|
|
1199
|
+
|
|
1200
|
+
### Can I use this with CMake?
|
|
1201
|
+
|
|
1202
|
+
Yes! Set the compiler in your `CMakeLists.txt` or via environment variables:
|
|
1203
|
+
|
|
1204
|
+
```bash
|
|
1205
|
+
# Option 1: Environment variables
|
|
1206
|
+
export CC=clang-tool-chain-c
|
|
1207
|
+
export CXX=clang-tool-chain-cpp
|
|
1208
|
+
cmake -B build
|
|
1209
|
+
|
|
1210
|
+
# Option 2: CMake command line
|
|
1211
|
+
cmake -B build \
|
|
1212
|
+
-DCMAKE_C_COMPILER=clang-tool-chain-c \
|
|
1213
|
+
-DCMAKE_CXX_COMPILER=clang-tool-chain-cpp
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
### What about Windows paths with spaces?
|
|
1217
|
+
|
|
1218
|
+
All paths are handled correctly, including those with spaces. The wrappers quote paths appropriately.
|
|
1219
|
+
|
|
1220
|
+
### Do I need to install Xcode on macOS?
|
|
1221
|
+
|
|
1222
|
+
No! You only need the **Xcode Command Line Tools**, which is much smaller:
|
|
1223
|
+
|
|
1224
|
+
```bash
|
|
1225
|
+
xcode-select --install
|
|
1226
|
+
```
|
|
1227
|
+
|
|
1228
|
+
This provides the SDK headers needed for compilation without installing the full Xcode IDE.
|
|
1229
|
+
|
|
1230
|
+
---
|
|
1231
|
+
|
|
1232
|
+
## 🔍 Troubleshooting
|
|
1233
|
+
|
|
1234
|
+
### Binaries Not Found
|
|
1235
|
+
|
|
1236
|
+
**Error:** `Clang binaries are not installed`
|
|
1237
|
+
|
|
1238
|
+
**Solution:**
|
|
1239
|
+
```bash
|
|
1240
|
+
# Check installation status
|
|
1241
|
+
clang-tool-chain info
|
|
1242
|
+
|
|
1243
|
+
# Try manual fetch
|
|
1244
|
+
clang-tool-chain-fetch
|
|
1245
|
+
|
|
1246
|
+
# Verify installation directory exists
|
|
1247
|
+
ls ~/.clang-tool-chain/
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
### Platform Not Supported
|
|
1251
|
+
|
|
1252
|
+
**Error:** `Unsupported platform`
|
|
1253
|
+
|
|
1254
|
+
**Solution:** Ensure you're on a supported platform:
|
|
1255
|
+
- Windows 10+ (x64)
|
|
1256
|
+
- Linux x64 or ARM64 (glibc 2.27+)
|
|
1257
|
+
- macOS 11+ (x64 or ARM64)
|
|
1258
|
+
|
|
1259
|
+
32-bit systems are **not supported**.
|
|
1260
|
+
|
|
1261
|
+
### Download Fails
|
|
1262
|
+
|
|
1263
|
+
**Error:** `Failed to download archive` or `Checksum verification failed`
|
|
1264
|
+
|
|
1265
|
+
**Solutions:**
|
|
1266
|
+
1. **Check internet connection**
|
|
1267
|
+
2. **Retry the command** (temporary network issue)
|
|
1268
|
+
3. **Check GitHub raw content access:**
|
|
1269
|
+
```bash
|
|
1270
|
+
curl -I https://raw.githubusercontent.com/zackees/clang-tool-chain-bins/main/assets/clang/manifest.json
|
|
1271
|
+
```
|
|
1272
|
+
4. **Clear partial downloads:**
|
|
1273
|
+
```bash
|
|
1274
|
+
rm -rf ~/.clang-tool-chain/
|
|
1275
|
+
```
|
|
1276
|
+
|
|
1277
|
+
### Tool Execution Fails
|
|
1278
|
+
|
|
1279
|
+
**Error:** `Permission denied` (Linux/macOS)
|
|
1280
|
+
|
|
1281
|
+
**Solution:**
|
|
1282
|
+
```bash
|
|
1283
|
+
# Ensure execute permissions
|
|
1284
|
+
chmod +x ~/.clang-tool-chain/clang/*/bin/*
|
|
1285
|
+
|
|
1286
|
+
# Or reinstall
|
|
1287
|
+
rm -rf ~/.clang-tool-chain/
|
|
1288
|
+
clang-tool-chain-c --version # Re-downloads with correct permissions
|
|
1289
|
+
```
|
|
1290
|
+
|
|
1291
|
+
### macOS: stdio.h or iostream Not Found
|
|
1292
|
+
|
|
1293
|
+
**Error:** `fatal error: 'stdio.h' file not found` or `'iostream' file not found`
|
|
1294
|
+
|
|
1295
|
+
**Cause:** Xcode Command Line Tools not installed or SDK not detected.
|
|
1296
|
+
|
|
1297
|
+
**Solution:**
|
|
1298
|
+
```bash
|
|
1299
|
+
# Install Xcode Command Line Tools
|
|
1300
|
+
xcode-select --install
|
|
1301
|
+
|
|
1302
|
+
# Verify SDK is detected
|
|
1303
|
+
xcrun --show-sdk-path
|
|
1304
|
+
|
|
1305
|
+
# Should output something like:
|
|
1306
|
+
# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
|
|
1307
|
+
|
|
1308
|
+
# Try compilation again
|
|
1309
|
+
clang-tool-chain-c hello.c -o hello
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
**Advanced troubleshooting:**
|
|
1313
|
+
```bash
|
|
1314
|
+
# Manually specify SDK path
|
|
1315
|
+
clang-tool-chain-c -isysroot $(xcrun --show-sdk-path) hello.c -o hello
|
|
1316
|
+
|
|
1317
|
+
# Or set SDKROOT environment variable
|
|
1318
|
+
export SDKROOT=$(xcrun --show-sdk-path)
|
|
1319
|
+
clang-tool-chain-c hello.c -o hello
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
### Slow First-Time Download
|
|
1323
|
+
|
|
1324
|
+
**Observation:** First compilation takes 30-60 seconds
|
|
1325
|
+
|
|
1326
|
+
**This is normal!** The toolchain is downloading. Subsequent compilations are instant. To pre-download:
|
|
1327
|
+
|
|
1328
|
+
```bash
|
|
1329
|
+
# Pre-fetch binaries before your build
|
|
1330
|
+
clang-tool-chain-fetch
|
|
1331
|
+
|
|
1332
|
+
# Or just run any command
|
|
1333
|
+
clang-tool-chain-c --version
|
|
1334
|
+
```
|
|
1335
|
+
|
|
1336
|
+
### Import Errors
|
|
1337
|
+
|
|
1338
|
+
**Error:** `ModuleNotFoundError: No module named 'clang_tool_chain'`
|
|
1339
|
+
|
|
1340
|
+
**Solutions:**
|
|
1341
|
+
1. **Ensure package is installed:**
|
|
1342
|
+
```bash
|
|
1343
|
+
pip install clang-tool-chain
|
|
1344
|
+
```
|
|
1345
|
+
|
|
1346
|
+
2. **Check Python environment:**
|
|
1347
|
+
```bash
|
|
1348
|
+
which python # Verify correct Python interpreter
|
|
1349
|
+
pip list | grep clang-tool-chain
|
|
1350
|
+
```
|
|
1351
|
+
|
|
1352
|
+
3. **Reinstall:**
|
|
1353
|
+
```bash
|
|
1354
|
+
pip uninstall clang-tool-chain
|
|
1355
|
+
pip install clang-tool-chain
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
### Custom Installation Path Not Working
|
|
1359
|
+
|
|
1360
|
+
**Error:** Binaries install to default location despite `CLANG_TOOL_CHAIN_DOWNLOAD_PATH`
|
|
1361
|
+
|
|
1362
|
+
**Solution:** Ensure the environment variable is set **before** running the command:
|
|
1363
|
+
|
|
1364
|
+
```bash
|
|
1365
|
+
# Linux/macOS
|
|
1366
|
+
export CLANG_TOOL_CHAIN_DOWNLOAD_PATH=/custom/path
|
|
1367
|
+
clang-tool-chain-c hello.c
|
|
1368
|
+
|
|
1369
|
+
# Windows (CMD)
|
|
1370
|
+
set CLANG_TOOL_CHAIN_DOWNLOAD_PATH=C:\custom\path
|
|
1371
|
+
clang-tool-chain-c hello.c
|
|
1372
|
+
|
|
1373
|
+
# Windows (PowerShell)
|
|
1374
|
+
$env:CLANG_TOOL_CHAIN_DOWNLOAD_PATH="C:\custom\path"
|
|
1375
|
+
clang-tool-chain-c hello.c
|
|
1376
|
+
```
|
|
1377
|
+
|
|
1378
|
+
---
|
|
1379
|
+
|
|
1380
|
+
## 🔒 Security
|
|
1381
|
+
|
|
1382
|
+
Security is a top priority for this project.
|
|
1383
|
+
|
|
1384
|
+
### Checksum Verification
|
|
1385
|
+
|
|
1386
|
+
- **Automatic:** SHA256 checksums are verified during download (enabled by default)
|
|
1387
|
+
- **Manifest-Based:** Checksums stored in version-controlled manifests
|
|
1388
|
+
- **Protection:** Detects corrupted downloads, MITM attacks, and file tampering
|
|
1389
|
+
- **Transparency:** All checksums visible in `downloads-bins/assets/clang/{platform}/{arch}/manifest.json`
|
|
1390
|
+
|
|
1391
|
+
### Safe Extraction
|
|
1392
|
+
|
|
1393
|
+
- **Python 3.12+ Tarfile Safety:** Uses `filter="data"` to prevent path traversal attacks
|
|
1394
|
+
- **Temporary Directory:** Extraction happens in temp directory, then moved atomically
|
|
1395
|
+
- **Validation:** Verifies archive integrity before extraction
|
|
1396
|
+
|
|
1397
|
+
### Download Security
|
|
1398
|
+
|
|
1399
|
+
Binaries are served from GitHub raw content (`raw.githubusercontent.com`):
|
|
1400
|
+
- ✅ **Checksum Verified:** SHA256 validation on every download
|
|
1401
|
+
- ✅ **Version Locked:** Manifests are version-controlled in the repository
|
|
1402
|
+
- ⚠️ **Trust Model:** You're trusting this package maintainer + GitHub infrastructure
|
|
1403
|
+
- 🔒 **HTTPS Only:** All downloads use encrypted connections
|
|
1404
|
+
|
|
1405
|
+
**For maximum security:**
|
|
1406
|
+
```bash
|
|
1407
|
+
# Option 1: Manual verification
|
|
1408
|
+
clang-tool-chain-fetch --dry-run # Shows download URLs
|
|
1409
|
+
# Verify checksums in downloads-bins/assets/clang/<platform>/<arch>/manifest.json
|
|
1410
|
+
|
|
1411
|
+
# Option 2: Offline installation
|
|
1412
|
+
# Download archive, verify checksum independently, then extract manually
|
|
1413
|
+
```
|
|
1414
|
+
|
|
1415
|
+
### Reporting Security Issues
|
|
1416
|
+
|
|
1417
|
+
For security vulnerabilities, please see our [Security Policy](SECURITY.md) for responsible disclosure instructions.
|
|
1418
|
+
|
|
1419
|
+
**Do NOT** report security issues in public GitHub issues.
|
|
1420
|
+
|
|
1421
|
+
---
|
|
1422
|
+
|
|
1423
|
+
## 👨💻 Development
|
|
1424
|
+
|
|
1425
|
+
### Development Setup
|
|
1426
|
+
|
|
1427
|
+
```bash
|
|
1428
|
+
# Clone repository
|
|
1429
|
+
git clone https://github.com/zackees/clang-tool-chain.git
|
|
1430
|
+
cd clang-tool-chain
|
|
1431
|
+
|
|
1432
|
+
# Install dependencies (using uv - recommended)
|
|
1433
|
+
./install
|
|
1434
|
+
|
|
1435
|
+
# Or manually:
|
|
1436
|
+
uv venv --python 3.11
|
|
1437
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
1438
|
+
uv pip install -e ".[dev]"
|
|
1439
|
+
pre-commit install
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
### Running Tests
|
|
1443
|
+
|
|
1444
|
+
```bash
|
|
1445
|
+
# Run all tests with coverage (parallel execution)
|
|
1446
|
+
./test
|
|
1447
|
+
|
|
1448
|
+
# Or manually with pytest:
|
|
1449
|
+
uv run pytest # Run with coverage reporting
|
|
1450
|
+
uv run pytest -n auto # Run in parallel
|
|
1451
|
+
uv run pytest tests/test_cli.py # Run specific test file
|
|
1452
|
+
uv run pytest -m "not slow" # Skip slow tests
|
|
1453
|
+
|
|
1454
|
+
# Run single test
|
|
1455
|
+
uv run pytest tests/test_cli.py::MainTester::test_imports -v
|
|
1456
|
+
```
|
|
1457
|
+
|
|
1458
|
+
### Code Quality
|
|
1459
|
+
|
|
1460
|
+
```bash
|
|
1461
|
+
# Run all linters and formatters
|
|
1462
|
+
./lint
|
|
1463
|
+
|
|
1464
|
+
# Individual tools:
|
|
1465
|
+
uv run ruff check --fix src tests # Lint with auto-fix
|
|
1466
|
+
uv run black src tests # Format code
|
|
1467
|
+
uv run isort --profile black src tests # Sort imports
|
|
1468
|
+
uv run pyright src tests # Type checking
|
|
1469
|
+
uv run mypy src tests # Alternative type checking
|
|
1470
|
+
```
|
|
1471
|
+
|
|
1472
|
+
### Pre-commit Hooks
|
|
1473
|
+
|
|
1474
|
+
```bash
|
|
1475
|
+
# Install pre-commit hooks
|
|
1476
|
+
pre-commit install
|
|
1477
|
+
|
|
1478
|
+
# Run all pre-commit checks manually
|
|
1479
|
+
pre-commit run --all-files
|
|
1480
|
+
|
|
1481
|
+
# Update hook versions
|
|
1482
|
+
pre-commit autoupdate
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
### Building and Publishing
|
|
1486
|
+
|
|
1487
|
+
```bash
|
|
1488
|
+
# Build the package
|
|
1489
|
+
uv run python -m build
|
|
1490
|
+
|
|
1491
|
+
# Check the built package
|
|
1492
|
+
twine check dist/*
|
|
1493
|
+
|
|
1494
|
+
# Upload to PyPI (maintainers only)
|
|
1495
|
+
./upload_package.sh
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
---
|
|
1499
|
+
|
|
1500
|
+
## 🛠️ Maintainer Tools
|
|
1501
|
+
|
|
1502
|
+
<details>
|
|
1503
|
+
<summary><b>Click to expand maintainer documentation</b> (for package maintainers only)</summary>
|
|
1504
|
+
|
|
1505
|
+
### Archive Creation Pipeline
|
|
1506
|
+
|
|
1507
|
+
The `clang-tool-chain-fetch-archive` command automates the complete packaging process:
|
|
1508
|
+
|
|
1509
|
+
```bash
|
|
1510
|
+
# Create optimized archive for Windows x86_64
|
|
1511
|
+
clang-tool-chain-fetch-archive --platform win --arch x86_64
|
|
1512
|
+
|
|
1513
|
+
# Create archive for Linux x86_64
|
|
1514
|
+
clang-tool-chain-fetch-archive --platform linux --arch x86_64
|
|
1515
|
+
|
|
1516
|
+
# Create archive for macOS ARM64 (Apple Silicon)
|
|
1517
|
+
clang-tool-chain-fetch-archive --platform darwin --arch arm64
|
|
1518
|
+
|
|
1519
|
+
# Use existing extracted binaries (skip download)
|
|
1520
|
+
clang-tool-chain-fetch-archive \
|
|
1521
|
+
--platform win --arch x86_64 \
|
|
1522
|
+
--source-dir ./assets/win
|
|
1523
|
+
```
|
|
1524
|
+
|
|
1525
|
+
**What it does:**
|
|
1526
|
+
|
|
1527
|
+
1. ✅ Downloads LLVM 21.1.5 from official GitHub releases (~400-900 MB)
|
|
1528
|
+
2. ✅ Extracts the archive
|
|
1529
|
+
3. ✅ Strips unnecessary files (docs, examples, static libs)
|
|
1530
|
+
4. ✅ Deduplicates identical binaries (~571 MB savings via MD5 hash detection)
|
|
1531
|
+
5. ✅ Creates hard-linked structure (reduces size without data loss)
|
|
1532
|
+
6. ✅ Compresses with **zstd level 22** (94.3% reduction!)
|
|
1533
|
+
7. ✅ Generates checksums (SHA256, MD5)
|
|
1534
|
+
8. ✅ Names archive: `llvm-{version}-{platform}-{arch}.tar.zst`
|
|
1535
|
+
9. ✅ Places in `downloads-bins/assets/clang/{platform}/{arch}/`
|
|
1536
|
+
10. ✅ Updates platform manifest with URLs and checksums
|
|
1537
|
+
|
|
1538
|
+
**Result:** 51.53 MB archive (from 902 MB original) for Windows x86_64!
|
|
1539
|
+
|
|
1540
|
+
### Individual Maintainer Scripts
|
|
1541
|
+
|
|
1542
|
+
Available as Python modules in `clang_tool_chain.downloads`:
|
|
1543
|
+
|
|
1544
|
+
#### download_binaries.py
|
|
1545
|
+
Download LLVM releases from GitHub:
|
|
1546
|
+
|
|
1547
|
+
```bash
|
|
1548
|
+
python -m clang_tool_chain.downloads.download_binaries \
|
|
1549
|
+
--platform win --arch x86_64 --version 21.1.5
|
|
1550
|
+
|
|
1551
|
+
# Download for current platform only
|
|
1552
|
+
python -m clang_tool_chain.downloads.download_binaries --current-only
|
|
1553
|
+
|
|
1554
|
+
# Skip checksum verification (not recommended)
|
|
1555
|
+
python -m clang_tool_chain.downloads.download_binaries --current-only --no-verify
|
|
1556
|
+
```
|
|
1557
|
+
|
|
1558
|
+
#### strip_binaries.py
|
|
1559
|
+
Optimize binary size by removing unnecessary files:
|
|
1560
|
+
|
|
1561
|
+
```bash
|
|
1562
|
+
python -m clang_tool_chain.downloads.strip_binaries \
|
|
1563
|
+
work/clang+llvm-21.1.5-x86_64-pc-windows-msvc \
|
|
1564
|
+
downloads-bins/assets/clang/win/x86_64 \
|
|
1565
|
+
--platform win
|
|
1566
|
+
```
|
|
1567
|
+
|
|
1568
|
+
**Removes:**
|
|
1569
|
+
- Documentation (`share/doc`, `share/man`)
|
|
1570
|
+
- Headers and examples
|
|
1571
|
+
- Static libraries (`*.a`, `*.lib`)
|
|
1572
|
+
- CMake files
|
|
1573
|
+
- Debug symbols (using `llvm-strip`)
|
|
1574
|
+
|
|
1575
|
+
**Keeps:**
|
|
1576
|
+
- 14 essential binaries
|
|
1577
|
+
- Runtime libraries (`*.so`, `*.dll`, `*.dylib`)
|
|
1578
|
+
- License files
|
|
1579
|
+
|
|
1580
|
+
**Size reduction:** ~3.5 GB → ~200-400 MB per platform
|
|
1581
|
+
|
|
1582
|
+
#### deduplicate_binaries.py
|
|
1583
|
+
Find duplicate binaries by MD5 hash:
|
|
1584
|
+
|
|
1585
|
+
```bash
|
|
1586
|
+
python -m clang_tool_chain.downloads.deduplicate_binaries \
|
|
1587
|
+
work/clang+llvm-21.1.5-x86_64-pc-windows-msvc/bin
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
**Output:**
|
|
1591
|
+
```
|
|
1592
|
+
Duplicate groups found: 45
|
|
1593
|
+
Total duplicates: 158 files
|
|
1594
|
+
Potential space savings: 571.23 MB
|
|
1595
|
+
|
|
1596
|
+
Duplicate group #1 (MD5: a1b2c3d4...):
|
|
1597
|
+
- clang.exe (12.5 MB)
|
|
1598
|
+
- clang++.exe (12.5 MB)
|
|
1599
|
+
- clang-cl.exe (12.5 MB)
|
|
1600
|
+
```
|
|
1601
|
+
|
|
1602
|
+
#### create_hardlink_archive.py
|
|
1603
|
+
Create hard-linked TAR archives (preserves hard links during extraction):
|
|
1604
|
+
|
|
1605
|
+
```bash
|
|
1606
|
+
python -m clang_tool_chain.downloads.create_hardlink_archive \
|
|
1607
|
+
input/win \
|
|
1608
|
+
output/llvm-21.1.5-win-x86_64.tar.zst \
|
|
1609
|
+
--compression-level 22
|
|
1610
|
+
```
|
|
1611
|
+
|
|
1612
|
+
**Benefits:**
|
|
1613
|
+
- Preserves hard links (deduplication survives extraction)
|
|
1614
|
+
- Ultra-high compression (zstd level 22)
|
|
1615
|
+
- Maintains file permissions and metadata
|
|
1616
|
+
|
|
1617
|
+
#### expand_archive.py
|
|
1618
|
+
Extract `.tar.zst` archives:
|
|
1619
|
+
|
|
1620
|
+
```bash
|
|
1621
|
+
python -m clang_tool_chain.downloads.expand_archive \
|
|
1622
|
+
llvm-21.1.5-win-x86_64.tar.zst \
|
|
1623
|
+
output/win
|
|
1624
|
+
```
|
|
1625
|
+
|
|
1626
|
+
**Features:**
|
|
1627
|
+
- Handles zstd compression
|
|
1628
|
+
- Preserves hard links
|
|
1629
|
+
- Shows extraction progress
|
|
1630
|
+
- Validates archive integrity
|
|
1631
|
+
|
|
1632
|
+
#### test_compression.py
|
|
1633
|
+
Compare compression methods and levels:
|
|
1634
|
+
|
|
1635
|
+
```bash
|
|
1636
|
+
python -m clang_tool_chain.downloads.test_compression \
|
|
1637
|
+
input/win \
|
|
1638
|
+
--methods zstd gzip xz \
|
|
1639
|
+
--levels 1 9 22
|
|
1640
|
+
```
|
|
1641
|
+
|
|
1642
|
+
**Output:**
|
|
1643
|
+
```
|
|
1644
|
+
Testing compression methods...
|
|
1645
|
+
|
|
1646
|
+
zstd level 1: Size: 156 MB, Time: 2.3s
|
|
1647
|
+
zstd level 9: Size: 78 MB, Time: 8.7s
|
|
1648
|
+
zstd level 22: Size: 51 MB, Time: 45.2s ⭐ BEST RATIO
|
|
1649
|
+
|
|
1650
|
+
gzip level 9: Size: 124 MB, Time: 15.6s
|
|
1651
|
+
xz level 9: Size: 89 MB, Time: 67.3s
|
|
1652
|
+
```
|
|
1653
|
+
|
|
1654
|
+
### Compression Statistics
|
|
1655
|
+
|
|
1656
|
+
**Windows x86_64 (LLVM 21.1.5):**
|
|
1657
|
+
- Original: 902 MB
|
|
1658
|
+
- After stripping: 200 MB
|
|
1659
|
+
- After deduplication (hard links): 200 MB (same size, but ~571 MB savings on disk)
|
|
1660
|
+
- After zstd level 22: **51.53 MB** (94.3% reduction from original!)
|
|
1661
|
+
|
|
1662
|
+
**Linux x86_64 (LLVM 21.1.5):**
|
|
1663
|
+
- Original: ~850 MB
|
|
1664
|
+
- After optimization: **88 MB archive**
|
|
1665
|
+
|
|
1666
|
+
**macOS ARM64 (LLVM 19.1.6):**
|
|
1667
|
+
- Original: ~750 MB
|
|
1668
|
+
- After optimization: **71 MB archive**
|
|
1669
|
+
|
|
1670
|
+
### Updating Manifests
|
|
1671
|
+
|
|
1672
|
+
After creating archives, update the manifest files:
|
|
1673
|
+
|
|
1674
|
+
1. **Generate SHA256 checksum:**
|
|
1675
|
+
```bash
|
|
1676
|
+
sha256sum downloads-bins/assets/clang/win/x86_64/llvm-21.1.5-win-x86_64.tar.zst
|
|
1677
|
+
```
|
|
1678
|
+
|
|
1679
|
+
2. **Update platform manifest** (`downloads-bins/assets/clang/win/x86_64/manifest.json`):
|
|
1680
|
+
```json
|
|
1681
|
+
{
|
|
1682
|
+
"latest": "21.1.5",
|
|
1683
|
+
"21.1.5": {
|
|
1684
|
+
"href": "https://raw.githubusercontent.com/zackees/clang-tool-chain-bins/main/assets/clang/win/x86_64/llvm-21.1.5-win-x86_64.tar.zst",
|
|
1685
|
+
"sha256": "3c21e45edeee591fe8ead5427d25b62ddb26c409575b41db03d6777c77bba44f"
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
```
|
|
1689
|
+
|
|
1690
|
+
3. **Commit and push to downloads-bins submodule:**
|
|
1691
|
+
```bash
|
|
1692
|
+
cd downloads-bins
|
|
1693
|
+
git add assets/clang/
|
|
1694
|
+
git commit -m "chore: add LLVM 21.1.5 for Windows x86_64"
|
|
1695
|
+
git push
|
|
1696
|
+
cd ..
|
|
1697
|
+
git add downloads-bins
|
|
1698
|
+
git commit -m "chore: update submodule to latest binaries"
|
|
1699
|
+
git push
|
|
1700
|
+
```
|
|
1701
|
+
|
|
1702
|
+
</details>
|
|
1703
|
+
|
|
1704
|
+
---
|
|
1705
|
+
|
|
1706
|
+
## 📄 License
|
|
1707
|
+
|
|
1708
|
+
This package is distributed under the **Apache License 2.0**. See [LICENSE](LICENSE) for details.
|
|
1709
|
+
|
|
1710
|
+
The bundled LLVM/Clang binaries are licensed under the **Apache License 2.0 with LLVM Exception**. See [LLVM License](https://llvm.org/LICENSE.txt) for details.
|
|
1711
|
+
|
|
1712
|
+
---
|
|
1713
|
+
|
|
1714
|
+
## 🙏 Acknowledgments
|
|
1715
|
+
|
|
1716
|
+
- **[LLVM Project](https://llvm.org/)** - For the excellent Clang/LLVM toolchain
|
|
1717
|
+
- **[GitHub LLVM Releases](https://github.com/llvm/llvm-project/releases)** - For providing pre-built binaries
|
|
1718
|
+
- **[Zstandard (zstd)](https://facebook.github.io/zstd/)** - For incredible compression performance
|
|
1719
|
+
- **[pyzstd](https://github.com/animalize/pyzstd)** - For Python zstd bindings
|
|
1720
|
+
- **[fasteners](https://github.com/harlowja/fasteners)** - For cross-platform file locking
|
|
1721
|
+
|
|
1722
|
+
---
|
|
1723
|
+
|
|
1724
|
+
## 📊 Version History
|
|
1725
|
+
|
|
1726
|
+
### 1.0.1 (2025-11-09)
|
|
1727
|
+
- ✅ Automatic macOS SDK detection via xcrun
|
|
1728
|
+
- ✅ Improved error messages and troubleshooting
|
|
1729
|
+
- ✅ Enhanced documentation with platform-specific guidance
|
|
1730
|
+
|
|
1731
|
+
### 1.0.0 (2025-11-07) - Initial Release
|
|
1732
|
+
- ✅ Core wrapper infrastructure for 22 wrapper commands
|
|
1733
|
+
- ✅ Automatic download and installation system
|
|
1734
|
+
- ✅ Manifest-based distribution with SHA256 verification
|
|
1735
|
+
- ✅ Binary optimization pipeline (stripping, deduplication, compression)
|
|
1736
|
+
- ✅ CLI management commands (`info`, `version`, `list-tools`, `path`)
|
|
1737
|
+
- ✅ Cross-platform support (Windows x64, macOS x64/ARM64, Linux x64/ARM64)
|
|
1738
|
+
- ✅ File locking for concurrent-safe downloads
|
|
1739
|
+
- ✅ Ultra-compressed archives (zstd level 22, 94.3% size reduction)
|
|
1740
|
+
- ✅ LLVM 21.1.5 for Windows/Linux, 19.1.6 for macOS
|
|
1741
|
+
- ✅ Comprehensive test suite with CI/CD integration
|
|
1742
|
+
|
|
1743
|
+
---
|
|
1744
|
+
|
|
1745
|
+
## 🚀 Getting Started
|
|
1746
|
+
|
|
1747
|
+
Ready to compile? Install and run:
|
|
1748
|
+
|
|
1749
|
+
```bash
|
|
1750
|
+
pip install clang-tool-chain
|
|
1751
|
+
echo 'int main() { return 0; }' > hello.c
|
|
1752
|
+
clang-tool-chain-c hello.c -o hello
|
|
1753
|
+
./hello
|
|
1754
|
+
```
|
|
1755
|
+
|
|
1756
|
+
That's all you need! The toolchain downloads automatically. Happy compiling! 🎉
|
|
1757
|
+
|
|
1758
|
+
---
|
|
1759
|
+
|
|
1760
|
+
**Repository:** [github.com/zackees/clang-tool-chain](https://github.com/zackees/clang-tool-chain)
|
|
1761
|
+
**Issues:** [github.com/zackees/clang-tool-chain/issues](https://github.com/zackees/clang-tool-chain/issues)
|
|
1762
|
+
**PyPI:** [pypi.org/project/clang-tool-chain/](https://pypi.org/project/clang-tool-chain/)
|
|
1763
|
+
|
|
1764
|
+
---
|
|
1765
|
+
|
|
1766
|
+
**Keywords:** clang wrapper, llvm python, portable clang, clang installer, llvm toolchain, cross-platform compiler, python clang, automated llvm, clang docker, ci/cd compiler
|