Skip to content

Commit 1af4740

Browse files
Add Windows wamrc and iwasm build in release CI (#3857)
- For Windows, llvm libs need to cache more directories, so use a multi-line environment variable for paths - Remove conditionally build directories `win32build`, just use `build` for all platform - Add Windows wamrc and iwasm(disable lib pthread semaphore and fast jit for now) build in release CI
1 parent 327374c commit 1af4740

File tree

9 files changed

+117
-26
lines changed

9 files changed

+117
-26
lines changed

.github/workflows/build_iwasm_release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
fail-on-cache-miss: true
5252

5353
- name: generate iwasm binary release
54+
shell: bash
5455
run: |
5556
cmake -S . -B build \
5657
-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
@@ -81,7 +82,16 @@ jobs:
8182
cmake --build build --config Release --parallel 4
8283
working-directory: ${{ inputs.cwd }}
8384

84-
- name: compress the binary
85+
- name: Compress the binary on Windows
86+
if: inputs.runner == 'windows-latest'
87+
run: |
88+
tar -czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
89+
Compress-Archive -Path iwasm.exe -DestinationPath iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
90+
mv iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
91+
working-directory: ${{ inputs.cwd }}/build/Release
92+
93+
- name: compress the binary on non-Windows
94+
if: inputs.runner != 'windows-latest'
8595
run: |
8696
tar czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
8797
zip iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm

.github/workflows/build_llvm_libraries.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343

4444
- name: install dependencies for non macos-14
4545
if: inputs.os != 'macos-14'
46+
shell: bash
4647
run: /usr/bin/env python3 -m pip install -r requirements.txt
4748
working-directory: build-scripts
4849

@@ -51,18 +52,23 @@ jobs:
5152
run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
5253
working-directory: build-scripts
5354

54-
- name: retrieve the last commit ID
55+
- name: Retrieve the last commit ID
5556
id: get_last_commit
56-
run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
57-
working-directory: build-scripts
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
shell: bash
60+
run: |
61+
echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
5862
5963
# Bump the prefix number to evict all previous caches and
6064
# enforce a clean build, in the unlikely case that some
6165
# weird build error occur and llvm/build becomes a potential
6266
# suspect.
6367
- name: form the cache key of libraries
6468
id: create_lib_cache_key
65-
run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}" >> $GITHUB_OUTPUT
69+
shell: bash
70+
run: |
71+
echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}" >> $GITHUB_OUTPUT
6672
6773
- name: Cache LLVM libraries
6874
id: retrieve_llvm_libs
@@ -107,7 +113,20 @@ jobs:
107113
- run: brew install ccache ninja
108114
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
109115

116+
- uses: actions/cache@v4
117+
with:
118+
path: ~/.cache/ccache
119+
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
120+
restore-keys: |
121+
0-ccache-${{ inputs.os }}
122+
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
123+
124+
# Install tools on Windows
125+
- run: choco install -y ccache ninja
126+
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
127+
110128
- name: Build LLVM libraries
111129
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
130+
shell: bash
112131
run: /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --arch ${{ inputs.arch }}
113132
working-directory: build-scripts

.github/workflows/build_wamrc.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ jobs:
5656
cmake --build build --config Release --parallel 4
5757
working-directory: wamr-compiler
5858

59-
- name: compress the binary
60-
if: inputs.release
59+
- name: Compress the binary on Windows
60+
if: inputs.runner == 'windows-latest' && inputs.release
61+
run: |
62+
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
63+
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
64+
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
65+
working-directory: wamr-compiler/build/Release
66+
67+
- name: compress the binary on non-Windows
68+
if: inputs.runner != 'windows-latest' && inputs.release
6169
run: |
6270
tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
6371
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc

.github/workflows/release_process.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ jobs:
7272
os: "macos-13"
7373
arch: "AArch64 ARM Mips RISCV X86"
7474

75+
build_llvm_libraries_on_windows:
76+
needs: [create_tag, create_release]
77+
uses: ./.github/workflows/build_llvm_libraries.yml
78+
with:
79+
os: "windows-latest"
80+
arch: "AArch64 ARM Mips RISCV X86"
81+
7582
#
7683
# WAMRC
7784
release_wamrc_on_ubuntu_2004:
@@ -103,6 +110,16 @@ jobs:
103110
runner: macos-13
104111
upload_url: ${{ needs.create_release.outputs.upload_url }}
105112
ver_num: ${{ needs.create_tag.outputs.new_ver }}
113+
114+
release_wamrc_on_windows:
115+
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
116+
uses: ./.github/workflows/build_wamrc.yml
117+
with:
118+
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
119+
release: true
120+
runner: windows-latest
121+
upload_url: ${{ needs.create_release.outputs.upload_url }}
122+
ver_num: ${{ needs.create_tag.outputs.new_ver }}
106123

107124
#
108125
# IWASM
@@ -136,6 +153,16 @@ jobs:
136153
upload_url: ${{ needs.create_release.outputs.upload_url }}
137154
ver_num: ${{ needs.create_tag.outputs.new_ver}}
138155

156+
release_iwasm_on_windows:
157+
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
158+
uses: ./.github/workflows/build_iwasm_release.yml
159+
with:
160+
cwd: product-mini/platforms/windows
161+
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
162+
runner: windows-latest
163+
upload_url: ${{ needs.create_release.outputs.upload_url }}
164+
ver_num: ${{ needs.create_tag.outputs.new_ver}}
165+
139166
#
140167
# WAMR_SDK
141168
release_wamr_sdk_on_ubuntu_2004:

build-scripts/build_llvm.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
125125
if not llvm_dir.exists():
126126
raise Exception(f"{llvm_dir} doesn't exist")
127127

128-
build_dir = llvm_dir.joinpath(
129-
"win32build" if "windows" == platform else "build"
130-
).resolve()
128+
build_dir = llvm_dir.joinpath("build").resolve()
131129
build_dir.mkdir(exist_ok=True)
132130

133131
lib_llvm_core_library = build_dir.joinpath("lib/libLLVMCore.a").resolve()
@@ -178,6 +176,7 @@ def repackage_llvm(llvm_dir):
178176
raise Exception("Find more than one LLVM-*.tar.gz")
179177

180178
if not packs:
179+
raise Exception("Didn't find any LLVM-* package")
181180
return
182181

183182
llvm_package = packs[0].name
@@ -193,6 +192,31 @@ def repackage_llvm(llvm_dir):
193192
# rm ./LLVM-1*.gz
194193
os.remove(llvm_dir.joinpath(llvm_package).resolve())
195194

195+
def repackage_llvm_windows(llvm_dir):
196+
build_dir = llvm_dir.joinpath("./build").resolve()
197+
198+
packs_path = [f for f in build_dir.glob("./_CPack_Packages/win64/NSIS/LLVM-*-win64")]
199+
if len(packs_path) > 1:
200+
raise Exception("Find more than one LLVM-* package")
201+
202+
if not packs_path:
203+
raise Exception("Didn't find any LLVM-* package")
204+
return
205+
206+
llvm_package_path = f"_CPack_Packages/win64/NSIS/{packs_path[0].name}"
207+
windows_package_dir = build_dir.joinpath(llvm_package_path).resolve()
208+
209+
# mv package dir outside of build
210+
shutil.move(str(windows_package_dir), str(llvm_dir))
211+
# rm -r build
212+
shutil.rmtree(str(build_dir))
213+
# mkdir build
214+
build_dir.mkdir()
215+
# move back all the subdiretories under cpack directory(bin/include/lib) to build dir
216+
moved_package_dir = llvm_dir.joinpath(packs_path[0].name)
217+
for sub_dir in moved_package_dir.iterdir():
218+
shutil.move(str(sub_dir), str(build_dir))
219+
moved_package_dir.rmdir()
196220

197221
def main():
198222
parser = argparse.ArgumentParser(description="build necessary LLVM libraries")
@@ -304,7 +328,11 @@ def main():
304328
)
305329
is not None
306330
):
307-
repackage_llvm(llvm_dir)
331+
# TODO: repackage process may change in the future, this work for LLVM 15.x
332+
if "windows" == platform:
333+
repackage_llvm_windows(llvm_dir)
334+
else:
335+
repackage_llvm(llvm_dir)
308336

309337
return True
310338
except subprocess.CalledProcessError:

build-scripts/config_common.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ if (WAMR_BUILD_JIT EQUAL 1)
102102
if (NOT DEFINED LLVM_DIR)
103103
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
104104
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
105-
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
106-
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/win32build")
107-
endif ()
108105
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
109106
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_BUILD_ROOT}")
110107
endif ()

build-scripts/runtime_lib.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ if (WAMR_BUILD_INTERP EQUAL 1)
5959
endif ()
6060

6161
if (WAMR_BUILD_FAST_JIT EQUAL 1)
62-
include (${IWASM_DIR}/fast-jit/iwasm_fast_jit.cmake)
62+
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
63+
message ("Fast JIT currently not supported on Windows")
64+
set (WAMR_BUILD_FAST_JIT 0)
65+
else ()
66+
include (${IWASM_DIR}/fast-jit/iwasm_fast_jit.cmake)
67+
endif ()
6368
endif ()
6469

6570
if (WAMR_BUILD_JIT EQUAL 1)
@@ -104,6 +109,10 @@ if (WAMR_BUILD_WASI_NN EQUAL 1)
104109
endif ()
105110

106111
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
112+
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
113+
set (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 0)
114+
message ("Lib pthread semaphore currently not supported on Windows")
115+
endif ()
107116
include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
108117
# Enable the dependent feature if lib pthread is enabled
109118
set (WAMR_BUILD_THREAD_MGR 1)

core/iwasm/libraries/lib-pthread/lib_pthread.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set (LIB_PTHREAD_DIR ${CMAKE_CURRENT_LIST_DIR})
66
add_definitions (-DWASM_ENABLE_LIB_PTHREAD=1)
77

88
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
9-
add_definitions (-DWASM_ENABLE_LIB_PTHREAD_SEMAPHORE=1)
9+
add_definitions (-DWASM_ENABLE_LIB_PTHREAD_SEMAPHORE=1)
1010
endif()
1111

1212
include_directories(${LIB_PTHREAD_DIR})

wamr-compiler/CMakeLists.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,10 @@ endif()
163163
# Enable LLVM
164164
if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
165165
set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
166-
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
167-
if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
168-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
169-
endif ()
170-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
171-
else()
172-
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
173-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
174-
endif ()
175-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
166+
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
167+
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
176168
endif ()
169+
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
177170
endif ()
178171

179172
find_package(LLVM REQUIRED CONFIG)

0 commit comments

Comments
 (0)