|
1 | 1 | # Cross-Compiler Toolchains |
2 | 2 |
|
3 | | -This directory contains pre-built cross-compiler toolchains from [musl.cc](https://musl.cc/). |
| 3 | +This directory contains downloaded musl-cross pre-built toolchains for cross-compilation support. |
4 | 4 |
|
5 | | -## Files |
| 5 | +## Installation |
6 | 6 |
|
7 | | -These files are stored with Git LFS (Large File Storage) and are downloaded via GitHub Actions CI/CD: |
| 7 | +The musl cross-compiler binaries are downloaded on-demand and stored in the `x-tools/` subdirectory. |
8 | 8 |
|
9 | | -- `arm-linux-musleabihf-cross.tgz` - ARM 32-bit (ARMv7) EABI Hard Float |
10 | | -- `riscv64-linux-musl-cross.tgz` - RISC-V 64-bit |
11 | | -- `s390x-linux-musl-cross.tgz` - IBM System z (s390x) |
12 | | -- `powerpc64le-linux-musl-cross.tgz` - PowerPC 64-bit Little Endian |
| 9 | +To install the musl-cross toolchains locally: |
13 | 10 |
|
14 | | -## Downloading Toolchains Locally |
| 11 | +```bash |
| 12 | +./scripts/download-musl-cross.sh |
| 13 | +``` |
15 | 14 |
|
16 | | -To download these toolchains to your local machine: |
| 15 | +This will download all four supported architectures from the [cross-tools/musl-cross](https://github.com/cross-tools/musl-cross) GitHub releases. |
17 | 16 |
|
18 | | -1. **Install Git LFS** (if not already installed): |
19 | | - ```bash |
20 | | - # macOS |
21 | | - brew install git-lfs |
| 17 | +To download a specific architecture only: |
22 | 18 |
|
23 | | - # Ubuntu/Debian |
24 | | - sudo apt-get install git-lfs |
| 19 | +```bash |
| 20 | +./scripts/download-musl-cross.sh arm-unknown-linux-musleabihf |
| 21 | +./scripts/download-musl-cross.sh riscv64-unknown-linux-musl |
| 22 | +./scripts/download-musl-cross.sh s390x-ibm-linux-musl |
| 23 | +./scripts/download-musl-cross.sh powerpc64le-unknown-linux-musl |
| 24 | +``` |
25 | 25 |
|
26 | | - # Other systems: https://git-lfs.com/ |
27 | | - ``` |
| 26 | +## Building with Musl |
28 | 27 |
|
29 | | -2. **Initialize Git LFS in this repository** (one-time setup): |
30 | | - ```bash |
31 | | - git lfs install |
32 | | - ``` |
| 28 | +Once installed, you can build for musl targets: |
33 | 29 |
|
34 | | -3. **Run the download script**: |
35 | | - ```bash |
36 | | - ./scripts/download-musl-cc.sh |
37 | | - ``` |
| 30 | +```bash |
| 31 | +mkdir build && cd build |
| 32 | +cmake -DTARGET=arm-unknown-linux-musleabihf .. |
| 33 | +cmake --build . |
| 34 | +``` |
38 | 35 |
|
39 | | - This script will: |
40 | | - - Create this directory if it doesn't exist |
41 | | - - Download all four cross-compiler toolchains |
42 | | - - Retry up to 3 times if downloads fail |
43 | | - - Store them for Git LFS tracking |
| 36 | +## Supported Architectures |
44 | 37 |
|
45 | | -4. **Commit and push to GitHub**: |
46 | | - ```bash |
47 | | - git add cross-compilers/ .gitattributes |
48 | | - git commit -m "Add musl.cc cross-compiler toolchains" |
49 | | - git push |
50 | | - ``` |
| 38 | +- **arm-unknown-linux-musleabihf** - ARM 32-bit (ARMv7) EABI Hard Float |
| 39 | +- **riscv64-unknown-linux-musl** - RISC-V 64-bit |
| 40 | +- **s390x-ibm-linux-musl** - IBM System z (s390x) |
| 41 | +- **powerpc64le-unknown-linux-musl** - PowerPC 64-bit Little Endian |
51 | 42 |
|
52 | | -## Git LFS Tracking |
| 43 | +## Directory Structure |
53 | 44 |
|
54 | | -These files are tracked with Git LFS, which means: |
| 45 | +``` |
| 46 | +cross-compilers/ |
| 47 | +├── README.md (this file) |
| 48 | +├── .gitkeep |
| 49 | +└── x-tools/ |
| 50 | + ├── arm-unknown-linux-musleabihf/ |
| 51 | + ├── riscv64-unknown-linux-musl/ |
| 52 | + ├── s390x-ibm-linux-musl/ |
| 53 | + └── powerpc64le-unknown-linux-musl/ |
| 54 | +``` |
55 | 55 |
|
56 | | -- Git stores pointers to the actual files instead of the full archives |
57 | | -- The repository size remains small |
58 | | -- When you clone or pull, Git LFS downloads only the files you need |
59 | | -- Bandwidth usage is optimized for large binary files |
| 56 | +The `x-tools/` directory is generated by the download script and is not checked into Git. |
60 | 57 |
|
61 | | -To verify Git LFS is working correctly, check the `.gitattributes` file to see which patterns are tracked. |
| 58 | +## Optional |
62 | 59 |
|
63 | | -## Why These Toolchains? |
| 60 | +These toolchains are **optional**. If you don't need musl cross-compilation, you can build for your native platform without downloading them: |
64 | 61 |
|
65 | | -The musl.cc project provides pre-built, statically-linked cross-compiler toolchains. They're: |
66 | | -- Ready to use without system dependencies |
67 | | -- Statically compiled (portable across Linux distributions) |
68 | | -- Designed for cross-compilation to various architectures |
69 | | -- Updated regularly with latest compiler versions |
70 | | - |
71 | | -## Updates |
72 | | - |
73 | | -To update these toolchains to newer versions in the future: |
74 | | - |
75 | | -1. Run the download script again: `./scripts/download-musl-cc.sh` |
76 | | -2. Git will detect changes if new versions are available |
77 | | -3. Commit and push the updated files |
| 62 | +```bash |
| 63 | +mkdir build && cd build |
| 64 | +cmake .. # Auto-detects your native platform |
| 65 | +cmake --build . |
| 66 | +``` |
78 | 67 |
|
79 | 68 | ## References |
80 | 69 |
|
81 | | -- [musl.cc](https://musl.cc/) - Pre-built musl libc cross-compiler toolchains |
82 | | -- [Git LFS Documentation](https://git-lfs.com/) |
| 70 | +- [cross-tools/musl-cross](https://github.com/cross-tools/musl-cross) - Pre-built musl libc cross-compiler toolchains |
| 71 | +- [musl libc](https://musl.libc.org) - Standard C library for Linux |
0 commit comments