Skip to content

Commit 9838eeb

Browse files
committed
update llvm release URLs
1 parent 04aded1 commit 9838eeb

File tree

3 files changed

+130
-27
lines changed

3 files changed

+130
-27
lines changed

.github/actions/install-llvm-binaries/action.yml

Lines changed: 120 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,153 @@
1010
# outputs includes: llvm_dir, which is the directory where the libraries are installed
1111

1212
name: "Install LLVM Binaries"
13-
description: "Installs pre-compiled LLVM libraries for a specific OS and architecture."
13+
description: "Installs pre-compiled LLVM libraries."
1414
author: "Intel Corporation"
1515

1616
inputs:
1717
os:
18-
description: "Operating system to install on (e.g., ubuntu-22.04, macos-14)"
18+
description: "Operating system to install LLVM on (e.g., ubuntu-22.04, windows-latest)"
1919
required: true
20-
#TODO: options
21-
arch:
22-
description: "Architecture to install for (e.g., x86_64, aarch64)"
20+
triple:
21+
description: "LLVM triple to install (e.g., x86_64-linux-gnu-ubuntu-18.04, x86_64-pc-windows-msvc, arm64-apple-macos11)"
2322
required: true
24-
#TODO: options
23+
default: ""
2524
container_image:
2625
description: "Container image to use (optional)"
2726
required: false
2827
default: ""
2928
ver:
3029
description: "LLVM version to install (e.g., 18.1.2) (optional)"
3130
required: false
32-
default: "18.1.2"
31+
default: "18.1.8"
3332
#TODO: options
3433
outputs:
35-
llvm_dir:
34+
llvm_dir_on_windows:
35+
description: "The directory where LLVM libraries are installed"
36+
value: ${{ steps.set_llvm_dir_windows.outputs.llvm_dir }}
37+
llvm_dir_on_ubuntu:
3638
description: "The directory where LLVM libraries are installed"
37-
value: ${{ steps.set_llvm_dir.outputs.llvm_dir }}
39+
value: ${{ steps.set_llvm_dir_ubuntu.outputs.llvm_dir }}
3840

3941
runs:
4042
using: "composite"
4143
steps:
42-
- name: Check Runner OS
44+
#TODO: tell the user there is no pre-compiled LLVM binaries for macos with x86_64 architecture
45+
46+
- name: LOG Runner OS
4347
shell: bash
4448
run: |
45-
if [[ "${{ inputs.os }}" != "ubuntu-22.04" && "${{ inputs.os }}" != "macos-14" ]]; then
46-
echo "::error title=⛔ error hint::Only support ubuntu-22.04 and macos-14 for now"
47-
exit 1
48-
fi
49+
echo "::debug::installing LLVM binaries on ${{ inputs.os }}"
50+
51+
- name: Install dependencies(Windows)
52+
if: ${{ startsWith(inputs.os, 'windows') }}
53+
shell: powershell
54+
run: |
55+
vcpkg install libxml2:x64-windows
56+
vcpkg install libxslt:x64-windows
57+
vcpkg integrate install
4958
50-
- name: Create installation directory
59+
- name: Create installation directory(Ubuntu)
60+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5161
shell: bash
52-
run: sudo mkdir -p /opt/llvm-${{ inputs.ver }}
62+
run: mkdir -p /opt/llvm-${{ inputs.ver }}
63+
64+
- name: Create installation directory(Windows)
65+
if: ${{ startsWith(inputs.os, 'windows') }}
66+
shell: powershell
67+
run: New-Item -ItemType Directory -Path .\core\deps\llvm\build -Force
5368

54-
- name: Download and install LLVM binaries
69+
- name: Download and install LLVM binaries(Ubuntu)
70+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5571
shell: bash
5672
run: |
57-
sudo wget -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.arch }}-${{ inputs.os }}.tar.xz
58-
sudo tar xf llvm.tar.xz --strip-components=1 -C /opt/llvm-${{ inputs.ver }}
59-
working-directory: /opt/llvm-${{ inputs.ver }}
73+
wget -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz
74+
tar xf llvm.tar.xz --strip-components=1 -C llvm-${{ inputs.ver }}
75+
working-directory: /opt
76+
77+
- name: Download and install LLVM binaries(Windows)
78+
if: ${{ startsWith(inputs.os, 'windows') }}
79+
shell: powershell
80+
run: |
81+
try {
82+
$ErrorActionPreference = "Stop"
83+
# Significantly reduce the time consumption of downloading.
84+
$ProgressPreference = 'SilentlyContinue'
85+
$url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz"
86+
Write-Host "Downloading LLVM from: $url"
87+
Invoke-WebRequest -Uri $url -OutFile llvm.tar.xz
88+
89+
if (-not (Test-Path llvm.tar.xz)) {
90+
throw "Download failed: llvm.tar.xz not found"
91+
}
92+
93+
Write-Host "Extracting LLVM package..."
94+
# Use 7z for better performance on Windows
95+
if (-not (Test-Path "C:\Program Files\7-Zip\7z.exe")) {
96+
throw "7-Zip is not installed. Please install 7-Zip to extract the LLVM package."
97+
}
98+
99+
# First extract the .tar file from .tar.xz
100+
Write-Host "Extracting .tar from .tar.xz..."
101+
& "C:\Program Files\7-Zip\7z.exe" e llvm.tar.xz
60102
61-
- name: Set output LLVM_DIR
62-
id: set_llvm_dir
103+
if ($LASTEXITCODE -ne 0) {
104+
throw "Extraction of .tar.xz failed with exit code: $LASTEXITCODE"
105+
}
106+
107+
# Then extract the contents from .tar
108+
Write-Host "Extracting contents from .tar..."
109+
& "C:\Program Files\7-Zip\7z.exe" x "llvm.tar"
110+
111+
if ($LASTEXITCODE -ne 0) {
112+
throw "Extraction of .tar failed with exit code: $LASTEXITCODE"
113+
}
114+
115+
# Verify the contents
116+
dir "."
117+
118+
$extractedDir = Join-Path -Path "." -ChildPath "clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}"
119+
if (-not (Test-Path $extractedDir)) {
120+
throw "Extraction failed: $extractedDir not found"
121+
}
122+
123+
# Verify the contents
124+
dir "$extractedDir"
125+
126+
Write-Host "Moving contents from $extractedDir to llvm\build..."
127+
128+
# Move all contents from the extracted directory to the target directory
129+
Get-ChildItem -Path "$extractedDir" | Move-Item -Destination ".\llvm\build"
130+
131+
# Verify the contents
132+
dir ".\llvm\build"
133+
134+
# Search LLVMConfig.cmake and llvm-config.cmake, ignore case
135+
$llvmConfigFiles = Get-ChildItem -Path ".\llvm\build" -Recurse -Include "LLVMConfig.cmake", "llvm-config.cmake" -ErrorAction SilentlyContinue
136+
Write-Host "Found LLVMConfig.cmake and llvm-config.cmake files: $($llvmConfigFiles)"
137+
if ($llvmConfigFiles.Count -eq 0) {
138+
throw "No LLVMConfig.cmake or llvm-config.cmake files found in the extracted directory."
139+
}
140+
141+
Write-Host "LLVM installation completed successfully"
142+
}
143+
catch {
144+
Write-Error "Failed to install LLVM: $_"
145+
exit 1
146+
}
147+
working-directory: .\core\deps
148+
149+
150+
- name: Set output LLVM_DIR(Ubuntu)
151+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
152+
id: set_llvm_dir_ubuntu
63153
shell: bash
64154
run: echo "llvm_dir=/opt/llvm-${{ inputs.ver }}" >> $GITHUB_OUTPUT
155+
156+
- name: Set output LLVM_DIR(Windows)
157+
if: ${{ startsWith(inputs.os, 'windows') }}
158+
id: set_llvm_dir_windows
159+
shell: powershell
160+
run: |
161+
$absolutePath = (Resolve-Path ".\core\deps\llvm\build").Path
162+
Write-Output "llvm_dir=$absolutePath" >> $env:GITHUB_OUTPUT

.github/workflows/compilation_on_windows.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ jobs:
100100
id: install_llvm_libraries
101101
uses: ./.github/actions/install-llvm-binaries
102102
with:
103-
os: ${{ matrix.os }}
104-
arch: ${{ matrix.arch }}
103+
os: windows-latest
104+
triple: x86_64-pc-windows-msvc
105105

106106
- name: build wamrc from source code
107+
shell: bash
107108
run: |
108109
cmake -S . -B build \
109-
-DWAMR_BUILD_WITH_CUSTOM_LLVM=1 \
110-
-DLLVM_DIR=${{ steps.install_llvm_libraries.outputs.llvm_dir }}/lib/cmake/llvm \
111-
-DCMAKE_BUILD_TYPE=Release
110+
-DCMAKE_BUILD_TYPE=Release \
111+
-G "Visual Studio 17 2022" \
112+
-DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_INSTALLATION_ROOT}}/scripts/buildsystems/vcpkg.cmake
112113
cmake --build build --config Release --parallel 4
113114
working-directory: wamr-compiler
114115

wamr-compiler/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ cmake_minimum_required (VERSION 3.14)
55

66
include(CheckPIESupported)
77

8+
include(CMakePrintHelpers)
9+
810
if (NOT DEFINED WAMR_BUILD_PLATFORM)
911
if (CMAKE_SYSTEM_NAME)
1012
string(TOLOWER ${CMAKE_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
@@ -165,6 +167,8 @@ if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
165167
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
166168
endif ()
167169

170+
cmake_print_variables(WAMR_BUILD_WITH_CUSTOM_LLVM LLVM_DIR)
171+
168172
find_package(LLVM REQUIRED CONFIG)
169173
include_directories(${LLVM_INCLUDE_DIRS})
170174
add_definitions(${LLVM_DEFINITIONS})

0 commit comments

Comments
 (0)