浏览代码

Merge pull request #80 from plctlab/copilot/add-gcc-toolchain-action

Add GitHub Actions for automated GCC toolchain builds and releases
Bernard Xiong 2 月之前
父节点
当前提交
2a640be9b0
共有 6 个文件被更改,包括 754 次插入0 次删除
  1. 198 0
      .github/workflows/README.md
  2. 155 0
      .github/workflows/build-single-toolchain.yml
  3. 243 0
      .github/workflows/build-toolchain.yml
  4. 72 0
      .github/workflows/release.yml
  5. 43 0
      README.md
  6. 43 0
      README_zh.md

+ 198 - 0
.github/workflows/README.md

@@ -0,0 +1,198 @@
+# GitHub Actions Workflows for mlibc
+
+This directory contains GitHub Actions workflows for automating the build and release of mlibc and its GCC toolchains.
+
+## Workflows
+
+### 1. Release mlibc Source (`release.yml`)
+
+**Purpose**: Automatically creates source code releases for mlibc.
+
+**Triggers**:
+- Automatically on version tags (e.g., `v1.0.0`)
+- Manually via workflow dispatch with custom version
+
+**What it does**:
+- Creates a source tarball from the repository
+- Generates SHA256 checksum
+- Creates a GitHub release with the source archive
+
+**Manual trigger**:
+```bash
+# Via GitHub UI: Actions -> Release mlibc Source -> Run workflow
+# Or use GitHub CLI:
+gh workflow run release.yml -f version=v1.0.0
+```
+
+### 2. Build GCC Toolchains (`build-toolchain.yml`)
+
+**Purpose**: Builds GCC toolchains with mlibc for multiple architectures.
+
+**Triggers**:
+- Automatically on version tags (e.g., `v1.0.0`)
+- Manually via workflow dispatch with optional architecture selection
+
+**What it does**:
+- Builds toolchains for selected architectures (default: all)
+- Creates tarball packages for each toolchain
+- Generates SHA256 checksums
+- On tag push: Creates a GitHub release with all toolchain packages
+
+**Supported architectures**:
+- `arm` - ARM Linux EABI (arm-linux-eabi)
+- `riscv32` - RISC-V 32-bit (riscv32-unknown-elf)
+- `riscv64` - RISC-V 64-bit (riscv64-unknown-elf)
+- `aarch64` - ARM 64-bit (aarch64-linux-gnu)
+
+**Manual trigger**:
+```bash
+# Build all architectures
+gh workflow run build-toolchain.yml
+
+# Build specific architectures
+gh workflow run build-toolchain.yml -f architectures=arm,riscv64
+```
+
+**Build time**: Each architecture takes approximately 1-2 hours to build.
+
+### 3. Build Single Toolchain (`build-single-toolchain.yml`)
+
+**Purpose**: Quickly build a single toolchain for testing or development.
+
+**Triggers**:
+- Manual workflow dispatch only
+
+**What it does**:
+- Builds a toolchain for the selected architecture
+- Optionally uploads as artifact (30-day retention)
+- Provides build summary with toolchain version info
+
+**Manual trigger**:
+```bash
+# Via GitHub UI: Actions -> Build Single Toolchain -> Run workflow
+# Select architecture: arm, riscv32, riscv64, or aarch64
+
+# Or use GitHub CLI:
+gh workflow run build-single-toolchain.yml -f arch=arm -f upload_artifact=true
+```
+
+**Use cases**:
+- Testing toolchain builds for a specific architecture
+- Quick validation after making changes
+- Development and debugging
+
+## Release Process
+
+### Creating a New Release
+
+To create a new release with source code and toolchains:
+
+1. **Tag the release**:
+   ```bash
+   git tag -a v1.0.0 -m "Release version 1.0.0"
+   git push origin v1.0.0
+   ```
+
+2. **Automatic builds**:
+   - The `release.yml` workflow will create a source release
+   - The `build-toolchain.yml` workflow will build all toolchains (takes 2-4 hours)
+
+3. **Download artifacts**:
+   - All toolchain packages will be attached to the GitHub release
+   - Source tarball and checksums will be available
+
+### Manual Release
+
+If you prefer to create releases manually:
+
+1. **Build toolchains**:
+   ```bash
+   gh workflow run build-toolchain.yml -f version=v1.0.0
+   ```
+
+2. **Create source release**:
+   ```bash
+   gh workflow run release.yml -f version=v1.0.0
+   ```
+
+3. **Download artifacts** from the workflow runs and manually attach to release
+
+## Workflow Configuration
+
+### Environment Variables
+
+The workflows set the following environment variables during builds:
+
+- `CI_COMMIT_SHA`: Git commit hash
+- `CI_JOB_ID`: GitHub run ID
+- `CI_PIPELINE_ID`: GitHub run number
+
+These are embedded in the built toolchains for traceability.
+
+### Build Resources
+
+- **Runner**: ubuntu-latest
+- **Disk space**: Workflows automatically clean up unnecessary files to free space
+- **Timeout**: 480 minutes (8 hours) per architecture
+- **Parallel builds**: Multiple architectures build in parallel
+
+### Dependencies
+
+The workflows install the following dependencies:
+
+- build-essential
+- bison, flex
+- file, texinfo
+- wget, gawk
+- chrpath, cpio, diffstat
+- zstd
+- libncurses5, libz-dev
+- python3, python3-pip
+
+## Troubleshooting
+
+### Build Failures
+
+1. **Check logs**: View the workflow run logs in GitHub Actions
+2. **Disk space**: Builds require ~30GB free space per architecture
+3. **Timeout**: If builds timeout, they may need more resources
+
+### Testing Locally
+
+To test builds locally before running workflows:
+
+```bash
+cd toolchain
+make arch=arm abi=linux-eabi
+```
+
+See `toolchain/README.md` for detailed local build instructions.
+
+## Maintenance
+
+### Updating GCC/Binutils Versions
+
+To update toolchain component versions:
+
+1. Edit `toolchain/Makefile`:
+   - `BINUTILS_VER`
+   - `GCC_VER`
+   - `GMP_VER`, `MPC_VER`, `MPFR_VER`
+
+2. Test locally first
+3. Update patches in `toolchain/patches/` if needed
+
+### Adding New Architectures
+
+To add support for a new architecture:
+
+1. Add architecture to `toolchain/Makefile`
+2. Add architecture choice to `build-single-toolchain.yml`
+3. Add architecture to default list in `build-toolchain.yml`
+4. Update this README
+
+## Related Documentation
+
+- [Main README](../../README.md)
+- [Toolchain README](../../toolchain/README.md)
+- [Architecture Documentation](../../ARCH.md)

+ 155 - 0
.github/workflows/build-single-toolchain.yml

@@ -0,0 +1,155 @@
+name: Build Single Toolchain
+
+on:
+  workflow_dispatch:
+    inputs:
+      arch:
+        description: 'Architecture to build'
+        required: true
+        type: choice
+        options:
+          - arm
+          - riscv32
+          - riscv64
+          - aarch64
+      upload_artifact:
+        description: 'Upload as artifact (keep for 30 days)'
+        required: false
+        type: boolean
+        default: true
+
+permissions:
+  contents: read
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    timeout-minutes: 480
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Free disk space
+        run: |
+          echo "Disk space before cleanup:"
+          df -h
+          sudo rm -rf /usr/share/dotnet
+          sudo rm -rf /opt/ghc
+          sudo rm -rf /usr/local/share/boost
+          sudo rm -rf "$AGENT_TOOLSDIRECTORY"
+          echo "Disk space after cleanup:"
+          df -h
+
+      - name: Install dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y \
+            build-essential \
+            bison \
+            flex \
+            file \
+            texinfo \
+            wget \
+            chrpath \
+            cpio \
+            diffstat \
+            gawk \
+            zstd \
+            libncurses5 \
+            libz-dev \
+            python3 \
+            python3-pip
+
+      - name: Set architecture-specific variables
+        id: arch_vars
+        run: |
+          ARCH="${{ inputs.arch }}"
+
+          case "$ARCH" in
+            arm)
+              echo "target=arm-linux-eabi" >> $GITHUB_OUTPUT
+              echo "abi=linux-eabi" >> $GITHUB_OUTPUT
+              ;;
+            riscv32)
+              echo "target=riscv32-unknown-elf" >> $GITHUB_OUTPUT
+              echo "abi=unknown-elf" >> $GITHUB_OUTPUT
+              ;;
+            riscv64)
+              echo "target=riscv64-unknown-elf" >> $GITHUB_OUTPUT
+              echo "abi=unknown-elf" >> $GITHUB_OUTPUT
+              ;;
+            aarch64)
+              echo "target=aarch64-linux-gnu" >> $GITHUB_OUTPUT
+              echo "abi=linux-gnu" >> $GITHUB_OUTPUT
+              ;;
+            *)
+              echo "Unknown architecture: $ARCH"
+              exit 1
+              ;;
+          esac
+
+      - name: Build toolchain for ${{ inputs.arch }}
+        working-directory: toolchain
+        env:
+          CI_COMMIT_SHA: ${{ github.sha }}
+          CI_JOB_ID: ${{ github.run_id }}
+          CI_PIPELINE_ID: ${{ github.run_number }}
+        run: |
+          echo "Building toolchain for ${{ inputs.arch }}"
+          echo "Target: ${{ steps.arch_vars.outputs.target }}"
+
+          make arch=${{ inputs.arch }} abi=${{ steps.arch_vars.outputs.abi }} \
+            CI_COMMIT_SHA="${CI_COMMIT_SHA}" \
+            CI_JOB_ID="${CI_JOB_ID}" \
+            CI_PIPELINE_ID="${CI_PIPELINE_ID}"
+
+      - name: Create toolchain archive
+        if: ${{ inputs.upload_artifact }}
+        working-directory: toolchain
+        run: |
+          TARGET="${{ steps.arch_vars.outputs.target }}_for_x86_64-pc-linux-gnu"
+          VERSION="$(date +%Y%m%d-%H%M%S)"
+          TARBALL_NAME="${TARGET}-${VERSION}.tar.gz"
+
+          echo "Creating tarball: $TARBALL_NAME"
+          tar -czf "$TARBALL_NAME" "$TARGET"
+
+          # Calculate checksum
+          sha256sum "$TARBALL_NAME" > "$TARBALL_NAME.sha256"
+
+          echo "TARBALL_NAME=$TARBALL_NAME" >> $GITHUB_ENV
+          echo "TARGET=$TARGET" >> $GITHUB_ENV
+
+      - name: Test toolchain
+        working-directory: toolchain
+        run: |
+          TARGET="${{ steps.arch_vars.outputs.target }}_for_x86_64-pc-linux-gnu"
+          echo "Testing toolchain..."
+          ./${TARGET}/bin/${{ steps.arch_vars.outputs.target }}-gcc --version
+
+      - name: Upload toolchain artifact
+        if: ${{ inputs.upload_artifact }}
+        uses: actions/upload-artifact@v4
+        with:
+          name: toolchain-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
+          path: |
+            toolchain/${{ env.TARBALL_NAME }}
+            toolchain/${{ env.TARBALL_NAME }}.sha256
+          retention-days: 30
+
+      - name: Build summary
+        run: |
+          echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
+          echo "" >> $GITHUB_STEP_SUMMARY
+          echo "**Architecture:** ${{ inputs.arch }}" >> $GITHUB_STEP_SUMMARY
+          echo "**Target:** ${{ steps.arch_vars.outputs.target }}" >> $GITHUB_STEP_SUMMARY
+          echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
+          echo "**Build ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
+          echo "" >> $GITHUB_STEP_SUMMARY
+          echo "### Toolchain Information" >> $GITHUB_STEP_SUMMARY
+          echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
+          toolchain/${{ steps.arch_vars.outputs.target }}_for_x86_64-pc-linux-gnu/bin/${{ steps.arch_vars.outputs.target }}-gcc --version >> $GITHUB_STEP_SUMMARY
+          echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

+ 243 - 0
.github/workflows/build-toolchain.yml

@@ -0,0 +1,243 @@
+name: Build GCC Toolchains
+
+on:
+  push:
+    tags:
+      - 'v*'
+  workflow_dispatch:
+    inputs:
+      version:
+        description: 'Version tag (e.g., v1.0.0)'
+        required: false
+        type: string
+      architectures:
+        description: 'Comma-separated list of architectures to build (arm,riscv32,riscv64,aarch64) or leave empty for all'
+        required: false
+        type: string
+        default: 'arm,riscv32,riscv64,aarch64'
+
+permissions:
+  contents: write
+
+jobs:
+  prepare:
+    runs-on: ubuntu-latest
+    outputs:
+      version: ${{ steps.set_version.outputs.version }}
+      matrix: ${{ steps.set_matrix.outputs.matrix }}
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+
+      - name: Set version
+        id: set_version
+        run: |
+          if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
+            echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
+          elif [ "${{ github.event_name }}" == "push" ]; then
+            echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
+          else
+            echo "version=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
+          fi
+
+      - name: Set build matrix
+        id: set_matrix
+        run: |
+          if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ inputs.architectures }}" ]; then
+            ARCHS="${{ inputs.architectures }}"
+          else
+            ARCHS="arm,riscv32,riscv64,aarch64"
+          fi
+
+          # Convert comma-separated string to JSON array for matrix
+          MATRIX_JSON=$(echo "$ARCHS" | jq -R -s -c 'split(",") | map(select(length > 0))')
+          echo "matrix={\"arch\":$MATRIX_JSON}" >> $GITHUB_OUTPUT
+          echo "Building for architectures: $ARCHS"
+          echo "Matrix JSON: $MATRIX_JSON"
+
+  build-toolchain:
+    needs: prepare
+    runs-on: ubuntu-latest
+    timeout-minutes: 480
+    strategy:
+      fail-fast: false
+      matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Free disk space
+        run: |
+          echo "Disk space before cleanup:"
+          df -h
+          sudo rm -rf /usr/share/dotnet
+          sudo rm -rf /opt/ghc
+          sudo rm -rf /usr/local/share/boost
+          sudo rm -rf "$AGENT_TOOLSDIRECTORY"
+          echo "Disk space after cleanup:"
+          df -h
+
+      - name: Install dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y \
+            build-essential \
+            bison \
+            flex \
+            file \
+            texinfo \
+            wget \
+            chrpath \
+            cpio \
+            diffstat \
+            gawk \
+            zstd \
+            libncurses5 \
+            libz-dev \
+            python3 \
+            python3-pip
+
+      - name: Set architecture-specific variables
+        id: arch_vars
+        run: |
+          ARCH="${{ matrix.arch }}"
+
+          case "$ARCH" in
+            arm)
+              echo "target=arm-linux-eabi" >> $GITHUB_OUTPUT
+              echo "abi=linux-eabi" >> $GITHUB_OUTPUT
+              ;;
+            riscv32)
+              echo "target=riscv32-unknown-elf" >> $GITHUB_OUTPUT
+              echo "abi=unknown-elf" >> $GITHUB_OUTPUT
+              ;;
+            riscv64)
+              echo "target=riscv64-unknown-elf" >> $GITHUB_OUTPUT
+              echo "abi=unknown-elf" >> $GITHUB_OUTPUT
+              ;;
+            aarch64)
+              echo "target=aarch64-linux-gnu" >> $GITHUB_OUTPUT
+              echo "abi=linux-gnu" >> $GITHUB_OUTPUT
+              ;;
+            *)
+              echo "Unknown architecture: $ARCH"
+              exit 1
+              ;;
+          esac
+
+      - name: Build toolchain for ${{ matrix.arch }}
+        working-directory: toolchain
+        env:
+          CI_COMMIT_SHA: ${{ github.sha }}
+          CI_JOB_ID: ${{ github.run_id }}
+          CI_PIPELINE_ID: ${{ github.run_number }}
+        run: |
+          echo "Building toolchain for ${{ matrix.arch }}"
+          echo "Target: ${{ steps.arch_vars.outputs.target }}"
+
+          make arch=${{ matrix.arch }} abi=${{ steps.arch_vars.outputs.abi }} \
+            CI_COMMIT_SHA="${CI_COMMIT_SHA}" \
+            CI_JOB_ID="${CI_JOB_ID}" \
+            CI_PIPELINE_ID="${CI_PIPELINE_ID}"
+
+      - name: Create toolchain archive
+        working-directory: toolchain
+        run: |
+          TARGET="${{ steps.arch_vars.outputs.target }}_for_x86_64-pc-linux-gnu"
+          TARBALL_NAME="${TARGET}-${{ needs.prepare.outputs.version }}.tar.gz"
+
+          echo "Creating tarball: $TARBALL_NAME"
+          tar -czf "$TARBALL_NAME" "$TARGET"
+
+          # Calculate checksum
+          sha256sum "$TARBALL_NAME" > "$TARBALL_NAME.sha256"
+
+          echo "TARBALL_NAME=$TARBALL_NAME" >> $GITHUB_ENV
+          echo "TARGET=$TARGET" >> $GITHUB_ENV
+
+      - name: Test toolchain
+        working-directory: toolchain
+        run: |
+          TARGET="${{ steps.arch_vars.outputs.target }}_for_x86_64-pc-linux-gnu"
+          echo "Testing toolchain..."
+          ./${TARGET}/bin/${{ steps.arch_vars.outputs.target }}-gcc --version
+
+      - name: Upload toolchain artifact
+        uses: actions/upload-artifact@v4
+        with:
+          name: toolchain-${{ matrix.arch }}-${{ needs.prepare.outputs.version }}
+          path: |
+            toolchain/${{ env.TARGET }}-${{ needs.prepare.outputs.version }}.tar.gz
+            toolchain/${{ env.TARGET }}-${{ needs.prepare.outputs.version }}.tar.gz.sha256
+          retention-days: 30
+
+  release:
+    needs: [prepare, build-toolchain]
+    runs-on: ubuntu-latest
+    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
+    steps:
+      - name: Download all artifacts
+        uses: actions/download-artifact@v4
+        with:
+          path: artifacts
+
+      - name: Prepare release files
+        run: |
+          mkdir -p release-files
+          find artifacts -type f \( -name "*.tar.gz" -o -name "*.sha256" \) -exec cp {} release-files/ \;
+          ls -lh release-files/
+
+      - name: Create GitHub Release
+        uses: softprops/action-gh-release@v1
+        with:
+          tag_name: ${{ needs.prepare.outputs.version }}
+          name: GCC Toolchains ${{ needs.prepare.outputs.version }}
+          draft: false
+          prerelease: false
+          files: release-files/*
+          body: |
+            ## GCC Toolchains for mlibc ${{ needs.prepare.outputs.version }}
+
+            This release contains pre-built GCC toolchains with mlibc for the following architectures:
+
+            ### Supported Architectures
+            - **ARM**: `arm-linux-eabi`
+            - **RISC-V 32-bit**: `riscv32-unknown-elf`
+            - **RISC-V 64-bit**: `riscv64-unknown-elf`
+            - **AArch64**: `aarch64-linux-gnu`
+
+            ### GCC Version
+            - GCC 12.2.0
+            - Binutils 2.39
+            - mlibc version ${{ needs.prepare.outputs.version }}
+
+            ### Installation
+            1. Download the appropriate toolchain tarball for your target architecture
+            2. Extract: `tar -xzf <toolchain-tarball>.tar.gz`
+            3. Add to PATH: `export PATH=/path/to/toolchain/bin:$PATH`
+
+            ### Usage
+            ```bash
+            # For ARM
+            arm-linux-eabi-gcc --version
+
+            # For RISC-V 32-bit
+            riscv32-unknown-elf-gcc --version
+
+            # For RISC-V 64-bit
+            riscv64-unknown-elf-gcc --version
+
+            # For AArch64
+            aarch64-linux-gnu-gcc --version
+            ```
+
+            ### Checksums
+            SHA256 checksums are provided for each tarball to verify integrity.
+
+            ### Build Information
+            - Commit: ${{ github.sha }}
+            - Build: ${{ github.run_id }}
+            - Pipeline: ${{ github.run_number }}

+ 72 - 0
.github/workflows/release.yml

@@ -0,0 +1,72 @@
+name: Release mlibc Source
+
+on:
+  push:
+    tags:
+      - 'v*'
+  workflow_dispatch:
+    inputs:
+      version:
+        description: 'Version tag (e.g., v1.0.0)'
+        required: true
+        type: string
+
+permissions:
+  contents: write
+
+jobs:
+  create-source-release:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Get version
+        id: get_version
+        run: |
+          if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
+            echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
+          else
+            echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
+          fi
+
+      - name: Create source tarball
+        run: |
+          VERSION="${{ steps.get_version.outputs.version }}"
+          TARBALL_NAME="mlibc-${VERSION}-source.tar.gz"
+
+          # Create a clean export of the repository
+          git archive --format=tar.gz --prefix=mlibc-${VERSION}/ HEAD > ${TARBALL_NAME}
+
+          # Calculate checksum
+          sha256sum ${TARBALL_NAME} > ${TARBALL_NAME}.sha256
+
+          echo "TARBALL_NAME=${TARBALL_NAME}" >> $GITHUB_ENV
+
+      - name: Create Release
+        uses: softprops/action-gh-release@v1
+        with:
+          tag_name: ${{ steps.get_version.outputs.version }}
+          name: mlibc ${{ steps.get_version.outputs.version }}
+          draft: false
+          prerelease: false
+          files: |
+            mlibc-*.tar.gz
+            mlibc-*.tar.gz.sha256
+          body: |
+            ## mlibc ${{ steps.get_version.outputs.version }} Release
+
+            ### Source Code
+            This release includes the source code for mlibc version ${{ steps.get_version.outputs.version }}.
+
+            ### Downloads
+            - **Source tarball**: `mlibc-${{ steps.get_version.outputs.version }}-source.tar.gz`
+            - **SHA256 checksum**: `mlibc-${{ steps.get_version.outputs.version }}-source.tar.gz.sha256`
+
+            ### Toolchains
+            Pre-built GCC toolchains for various architectures can be downloaded from the [toolchain releases](https://github.com/${{ github.repository }}/releases).
+
+            ### Building
+            Please refer to the [README](https://github.com/${{ github.repository }}/blob/${{ steps.get_version.outputs.version }}/README.md) for build instructions.

+ 43 - 0
README.md

@@ -245,6 +245,49 @@ Information for each virtual environment is as follows:
 | qemu-virt-riscv32 | virt-riscv32   | make qemu-hello QEMU_BOARD=qemu-virt-riscv32 ARCH=riscv32 |
 | qemu-virt-riscv64 | virt-riscv64   | make qemu-hello QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 |
 
+## Pre-built GCC Toolchains
+
+For convenience, we provide pre-built GCC toolchains with mlibc for multiple architectures. These toolchains are automatically built and released using GitHub Actions.
+
+### Downloading Pre-built Toolchains
+
+Visit the [Releases page](https://github.com/plctlab/mlibc/releases) to download pre-built toolchains:
+
+- **ARM**: `arm-linux-eabi_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **RISC-V 32-bit**: `riscv32-unknown-elf_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **RISC-V 64-bit**: `riscv64-unknown-elf_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **AArch64**: `aarch64-linux-gnu_for_x86_64-pc-linux-gnu-*.tar.gz`
+
+### Installation
+
+```bash
+# Download and extract
+tar -xzf <toolchain-tarball>.tar.gz
+
+# Add to PATH
+export PATH=/path/to/toolchain/bin:$PATH
+
+# Verify installation
+arm-linux-eabi-gcc --version
+```
+
+### Building Toolchains Yourself
+
+If you prefer to build the toolchains yourself:
+
+#### Using Docker (Recommended)
+
+See [toolchain/README.md](toolchain/README.md) for detailed instructions on building with Docker.
+
+#### Using GitHub Actions
+
+The repository includes GitHub Actions workflows for automated builds:
+
+- **Build all architectures**: Triggered automatically on version tags or manually via workflow dispatch
+- **Build single architecture**: Use the "Build Single Toolchain" workflow for testing
+
+For more information, see [.github/workflows/README.md](.github/workflows/README.md).
+
 # License Agreement
 
 mlibc is fully open-source, following the MIT license. It allows for commercial use and modifications without any concerns, provided that the MIT license is declared in the software, with no potential commercial risks.

+ 43 - 0
README_zh.md

@@ -246,6 +246,49 @@ qemu.bat
 | qemu-virt-riscv32 | virt-riscv32   | make qemu-hello QEMU_BOARD=qemu-virt-riscv32 ARCH=riscv32 |
 | qemu-virt-riscv64 | virt-riscv64   | make qemu-hello QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 |
 
+## 预编译的 GCC 工具链
+
+为了方便使用,我们提供了带有 mlibc 的多架构预编译 GCC 工具链。这些工具链通过 GitHub Actions 自动构建和发布。
+
+### 下载预编译工具链
+
+访问 [Releases 页面](https://github.com/plctlab/mlibc/releases) 下载预编译工具链:
+
+- **ARM**: `arm-linux-eabi_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **RISC-V 32位**: `riscv32-unknown-elf_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **RISC-V 64位**: `riscv64-unknown-elf_for_x86_64-pc-linux-gnu-*.tar.gz`
+- **AArch64**: `aarch64-linux-gnu_for_x86_64-pc-linux-gnu-*.tar.gz`
+
+### 安装
+
+```bash
+# 下载并解压
+tar -xzf <toolchain-tarball>.tar.gz
+
+# 添加到 PATH
+export PATH=/path/to/toolchain/bin:$PATH
+
+# 验证安装
+arm-linux-eabi-gcc --version
+```
+
+### 自行构建工具链
+
+如果您希望自行构建工具链:
+
+#### 使用 Docker(推荐)
+
+详细说明请参见 [toolchain/README.md](toolchain/README.md)。
+
+#### 使用 GitHub Actions
+
+仓库中包含用于自动构建的 GitHub Actions 工作流:
+
+- **构建所有架构**:在版本标签上自动触发或通过工作流手动触发
+- **构建单个架构**:使用 "Build Single Toolchain" 工作流进行测试
+
+更多信息,请参见 [.github/workflows/README.md](.github/workflows/README.md)。
+
 # 贡献代码
 
 + How to