Skip to content

Commit

Permalink
Added LLVM Installation with Rust LLVM Version
Browse files Browse the repository at this point in the history
Moved Environment Variable Initialisation to Setup
  • Loading branch information
Redfire75369 committed Oct 16, 2024
1 parent 01211eb commit a7deec2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 28 deletions.
56 changes: 44 additions & 12 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -52,7 +84,7 @@ runs:
uses: taiki-e/install-action@nextest

- name: Setup sccache
uses: mozilla-actions/[email protected].5
uses: mozilla-actions/[email protected].6

- name: Cache Cargo Cache and Git Database
uses: actions/cache@v4
Expand Down
Empty file modified .github/scripts/macos-linker.sh
100644 → 100755
Empty file.
12 changes: 1 addition & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a7deec2

Please sign in to comment.