From a7deec20918f42e41af554a6c072f6e6c56f700c Mon Sep 17 00:00:00 2001 From: Redfire Date: Tue, 15 Oct 2024 23:27:26 +0800 Subject: [PATCH] Added LLVM Installation with Rust LLVM Version Moved Environment Variable Initialisation to Setup --- .github/actions/setup/action.yml | 56 +++++++++++++++++++++++++------- .github/scripts/macos-linker.sh | 0 .github/workflows/release.yml | 12 +------ .github/workflows/rust.yml | 6 +--- 4 files changed, 46 insertions(+), 28 deletions(-) mode change 100644 => 100755 .github/scripts/macos-linker.sh diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a8616fa4..099134f4 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -13,6 +13,12 @@ inputs: runs: using: composite steps: + - name: Get LLVM Version from Rust + shell: bash + run: | + rustc --version --verbose | sed -n 's/LLVM version: \([0-9]\{1,\}\).*/LLVM_MAJOR_VERSION=\1/p' >> $GITHUB_ENV + rustc --version --verbose | sed -n 's/LLVM version: \([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)/LLVM_VERSION=\1/p' >> $GITHUB_ENV + - name: Install Dependencies on Windows if: inputs.os == 'windows' env: @@ -21,29 +27,55 @@ runs: MOZTOOLS_PATH: ${{ github.workspace }}\\target\\dependencies\\moztools-4.0 shell: pwsh run: | - curl -SL "$env:MOZTOOLS_LINK/moztools-$env:MOZTOOLS_VERSION.zip" --create-dirs -o target/dependencies/moztools.zip + curl -fsSL "$env:MOZTOOLS_LINK/moztools-$env:MOZTOOLS_VERSION.zip" --create-dirs -o target/dependencies/moztools.zip cd target/dependencies && unzip -qo moztools.zip -d . - echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Tools\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "MOZTOOLS_PATH=$env:MOZTOOLS_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "CC=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "CXX=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "AR=llvm-lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "LINKER=lld-link" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "MOZTOOLS_PATH=$env:MOZTOOLS_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression + scoop install "llvm@$env:LLVM_VERSION" --global + $( + Write-Output "$env:PROGRAMDATA\scoop\shims" + Get-Content "$env:GITHUB_PATH" + ) | Set-Content -Path "$env:GITHUB_PATH" -Encoding utf8 + + Write-Output "CC=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "CXX=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "AR=llvm-lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "LINKER=lld-link" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + Write-Output "CCACHE=sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install Dependencies on MacOS if: inputs.os == 'macos' shell: bash run: | brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done - brew install lld llvm yasm - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_PATH + brew install llvm@$LLVM_MAJOR_VERSION yasm + { echo "$(brew --prefix llvm@$LLVM_MAJOR_VERSION)/bin"; cat "$GITHUB_PATH"; } > "$GITHUB_PATH.new" + mv "$GITHUB_PATH.new" "$GITHUB_PATH" + + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "AR=llvm-ar" >> $GITHUB_ENV + + echo "CCACHE=sccache" >> $GITHUB_ENV + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - name: Install Dependencies on Linux if: inputs.os == 'linux' shell: bash run: | - sudo apt install -y clang llvm - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_PATH + curl -fsSL https://apt.llvm.org/llvm.sh -o llvm.sh && chmod +x llvm.sh + sudo env DPKG_FORCE=overwrite ./llvm.sh "$LLVM_MAJOR_VERSION" all + { echo "/usr/lib/llvm-$LLVM_MAJOR_VERSION/bin"; cat "$GITHUB_PATH"; } > "$GITHUB_PATH.new" + mv "$GITHUB_PATH.new" "$GITHUB_PATH" + + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "AR=llvm-ar" >> $GITHUB_ENV + + echo "CCACHE=sccache" >> $GITHUB_ENV + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - name: Install Just uses: taiki-e/install-action@just @@ -52,7 +84,7 @@ runs: uses: taiki-e/install-action@nextest - name: Setup sccache - uses: mozilla-actions/sccache-action@v0.0.5 + uses: mozilla-actions/sccache-action@v0.0.6 - name: Cache Cargo Cache and Git Database uses: actions/cache@v4 diff --git a/.github/scripts/macos-linker.sh b/.github/scripts/macos-linker.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1f21570..cbb802fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,12 @@ name: Rust Release Build -on: workflow_dispatch +on: [push, workflow_dispatch] env: SHELL: /bin/bash CARGO_TERM_COLOR: never SCCACHE_GHA_ENABLED: "true" - CC: clang - CXX: clang++ - CCACHE: sccache - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -43,12 +39,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install LLVM - if: matrix.os == 'macos' || matrix.os == 'linux' - uses: ZhongRuoyu/setup-llvm@v0 - with: - llvm-version: 18 - - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@master with: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a81e46ef..b1b3085d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,16 +1,12 @@ name: Rust -on: [push, pull_request, workflow_dispatch] +on: [pull_request, workflow_dispatch] env: SHELL: /bin/bash CARGO_TERM_COLOR: never SCCACHE_GHA_ENABLED: "true" - CC: clang - CXX: clang++ - CCACHE: sccache - concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true