Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c995ec
Initial plan
Copilot Nov 1, 2025
b2da816
Add GitHub Actions CI workflows for mlibc compilation and QEMU testing
Copilot Nov 1, 2025
31a093b
Include qemu-hello.mk in Makefile to enable qemu-hello target
Copilot Nov 1, 2025
d3cabfd
Fix typo: Successed -> Succeeded in qemu-hello workflow
Copilot Nov 1, 2025
5fe2da0
Fix QEMU workflow kernel path to use build output directory
Copilot Nov 2, 2025
95a04d6
Increase POOL_SIZE to 4096 bytes to fix heap initialization on 64-bit…
Copilot Nov 6, 2025
57dffec
Add -bios none parameter for RISC-V QEMU to enable bare-metal execution
Copilot Nov 6, 2025
6169a07
Fix RISC-V QEMU execution by using device loader instead of kernel pa…
Copilot Nov 7, 2025
1a046cf
Initial plan
Copilot Nov 6, 2025
22e8940
Update README files and Makefile to address issues #1-5
Copilot Nov 6, 2025
e655646
Initial plan
Copilot Nov 6, 2025
882e544
Add GitHub Actions workflows for toolchain builds and releases
Copilot Nov 6, 2025
05cccef
Update documentation to reference GitHub Actions workflows
Copilot Nov 6, 2025
95fb598
Fix artifact name to use GitHub Actions expressions instead of shell …
Copilot Nov 6, 2025
86e9aa8
Add explicit permissions block to build-single-toolchain workflow for…
Copilot Nov 6, 2025
2de905a
Initial plan
Copilot Nov 6, 2025
d705654
Fix compilation issues when integrating mlibc with RT-Thread
Copilot Nov 6, 2025
e80ca90
Add header guards for consistency in signal.h
Copilot Nov 6, 2025
381b436
Complete fix for mlibc RT-Thread integration issues
Copilot Nov 6, 2025
9541f16
Initial plan
Copilot Nov 1, 2025
4039af1
Rebase on main and remove -bios none from RISC-V QEMU commands
Copilot Nov 12, 2025
16d57e3
Fix ELF overlapping segments by placing .data section in RAM
Copilot Nov 12, 2025
1a2f97a
remove _codeql_detected_source_root and ignore it in .gitignore file
BernardXiong Nov 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 155 additions & 0 deletions .github/workflows/build-single-toolchain.yml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading