Build llvm toolchain #228
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build llvm toolchain | |
on: | |
workflow_dispatch: | |
# push: | |
# branches: | |
# - main | |
jobs: | |
build: | |
name: Build | |
# if: "contains(github.event.head_commit.message, '[mainBuild]')" | |
continue-on-error: false | |
strategy: | |
matrix: | |
target: | |
- id: 'linux-amd64' | |
os: 'ubuntu-24.04' | |
tar_extra_args: '' | |
llvm_version: '18.x' | |
# - id: 'linux-aarch64' | |
# os: "ubuntu-latest" | |
# os: ['self-hosted', 'linux', 'ARM64'] | |
# - id: 'linux-riscv64' | |
# os: "ubuntu-latest" | |
# os: ['self-hosted', 'linux', 'RISCV64'] | |
## https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ | |
- id: 'darwin-amd64' | |
os: 'macos-14' | |
tar_extra_args: '' | |
llvm_version: '18.x' | |
- id: 'windows-amd64' | |
os: 'windows-2022' | |
llvm_version: '16.x' | |
# When unpacking an archive on Windows, the symlinks can't be | |
# created unless the target path already exists. This causes | |
# problems when the linked file is ordered after the link | |
# inside the archive. Dereferencing the files when packing them | |
# adds an additional copy per link, but it reliably works and | |
# the additional size is not too large on Windows. | |
tar_extra_args: '--dereference' | |
# llvm_version: ['17.x'] | |
llvm_repo_url: ['https://github.com/llvm/llvm-project.git'] | |
fail-fast: true | |
runs-on: ${{ matrix.target.os }} | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Install `ninja` on Ubuntu | |
if: startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
sudo apt install ninja-build build-essential clang coreutils tree -y | |
echo "cpu core num is " | |
nproc | |
- name: Install `ninja llvm cmake ` on macOS | |
if: startsWith(matrix.target.id, 'darwin-') | |
shell: bash | |
run: | | |
brew install ninja llvm cmake tree | |
clang --version | |
echo "BREW_INSTALL_PREFIX=$(brew --prefix llvm)" >> $GITHUB_ENV | |
echo "${BREW_INSTALL_PREFIX}/bin" | |
echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH | |
clang --version | |
echo "llvm" | |
/opt/homebrew/opt/llvm/bin/clang --version | |
- name: Build | |
# if: matrix.target.id != 'windows-amd64' && matrix.target.id != 'linux-aarch64' && matrix.target.id != 'linux-riscv64' | |
if: matrix.target.id == 'linux-amd64' | |
shell: bash | |
run: | | |
./scripts/build_llvm.sh ${{ matrix.target.llvm_version }} ${{ matrix.llvm_repo_url }} | |
- name: Build (darwin-amd64) | |
if: startsWith(matrix.target.id, 'darwin-') | |
shell: bash | |
run: | | |
./scripts/build_llvm_mac.sh ${{ matrix.target.llvm_version }} ${{ matrix.llvm_repo_url }} | |
- name: Build (Windows) | |
if: matrix.target.id == 'windows-amd64' | |
shell: | | |
powershell -Command "& '{0}'" | |
run: | | |
./scripts/build_llvm.ps1 ${{ matrix.target.llvm_version }} ${{ matrix.llvm_repo_url }} | |
- name: Inspect | |
shell: bash | |
run: | | |
PATH=llvm-project/build/destdir/bin:llvm-project/build/destdir/usr/bin:$PATH llvm-config --version | |
PATH=llvm-project/build/destdir/bin:llvm-project/build/destdir/usr/bin:$PATH clang --version | |
PATH=llvm-project/build/destdir/bin:llvm-project/build/destdir/usr/bin:$PATH clang++ --version | |
- name: Zip | |
shell: bash | |
run: | | |
mkdir -p dist | |
tar --directory llvm-project/build/destdir --create --xz --verbose ${{ matrix.target.tar_extra_args }} --file dist/llvm.tar.xz . | |
ls -lh dist/llvm.tar.xz | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target.id }}-${{ matrix.target.os }}-${{ matrix.target.llvm_version }} | |
path: dist | |
if-no-files-found: error | |
retention-days: 7 | |
- name: Check out fmt code base | |
if: startsWith(matrix.target.id, 'darwin-') || startsWith(matrix.target.id, 'linux-') | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
repository: fmtlib/fmt | |
ref: 9.1.0 | |
path: fmt | |
fetch-tags: true | |
- name: test deps | |
if: startsWith(matrix.target.id, 'darwin-') || startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
uname -a | |
clang --version | |
clang++ --version | |
- name: show root layouts | |
if: startsWith(matrix.target.id, 'darwin-') || startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
tree -L 5 | |
- name: prepre layout of new toolchain | |
if: startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
mv dist/llvm.tar.xz llvm.tar.xz | |
tar -xf llvm.tar.xz | |
tree -L 3 | |
- name: build fmt using custom llvm toolchain | |
if: startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
bash scripts/build_fmt.sh | |
tree -L 3 | |
buildFmt: | |
name: Build fmt | |
if: "contains(github.event.head_commit.message, '[mainfmt]')" | |
continue-on-error: false | |
strategy: | |
matrix: | |
target: | |
- id: 'linux-amd64' | |
os: 'ubuntu-24.04' | |
tar_extra_args: '' | |
llvm_version: '18.x' | |
# - id: 'linux-aarch64' | |
# os: "ubuntu-latest" | |
# os: ['self-hosted', 'linux', 'ARM64'] | |
# - id: 'linux-riscv64' | |
# os: "ubuntu-latest" | |
# os: ['self-hosted', 'linux', 'RISCV64'] | |
## https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ | |
- id: 'darwin-amd64' | |
os: 'macos-14' | |
tar_extra_args: '' | |
llvm_version: '18.x' | |
# - id: 'windows-amd64' | |
# os: 'windows-2022' | |
# llvm_version: '16.x' | |
# When unpacking an archive on Windows, the symlinks can't be | |
# created unless the target path already exists. This causes | |
# problems when the linked file is ordered after the link | |
# inside the archive. Dereferencing the files when packing them | |
# adds an additional copy per link, but it reliably works and | |
# the additional size is not too large on Windows. | |
# tar_extra_args: '--dereference' | |
# llvm_version: ['17.x'] | |
llvm_repo_url: ['https://github.com/llvm/llvm-project.git'] | |
fail-fast: true | |
runs-on: ${{ matrix.target.os }} | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
# - name: Check out fmt code base | |
# uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 2 | |
# repository: fmtlib/fmt | |
# ref: 9.1.0 | |
# path: fmt | |
# fetch-tags: true | |
- name: Install `deps` on Ubuntu | |
if: startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
sudo apt install ninja-build build-essential clang coreutils libidn2-0-dev libunistring-dev -y | |
echo "cpu core num is " | |
nproc | |
- name: Install `ninja llvm cmake ` on macOS | |
if: startsWith(matrix.target.id, 'darwin-') | |
shell: bash | |
run: | | |
brew install ninja llvm cmake tree libunistring libidn2 | |
clang --version | |
echo "BREW_INSTALL_PREFIX=$(brew --prefix llvm)" >> $GITHUB_ENV | |
echo "${BREW_INSTALL_PREFIX}/bin" | |
echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH | |
clang --version | |
echo "llvm" | |
/opt/homebrew/opt/llvm/bin/clang --version | |
- name: test deps | |
if: startsWith(matrix.target.id, 'darwin-') || startsWith(matrix.target.id, 'linux-') | |
shell: bash | |
run: | | |
uname -a | |
clang --version | |
clang++ --version | |
- name: build fmt | |
shell: bash | |
run: | | |
bash scripts/build_fmt.sh | |
tree -L 4 | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target.id }}-${{ matrix.target.os }}-prebuilt | |
path: dist | |
if-no-files-found: error | |
retention-days: 7 |